Arc Forumnew | comments | leaders | submitlogin
3 points by evanrmurphy 5123 days ago | link | parent

> Macro: (thunk body). It's simple enough. Just like the square bracket syntax covers one-argument functions, this can cover zero-argument functions.

A side effect of making all function arguments optional [1] is that the square bracket syntax can then cover zero-argument functions too, so we get this additional (shorter) way to express your thunk example:

  [err "Ack! You called me!"]
---

[1] http://arclanguage.org/item?id=13030



1 point by akkartik 5123 days ago | link

Nice. So you can use [] if it saves you a set of parens, and thunk to sidestep the implicit function call:

  (thunk 34)

-----

1 point by rocketnia 5123 days ago | link

Actually, I don't use 'thunk when it doesn't save me parens. Both "thunk" and "fn ()" take up the same number of characters (albeit not the same number of tokens), and I figure Arc programmers will have to look up what 'thunk means more often than they look up 'fn. :-p

Incidentally, it actually does save parens in that case:

  thunk.34

-----