Hi all.
I am currently experimenting with making modules first class.
First class simply means
-
You can create a variable representing a module, (without instantiating it into the CSG tree).
-
You can access member attributes of the module, without instantiating it into the CSG tree.
-
You can use modules as member attributes of a parent module without instantiating them.
-
You can pass a module to a function (without instantiating it into the CSG tree).
-
You can return a module from a function (without instantiating it into the CSG tree).
-
You can put a module into a list or dictionary etc.
-
You can also instantiate the module into the CSG tree of course, using the existing function call syntax as with any other module
I originally posted on the github issues list
https://github.com/openscad/openscad/issues/4336. Apologies to those that replied for modifying the text, but I wanted to refine what I was trying to achieve, since I think it was closed before anyone 'got it'.
Anyway I have started to try to incorporate the feature into my fork of Openscad, since it seems very useful to me and doesnt seem to overlap with other features
You can see work on the syntax on my openscad fork in the first_class_module branch
Here is an example of syntax, which runs on the modified executable
https://github.com/kwikius/openscad/blob/first-class-module/tests/data/scad/experimental/first_class_module/first_class_modules.scad
Its early days , but any comments appreciated.
Hi all.
I am currently experimenting with making modules first class.
First class simply means
1. You can create a variable representing a module, (without instantiating it into the CSG tree).
2. You can access member attributes of the module, without instantiating it into the CSG tree.
3. You can use modules as member attributes of a parent module without instantiating them.
4. You can pass a module to a function (without instantiating it into the CSG tree).
5. You can return a module from a function (without instantiating it into the CSG tree).
6. You can put a module into a list or dictionary etc.
7. You can also instantiate the module into the CSG tree of course, using the existing function call syntax as with any other module
I originally posted on the github issues list
https://github.com/openscad/openscad/issues/4336. Apologies to those that replied for modifying the text, but I wanted to refine what I was trying to achieve, since I think it was closed before anyone 'got it'.
Anyway I have started to try to incorporate the feature into my fork of Openscad, since it seems very useful to me and doesnt seem to overlap with other features
You can see work on the syntax on my openscad fork in the first_class_module branch
Here is an example of syntax, which runs on the modified executable
https://github.com/kwikius/openscad/blob/first-class-module/tests/data/scad/experimental/first_class_module/first_class_modules.scad
Its early days , but any comments appreciated.