Arc Forumnew | comments | leaders | submitlogin
1 point by akkartik 3597 days ago | link | parent

I'm curious how your square bracket syntax works. In particular, why does this work?

  mtl> ([_.car] '(1 2 3))
  1
But not this?

  mtl> ([0._] '(1 2 3))
  Exception: Symbol is not bound: 0


2 points by c-a-smallwood 3597 days ago | link

Essentially the syntax is the same, but with one difference: If the body of the bracket function ONLY consists of a dotted expression, the body of the function IS that expression. Example:

  Anarki:
  [car._] => (fn (_) ((car _))) ; note extra parens
  [car _] => (fn (_) (car _))

  MTL:
  [_.car] => (fn (_) (car _))
  [car _] => (fn (_) (car _))
I mainly took this step to take advantage of having support for multiple "dots", Example:

  x.car.type => (type (car x))
It's just more readable in my opinion. In regards to the second part of your post, it's because of a bug in my number reader, which I'll fix soon. Thanks for pointing it out!

I plan to add n-expression support into bracket functions, too. It would make the following work:

  ([_(1)] '(1 2 3)) => 2

-----

2 points by akkartik 3597 days ago | link

Nice!

I've criticized sweet-exprs in the past as trying to do too much (https://news.ycombinator.com/item?id=8507385). But the original subset you're implementing here is very useful.

(I'm still opposed to neoteric expressions, because parens before function is The One True Way, especially in the presence of infix: http://arclanguage.org/item?id=16924. But I won't agitate for it again since n-exprs are optional :)

BTW, in searching for the above link I ran across http://arclanguage.org/item?id=18261, which you might find interesting if you hadn't already seen it.

-----