[OpenSCAD] Openscad Indirect Functions
G. Wade Johnson
gwadej at anomaly.org
Tue Oct 18 23:33:45 EDT 2016
On Tue, 18 Oct 2016 23:52:33 +0100
nop head <nop.head at gmail.com> wrote:
> 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; ?
No harder than it would be to require that arithmetic expressions can
only be written in functions.
Just like it can be handy to have an arithmetic expression in-line,
sometimes having a function in-line is clearer than the alternative.
> 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/
> > Convert-from-object-to-polygon-polyhedron-tp18522p18769.html
> > Sent from the OpenSCAD mailing list archive at Nabble.com.
> > _______________________________________________
> > OpenSCAD mailing list
> > Discuss at lists.openscad.org
> > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
You write code as if the person who will maintain your code is a violent
psychopath who knows where you live. -- John F. Woods
More information about the Discuss