What do you guys think to have an eval() to evaluate code ?I am thinking that
this would help in area where "function as a variable" is needed, which
openscad can't do.For example, we can have a module call Line from point P
to Q :
module Line ( [P,Q],
formula="sin(x)"
,
scope=["x",[0,90,180,270]]
){ formula to be converted to points : points0 =
eval( formula, scope )
(some other processings to use points0): points = .... faces= ....
polyhedron( points= points, faces=faces)}
Once this is set, we can have all kinds of different shapes of Lines,
generating from this single Line module.
$ 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-tp12627.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
My feeling is that it's more important to have first class function
values, and eval() is a poor substitute.
FWIW, first class function values is part of the set of changes that I
am currently discussing with Marius.
Doug Moen.
On 12/05/2015, runsun runsun@gmail.com wrote:
What do you guys think to have an eval() to evaluate code ?I am thinking
that
this would help in area where "function as a variable" is needed, which
openscad can't do.For example, we can have a module call Line from point P
to Q :
module Line ( [P,Q],
formula="sin(x)"
,
scope=["x",[0,90,180,270]]
){ formula to be converted to points : points0 =
eval( formula, scope )
(some other processings to use points0): points = .... faces= ....
polyhedron( points= points, faces=faces)}
Once this is set, we can have all kinds of different shapes of Lines,
generating from this single Line module.
$ 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-tp12627.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Indeed. A first class function will work pretty well in cases like I post
above. Just thought of something. Since in openscad, parameters and
functions are stored in different places: abc=3; function
abc()=...;Assigning abc to a parameter, if possible, will be confusing:
x = abc; // function or parameter?A possible way out of this is like what
Visual Basic does: x = something; // assign parameter set x =
something; // assign objectThat is, set for object assignment. In
openscad, could be function or module assignment. Not sure how expensive it
is though.
$ 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-tp12627p12630.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
Oh, god. Please do not head towards Visual Basic.
On 5/13/2015 12:56 AM, runsun wrote:
Indeed. A first class function will work pretty well in cases like I post above.
Just thought of something. Since in openscad, parameters and functions are stored in different places:
|
abc=3;
function abc()=...;
|
Assigning|abc| to a parameter, if possible, will be confusing:
|
x = abc; // function or parameter?
|
A possible way out of this is like what Visual Basic does:
|
x = something; // assign parameter
set x = something; // assign object
|
That is,set for object assignment. In openscad, could be function or module assignment. Not sure how expensive it is though.
$
http://forum.openscad.org/mailing_list/MailingListOptions.jtp?forum=1 Runsun
Pan, PhD
$ -- OpenScad_DocTest: doc and unit test ( Github
https://github.com/runsun/openscad_doctest, Thingiverse
https://www.thingiverse.com/thing:410831 )
$ -- hash parameter model: here
http://forum.openscad.org/parameterized-models-td8303.html#a8306,
here
http://forum.openscad.org/Can-I-get-some-code-review-up-in-here-tp12341p12355.html
$ -- Linux Mint 17.1 Rebecca x64 + OpenSCAD
2015.03.15/2015.04.01.nightly
View this message in context: Re: eval( ) ???
http://forum.openscad.org/eval-tp12627p12630.html
Sent from the OpenSCAD mailing list archive
http://forum.openscad.org/ at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
No virus found in this message.
Checked by AVG - www.avg.com http://www.avg.com
Version: 2015.0.5863 / Virus Database: 4342/9758 - Release Date: 05/12/15
On Tue, 12 May 2015 22:17:20 -0400
doug moen doug@moens.org wrote:
My feeling is that it's more important to have first class function
values, and eval() is a poor substitute.
Definitely agree that function values is a better idea. Plus eval()
almost always results in major unintended consequences.
FWIW, first class function values is part of the set of changes that I
am currently discussing with Marius.
Doug Moen.
On 12/05/2015, runsun runsun@gmail.com wrote:
What do you guys think to have an eval() to evaluate code ?I am
thinking that
this would help in area where "function as a variable" is needed,
which openscad can't do.For example, we can have a module call Line
from point P to Q :
module Line ( [P,Q],
formula="sin(x)"
,
scope=["x",[0,90,180,270]]
){ formula to be converted to points : points0 =
eval( formula, scope )
(some other processings to use points0): points = ....
faces= ....
polyhedron( points= points, faces=faces)}
Once this is set, we can have all kinds of different shapes of
Lines, generating from this single Line module.
$ 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-tp12627.html Sent from the OpenSCAD
mailing list archive at Nabble.com.
--
Understanding is a three-edged sword. -- Kosh in "Deathwalker"
If I didn't use the keyword "Visual Basic", but present it as just an idea,
will you have the same resentment?To me, borrowing idea from other language
doesn't mean the entire openscad is going toward it. It all depends on how
to implement to fit needs. Aside from that, using set for func/mod
assignment does have its down side. The following does look weird :
some_module( arg1, set arg2= some_func ) So, alternatively, we can use
a func specifically designed for this (this time I won't say where the idea
is from :) ): x1 = abc; // assign parameter abc x2 = function( abc )
; // assign function abc
$ 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-tp12627p12634.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
I'd rather see that function names and variables are saved in the same
scope, even though it might get backwards incompatible.
Miro Hrončok
Telefon: +420777974800
2015-05-13 18:55 GMT+02:00 runsun runsun@gmail.com:
If I didn't use the keyword "Visual Basic", but present it as just an idea,
will you have the same resentment?
To me, borrowing idea from other language doesn't mean the entire openscad
is going toward it. It all depends on how to implement to fit needs.
Aside from that, using set for func/mod assignment does have its down side.
The following does look weird :
some_module( arg1, set arg2= some_func )
So, alternatively, we can use a func specifically designed for this (this
time I won't say where the idea is from :) ):
x1 = abc; // assign parameter abc
x2 = function( abc ) ; // assign function abc
$ 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: Re: eval( ) ???
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Agreed
On 5/13/2015 1:16 PM, Miro Hrončok wrote:
I'd rather see that function names and variables are saved in the same
scope, even though it might get backwards incompatible.
Miro Hrončok
Telefon: +420777974800
2015-05-13 18:55 GMT+02:00 runsun runsun@gmail.com:
If I didn't use the keyword "Visual Basic", but present it as just an idea,
will you have the same resentment?
To me, borrowing idea from other language doesn't mean the entire openscad
is going toward it. It all depends on how to implement to fit needs.
Aside from that, using set for func/mod assignment does have its down side.
The following does look weird :
some_module( arg1, set arg2= some_func )
So, alternatively, we can use a func specifically designed for this (this
time I won't say where the idea is from :) ):
x1 = abc; // assign parameter abc
x2 = function( abc ) ; // assign function abc
$ 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: Re: eval( ) ???
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
No virus found in this message.
Checked by AVG - www.avg.com
Version: 2015.0.5863 / Virus Database: 4342/9764 - Release Date: 05/13/15
Miro said: "I'd rather see that function names and variables are saved in
the same scope".
That's what I want as well. This would allow functions to be first class
values: you can pass them as arguments to functions, return them as
results, and store them as elements of a list. No arbitrary restrictions.
On 13 May 2015 at 13:16, Miro Hrončok miro@hroncok.cz wrote:
I'd rather see that function names and variables are saved in the same
scope, even though it might get backwards incompatible.
Miro Hrončok
Telefon: +420777974800
2015-05-13 18:55 GMT+02:00 runsun runsun@gmail.com:
If I didn't use the keyword "Visual Basic", but present it as just an
idea,
will you have the same resentment?
To me, borrowing idea from other language doesn't mean the entire
openscad
is going toward it. It all depends on how to implement to fit needs.
Aside from that, using set for func/mod assignment does have its down
side.
The following does look weird :
some_module( arg1, set arg2= some_func )
So, alternatively, we can use a func specifically designed for this (this
time I won't say where the idea is from :) ):
x1 = abc; // assign parameter abc
x2 = function( abc ) ; // assign function abc
$ 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: Re: eval( ) ???
Sent from the OpenSCAD mailing list archive at Nabble.com.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
On 2015-05-13 20:19, doug moen wrote:
Miro said: "I'd rather see that function names and variables are saved
in the same scope".
That's what I want as well. This would allow functions to be first class
values: you can pass them as arguments to functions, return them as
results, and store them as elements of a list. No arbitrary restrictions.
Just a point of reflection:
I think it is a mistake that OpenSCAD spends time on defining the syntax
of a language. All of the resources should be spent on improving
modelling features. I realise this is much too late given the user base
of the .scad files, but it strikes me as odd anyway.
A few years ago, I was part of a team that created an modelling
application with CAD features (it is still significant in its market
area). It used, and still uses, ACIS as its CAD core, with heavy use of
boolean operations so it is similar to OpenSCAD in some ways.
The team had a history of creating applications in the past with ad-hoc
command languages, and we found it was a bad idea in the long run. So
for the ACIS-based application we decided to use an existing language
interpreter with a documented syntax. We happened to choose JavaScript
as the core language and expressed all functionality as JavaScript
objects. It worked fine.
I am clearly not saying OpenSCAD should adopt JavaScript, but I think it
would have been easier and better if an existing language had been
adapted (AngelScript is another example) instead of developing a new one.
Anyway, I realise it is much too late.
What I would like to see is an improvement to the speed of the F6
rendering, it takes too long in some cases. Plus it would be nice with
more general sweep options and other common operations in CAD tools
(lofting is another example).
That said, OpenSCAD is my preferred application for designing 3d printed
parts! I quite enjoy it.
Carsten Arnholm