tomhrr / dale

Lisp-flavoured C
BSD 3-Clause "New" or "Revised" License
1.03k stars 48 forks source link

Operator macros doesn't work currently #93

Closed porky11 closed 8 years ago

porky11 commented 8 years ago

the error is unquoting null node, in almost every module, which means, that the versions of the macros will be called without variatic args, so the argument of uql is (nullptr DNode), so the function selection is done wrong in some cases

(using-namespace std.macros
(def + (macro intern (a b ...)
  (qq + (+ (uq a) (uq b)) (uql (get-varargs-list (- (arg-count mc) 2))))))
)

(def new-type (struct intern ((value int))))

(def + (fn intern (retval new-type) ((a new-type) (b new-type))
  (setf (:@ retval value)  (+ (@: a value) (@: b value))))) ;;this `+` doesn't use + for ints, but the + macro, but only if this function is defined after the macro
tomhrr commented 8 years ago

On Sun, Sep 11, 2016 at 04:03:08AM -0700, Fabio Krapohl wrote:

the error is unquoting null node, in almost every module, which means, that the versions of the macros will be called without variatic args, so the argument of uql is (nullptr DNode), so the function selection is done wrong in some cases

Thanks, it looks like there are some cases where macros are incorrectly being preferred to functions. This has been fixed for this case, but it's likely that more changes will be required.

tomhrr commented 8 years ago

This should be fine now.

porky11 commented 8 years ago

This also seems to work now, since #106 has been fixed

porky11 commented 8 years ago

Wait, it just works for functions defined before operator-macros is imported, so I have to ensure that all function-overloads are defined, before i use the variadic version of the operator

porky11 commented 8 years ago

I tried it again, seems to work, even if importing it before everything else