Arc Forumnew | comments | leaders | submitlogin
2 points by partdavid 6166 days ago | link | parent

The second def to me implies that add-1 returns a function, not a value.

Since arc supports subscripting data structures using a list (I'm sorry if that's a terrible way to say it--I'm not a lisper), the last expression can be non-uglified:

   (def add2 [+ (_ 0) (_ 1)])
So [ ] is an anonymous single-argument function, and when more than one argument is passed to the function, a list is passed.

How would that grab you?



1 point by projectileboy 6165 days ago | link

Actually, forget everything I said - I agree with your first sentence. I had originally thought there might be an elegant way to ditch formal parameter lists when there aren't optional or rest parameters. But the cost seems too high for the value added.

-----

2 points by mcoles 6165 days ago | link

It's totally possible that I'm missing the point, but how is _ 0 and _ 1 and better than x and y? Sure this gives you an implicit parameter list, but when you go beyond short functions like add2, wouldn't it be nice to have names for variables? My understanding of [ _ ] was for all those quick, inline anonymous functions, not for function definition of non-trivial functions.

-----