[OpenSCAD] Functions literals / higher order functions
nop.head at gmail.com
Sat Nov 9 10:15:13 EST 2019
The issue is the old format functions have their own namespace,
separate from variables and modules so you can have the same name it all
three namespaces and there is no ambiguity. However new style function
literals are anonymous until you assign them to a variable and then that
variable is in the variable namespace, not the function namespace.
On Sat, 9 Nov 2019 at 15:03, adrianv <avm4 at cornell.edu> wrote:
> tp3 wrote
> > On 03.11.19 22:40, adrianv wrote:
> >> foo(function(x) sin(x))
> > Yes, all built-in functions and also those defined in
> > the previously existing function name() = expression
> > syntax have their own special namespace and are no values
> > that can be passed around. To do that they need to be
> > wrapped like that.
> Would it be worth adding a simpler mechanism for passing existing
> It seems like the existing scheme creates two independent namespaces for
> functions and it's sort of clumsy to get between them. In MATLAB, for
> example, you can pass an existing function by writing "@sin". I can
> imagine having to write code where I generate a table of function
> redefinitions to make it easy to pass pre-existing functions without the
> need for all the verbosity of a function declaration embedded in the code
> for every call.
> What would be the disadvantage of writing all of my functions using the new
> syntax. Would there be any problems with this? So always write
> funcname = function(...) definition....;
> This seems like it could be desirable since you can do something with a
> function literal defined this way that you can't do with a regular
> And there is no apparent advantage to defining functions the "normal"
> I mean, the one obvious limitation is that I no longer have a different
> namespace for functions if I do this.
> Sent from: http://forum.openscad.org/
> OpenSCAD mailing list
> Discuss at lists.openscad.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Discuss