tomhrr / dale

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

ambigous macros don't work #106

Closed porky11 closed 7 years ago

porky11 commented 7 years ago

Example:

(import cstdio)

(def x (macro intern (a (b int))
  a))

(def x (macro intern ((b int) a)
  a))

(def main (fn extern-c void (void)
  (printf "%i" (x 1 2)))) ;;prints 2, second macro is selected

is the behaviour, when multiple macros are possible, wanted, or should such a case cause an error, and you have explicitely define?

another example, which doesn't work:

(import cstdio)

(def x (macro intern (c (b int) a)
  a))

(def x (macro intern (a (b int) (c int))
  a))

(def main (fn extern-c void (void)
  (printf "%i" (x 1 2 3)))) ;;error: overloaded function/macro not in scope: 'x' (parameters are int int int, closest candidate expects (p DNode) int (p DNode))

why doesn't this work, but the above? same error with (x 1 2 "a"), which should use the first version of x, so this is a bug (seems the selection of overloaded function still doesn't work correctly with untyped macros)

tomhrr commented 7 years ago

On Fri, Sep 16, 2016 at 03:23:39PM -0700, Fabio Krapohl wrote:

why doesn't this work, but the above? (seems the selection of overloaded function still doesn't work correctly with untyped macros)

Thanks, this has been fixed, and documentation on how dispatch should work has been added to the macros page.