Arc Forumnew | comments | leaders | submitlogin
3 points by rntz 5663 days ago | link | parent

The only thing that bothers me about this is the same thing that bothers me about 'o for optional arguments: that it messes with destructuring.

    arc> (let (o x) '(1 2) x)
    2     ;expected result
    (1 2) ;actual result
The reason for this is that `(let ,var ,exp ,@body) translates into `((fn (,var) ,@body) ,exp)), and so if var is a list beginning with 'o, it gets interpreted as an optional argument. Likewise:

    arc> (let (c d e) '(1 2 3) e)
    3 ; current result
    Error: "reference to undefined identifier: _e" ; result with argument conversion


2 points by CatDancer 5663 days ago | link

I agree, I'd like to have some syntax for hacking function arguments that doesn't interfere with destructuring.

-----

2 points by rntz 5662 days ago | link

There are at least two options here which don't interfere with existing syntax; I'll demonstrate using optional arguments rather than argument conversion for simplicity:

    (def foo (x y ('o z)) ...)
This doesn't interfere because binding 'quote is more or less illegitimate in arc. (The reason for this lies in the underlying scheme - if 'quote is lexically bound as an identifier, it doesn't function as a special form.)

    (def foo (x y (:o z)) ...)
This doesn't interfere because binding to ':o in arc is more-or-less useless, because ssyntax expands away ':o to 'o. The same is true of '+o.

-----

2 points by shader 5662 days ago | link

I personally like the :o, maybe just because it reminds me of CL. Anyway, it shouldn't be too hard to add a special case for ': in ssyntax if it is the first character.

After all, wouldn't that be an error anyway? Therefore redefining it would not interfere with normal usage of ':. In fact, it makes sense to have different versions for each ssyntax if it is at the beginning, end or middle.

-----