It is a bit scary that a user defined function can override a preexisting one
without some override keyword. Especially if the language is growing and it
is possible that someone may define a function that is used in another
library which might cause unexpected results or if a user defines their own
function without realising that they had already defined it already.
Perhaps an override keyword could be added to indicate intent? And without
it cause an error on compile?
Thanks,
A
--
View this message in context: http://forum.openscad.org/Overriding-of-user-defined-and-non-user-defined-functions-tp11242.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
What is needed more is a way to call the built-in functions & modules [ie
cube() difference() etc] if they have been redefined. Or maybe call the next
lower version on the stack, thus having cascadable re-definitions. Sort of
like FORTH IIRC.
That would make it possible to override the default behavior.
(assuming the syntax is & to mean call the built-in)
module cube(v3,center) { // stupid example - all non centered cubes are red.
if (!center)
color("red")
&cube(v3,true)
else
&cube(v3,false);
}
Unless specifically shown otherwise above, my contribution is in the Public Domain; To the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. This work is published globally via the internet. :) Inclusion of works of previous authors is not included in the above.
View this message in context: http://forum.openscad.org/Overriding-of-user-defined-and-non-user-defined-functions-tp11242p11243.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
That would help, but still, I want the intent to be perfectly clear that /"I,
the writer of this function/module, so do understand that I want to override
this function/module and do realize by doing so, I may totally shoot myself
in the foot."/
A
--
View this message in context: http://forum.openscad.org/Overriding-of-user-defined-and-non-user-defined-functions-tp11242p11250.html
Sent from the OpenSCAD mailing list archive at Nabble.com.