[OpenSCAD] Openscad Indirect Functions

otto otto at 123phase.com
Mon Oct 24 13:13:55 EDT 2016


> And you can't write a curried function
> at all using Otto's @ notation (I've tried, the code doesn't work).

Doug is right.  I tried it too and there is a bug in my code.  I will
have to work on that.

f = @(x:@(y:x+y));  //Should work and doesn't.

Otto

On Sun, 23 Oct 2016 07:46:01 -0400
doug moen <doug at moens.org> wrote:

> Otto wrote:
> 
> > I see a major need for the following:
> > 1. The adoption and implementation of anonymous function syntax.
> > ...
> > Doug proposes anonymous functions be written function(<arglist>)
> > expr
> >
> 
> The OpenSCAD2 proposal was written during May-July 2015. I've had a
> lot of new ideas since then, but I mostly haven't updated the
> document, because it was exhausting to write, and time
> considerations. Now I'm actually coding, and trying to prototype some
> of the ideas. I'll write new documentation once my design stabilizes.
> 
> My original 'function(arglist)expr' syntax was based on the old
> Javascript syntax for anonymous functions. It turns out that when you
> try to use this syntax for writing code, it sucks. That's probably
> why Javascript has replaced this syntax with arrow notation. I'm
> using arrow notation now as well. My syntax is actually identical to
> the new Java syntax for anonymous functions, which uses ->
> (Javascript is the same except it uses =>).
> 
> My original proposed syntax is too verbose for short anonymous
> functions like 'x->x+1', and if you want a long anonymous function,
> it might be clearer to write a named function definition, as nop head
> suggested.
> 
> The other problem with my original syntax is that it sucks for curried
> functions. The OpenSCAD2 proposal explains why curried functions are
> important.
> 
> In arrow notation, you can write `x->y->x+y`, and that's a curried
> function. In the originally proposed syntax, that would be
> `function(x)(function(y)x+y)` which is a lot more verbose, and
> requires nested parentheses. And you can't write a curried function
> at all using Otto's @ notation (I've tried, the code doesn't work).





More information about the Discuss mailing list