[OpenSCAD] eval( ) ???

runsun runsun at gmail.com
Mon May 18 17:14:43 EDT 2015


doug.moen wrote
> Now I'll copy and paste part of Yona's post, with terminology and syntax
> changed to correspond to my current OpenSCAD 2 design:
> 
> // If we consider { ... } to be an "inline object", you get associative
>> arrays for free:
>> data = {
>>    a = 10;
>>    b = 20;
>> }
>> echo(data.a);
>> // You can create a copy with new values as well
>> data2 = data(b=30, c=100);

I like this idea. For the on-the-fly local var assignment in data(b=30,
c=100), openscad seems to already have this capacity:

  echo( b=30, c=100 );

b,c are local variables created at the run time. 

Also would be great if, other than *data.a*, we can do *x=data["a"]*,
*x=data("a")* (in case it needs to contain space) or even *x=data(a)*.

One more thing, variable name like 3a, 4b are allowed in openscad. Will
data.3a also be allowed ?

And, on top of that, we also need:

   keys(data) ==> ["a","b"]  
   values(data) ==> [10,20]

or data.keys, data.values, such that they can be iterated over. 

This brings up: if we do *[ for(x=data) ...]*, what would x stands for.



-----

$  Runsun Pan, PhD 

$ -- OpenScad_DocTest: doc and unit test ( Github , Thingiverse  ) 

$ -- hash parameter model: here , here 

$ -- Linux Mint 17.1 Rebecca x64  + OpenSCAD 2015.03.15/2015.04.01.nightly 




--
View this message in context: http://forum.openscad.org/eval-tp12627p12700.html
Sent from the OpenSCAD mailing list archive at Nabble.com.




More information about the Discuss mailing list