Arc Forumnew | comments | leaders | submitlogin
2 points by akkartik 4674 days ago | link | parent

  mklist +
         -
         /
I don't see why this needs the 4-indent. Wouldn't bullet simply translate '(-)' to '-' like it does for '(1)'?

Perhaps this is a better example of the problem?

  mkList +
      - /
which would expand to (mkList + (- /)) without the 4-indent.

I have a slightly different rule at http://github.com/akkartik/wart#readme (search for 'one exception').

Again, I think my approach is better :) (I hope you find me saying that more useful than the cantankerous lisp veteran who says "noobs! Stop messing with my parens!")



1 point by seertaak 4674 days ago | link

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 4673 days ago | link

(Psst, to get italics, use asterisks, not underscores. http://arclanguage.org/formatdoc)

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...

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

  save-middle-earth!
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 4673 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 4673 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.
        false-clause

-----