[OpenSCAD] Openscad Indirect Functions
runsun at gmail.com
Wed Oct 19 00:04:07 EDT 2016
> 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.
Well, when you write the code up to the point of "arr.map(...", you have
to leave the code and move to another place to write "function add2(x) = x +
then move back to complete it.
With lambda, you finish the code right there, don't have to switch places.
This is the same for code reader. When a reader reads the code to that
point, he/she has to first search and locate that function, then switch to
there to understand it, then switch back to continue. That's a lot of
distractions for such a simple task.
This is what I call *brain twists*, an unnecessary detour or distraction
to your coding focus. IMO, a good language should reduce these sorts of
"*brain twists*" as much as possible.
you do 'arr[-1]' in python. It is straight forward and, as the "-" indicates
you have to use other approaches, like 'arr[arr.length-1]', or
Yes, it's "just a little bit verbose", but it is an unnecessary "brain
that can be avoided.
Besides, if a language is designed with this "just a little bit verbose"
then all the little bits finally adds up and results in a verbosity that's
"just a little".
Python is designed with less brain twist that's why it's considered more
and one of the easiest to learn for beginners.
> It means OpenSCAD code becomes a little harder to read for people that
> 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
> and there needs to be a more test cases.
The above statements you made here applies to ANY new feature, thus are
not valid arguments when discussing a specific feature.
$ 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-tp18522p18773.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
More information about the Discuss