[OpenSCAD] Openscad Indirect Functions
nop.head at gmail.com
Tue Oct 18 18:52:33 EDT 2016
On 18 October 2016 at 22:35, runsun <runsun at gmail.com> wrote:
> nophead wrote
> > There is no need for lambda at all. It is only syntactic sugar and since
> > nobody can agree on the syntax it is only ever sweet for a subset of
> > people.
> I disagree. There are places where a lambda is better fitted. For
> example, a temporary, quick handler like that in array.map( x=> x+2 ).
> The need of making a named function for this purpose actually makes
> the code more complicated and harder to write.
How is it hard or complicated to write a named function add2(x) = x + 2; ?
Anybody that knows how to write an OpenScad function can do it and the
result is more readable, it is just a bit more verbose, but not much.
> Personally, I don't mind what syntax to use. As long as the feature is
> there, I'll just adopt to it. Besides, nothing can please everybody.
> The important thing is to have it available for people who want it. For
> those who don't, then simply don't use it. I don't think it's gonna hurt.
It means OpenSCAD code becomes a little harder to read for people that have
not come across lambda before. Its syntax becomes more complex but there
isn't anything new that can be done with it. It becomes a slightly bigger
language to learn.
It also means OpenSCAD needs more maintenance as its code gets a bit bigger
and there needs to be a more test cases. Fine for indirect functions
because they add power but lambda doesn't. It is just a slight shortcut
that saves you thinking up a name. Unless some optimisation is done it
leads to code duplication because once a named function is written it can
be used multiple times.
> $ Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ),
> runscad.py ( 2 , git ), synwrite ( 2 ); $ tips: hash ( 2 ), matrix (
> 2 , 3 ), sweep ( 2 , 3 ), var ( 2 ), lerp , animation ( gif , prodVid ,
> animlib ), precision ( 2 ), xl-control , type , rounded polygon , chfont ,
> tailRecur ( 2, 3 ), isosphere ( 2 ), area , vol/center , RGB , CurvedImg ,
> tests ( 2 ); $ Apps: rollApp , blockscad , openjscad , on AWS ( pdf )
> View this message in context: http://forum.openscad.org/
> Sent from the OpenSCAD mailing list archive at Nabble.com.
> OpenSCAD mailing list
> Discuss at lists.openscad.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Discuss