Arc Forumnew | comments | leaders | submitlogin
1 point by seertaak 2326 days ago | link | parent

Well spotted; you've just waded into the dark corners of _bullet_ :)

The reason the 2-indent would evaluate (i.e. result in an invocation) is that '+', '-', etc. are _primitives_, which behave semantically like _functions_. For all other objects, the (1) rule applies.

Do you think this is too convoluted?

Alternatives I see:

1. The obvious is not to allow (obj-thing) ==> obj-thing. But then we'd need to define (func val (x) x) so that (e.g.):

     print: if (is-saviour name)
       val "go frodo"
       val "don't know you"
Otherwise, we'd have an error.

2. Make (fn-or-prim) ==> fn-or-prim (i.e. unifiy treatment of functions and objects, and in addition. To force evaluation of a 0-arity function, allow:

    save-middle-earth ()  // <-- () causes invocation.
What do you think?

3 points by rocketnia 2326 days ago | link

(Psst, to get italics, use asterisks, not underscores.

Option 2 looks particularly troublesome to me. A veteran lisp user seeing "save-middle-earth ()" will probably guess it means "(save-middle-earth ())", with () being the empty list. Do you have () in bullet?

It might be less confusing to use dot syntax instead, like this...

...because that looks a bit like "" syntax with no argument. Alternatitvely, you could go with a syntax that stands on its own rather than borrowing existing connotations:

However, I'm not sure any of these nullary call syntaxes gives you a clear translation to s-expressions. If "save-middle-earth." just becomes "((save-middle-earth))" and does nothing twice, that doesn't help. ^_^; (On the other hand, maybe you could make this work by treating ((x)) as a special case in the s-expression semantics.)

Here's a third (fourth? fifth?) option: Define (func call (f :rest args) (apply f args)).

  call save-middle-earth


1 point by seertaak 2326 days ago | link

Thanks for the tip about the formatting!

No, currently attempting to evaluate () is an error (and a bad crash with no error message, I'm embarrassed to say! [but now fixed and pushed]).

Your argument regarding () is pretty convincing. It's a bad idea. But I find the full-stop notation a bit jarring, not sure why. I'll try it and see if I get used to it... And I didn't want to tread on the "!" real-estate, given that's it's commonly used in identifiers.

I have to say I still lean slightly towards preferring a default of invocation for 0-arity functions, and using the "val" (again, id) function for passing the function itself.

Maybe the best approach is to offer a define-syntax functionality which somehow corrects the anomality (by visiting the AST and reducing without evaluating) before applying the macro transform. But that's quite possibly another can of worms...


1 point by seertaak 2325 days ago | link

Having slept on this, I think I'm going to remove the (obj) ==> obj reduction. I think the gain is not enough to compensate the loss of transparency.

It's not even that big of a loss, since you can write:

    if (condition)
        true-clause   // 4-indent.