[OpenSCAD] Functions literals / higher order functions

adrianv avm4 at cornell.edu
Sat Nov 9 13:01:15 EST 2019


I wasn't suggesting that the old syntax be removed.  Rather, I was pondering
how to write code in the future.  It appears like with the new function
syntax that it might make sense to always use the new one.  In other words,
to treat the old syntax like a sort of old-style method and abandon it.  

Out of curiosity, is there some particular use case for using variables with
the same name as functions, or you just find it convenient to make variables
named "square" and "cube" and so on?  


nophead wrote
>> But I don't think I'd really miss this.
> 
> Maybe but people like me would as I have made extensive use of it so
> changing it would break a lot of code.
> 
> On Sat, 9 Nov 2019 at 15:47, Torsten Paul <

> Torsten.Paul@

> > wrote:
> 
>> On 09.11.19 16:15, adrianv wrote:
>> > Would it be worth adding a simpler mechanism for passing
>> > existing functions?
>>
>> Yes, that certainly is open for discussion. It might even be
>> possible to bind the built-in functions to the respective
>> names in the variable namespace.
>>
>> As that is one layer up from the top layer available to the
>> user, it would still be possible to just overwrite those names
>> in existing code.
>>
>> I believe the only non-compatible change is that you can
>> still observe this by "if (is_undef(sin))" on top level.
>>
>> > It seems like the existing scheme creates two independent
>> > namespaces for functions and it's sort of clumsy to get
>> > between them.
>>
>> The other way around. Those separate namespaces already exist
>> and cause the issues now. The problem is that first class
>> functions obviously need to be in the variable namespace as
>> they are really just values.
>>
>> > 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....;
>>
>> Right now, the only disadvantage I'm aware of is that use<>
>> will not import them as they are variables, and use<> only
>> imports (old style) functions and modules.
>>
>> That's something which needs to be changed of cause.
>>
>> ciao,
>>   Torsten.
>>
>> _______________________________________________
>> OpenSCAD mailing list
>> 

> Discuss at .openscad

>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>
> 
> _______________________________________________
> OpenSCAD mailing list

> Discuss at .openscad

> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org





--
Sent from: http://forum.openscad.org/



More information about the Discuss mailing list