On Thu, Sep 01, 2022 at 02:04:53PM +0000, Andy Little via Discuss wrote:
You mean a function call of the variable name ?
t = module cube([1,2,3]);
t();
I think I can now do:
module t (sz)
{
cube (sz);
}
t = 13;
echo (t);
t(10);
Roger.
--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 **
f equals m times a. When your f is steady, and your m is going down
your a is going up. -- Chris Hadfield about flying up the space shuttle.
Rogier Wolff wrote:
On Thu, Sep 01, 2022 at 02:04:53PM +0000, Andy Little via Discuss wrote:
You mean a function call of the variable name ?
Nope I mean “instantiate the module into the CSG tree, using the existing function call syntax as with any other module”
t = module cube([1,2,3]); t();
I think I can now do:
module t (sz)
{
cube (sz);
}
t = 13;
echo (t);
t(10);
You have created a module named t and a variable named t. You can still do that. With the module_alias No existing code breaks is broken.
however if you do:
//--------
t=1;
t = [1,2,3];
t = "hello";
t = module cube([1,2,3]); // No instantiation of cube([1,2,3]) into the CSG tree
//------------------
you will get warnings
WARNING: t was assigned on line 1 but was overwritten in file build, line 2
WARNING: t was assigned on line 1 but was overwritten in file build, line 3
WARNING: t was assigned on line 1 but was overwritten in file build, line 4
That is existing openscad behaviour however
If you want to really confuse you can also do
cube = module cube([a,b,c]);
cube(); // instantiate a cube([1,2,3]) into the CSG tree
function cube() = module cube();
cube(); // instantiate a cube([1,2,3]) into the CSG tree
cube1 = cube();
I'll leave you to figure out what that actually means!