discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] A = A + 1;

AG
Adrian Grajdeanu
Tue, Feb 3, 2015 8:38 PM

A well reasoned, and encouraging response. I offer my help with language improvements. Seems the need is there, i have the experience and the interest.

A well reasoned, and encouraging response. I offer my help with language improvements. Seems the need is there, i have the experience and the interest.
JL
Joseph Lenox
Tue, Feb 3, 2015 8:51 PM

If you want to add iterativeness, please put it behind syntax so the person
describing the part is explicit when they say "Yes, I want to do iterative
work now", and at least block-level, so the parser isn't stuck assuming
that everything depends on previous stuff. That should make things less
crazy for the rest of the compiler and still allow some measure of
parallelism.

This is how two of the other big HDLs (Verilog and VHDL) do it with their
behavioral modes. It's still a pain, as you can easily have a stack of
dependencies. Alternatively, you can instead use a real programming
language to generate OpenSCAD syntax (SolidPython, scripts, etc), so you
get the comforting and familiar iterativeness.

--Joseph Lenox

On Tue, Feb 3, 2015 at 2:38 PM, Adrian Grajdeanu adriang0@cox.net wrote:

A well reasoned, and encouraging response. I offer my help with language
improvements. Seems the need is there, i have the experience and the
interest.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

If you want to add iterativeness, please put it behind syntax so the person describing the part is explicit when they say "Yes, I want to do iterative work now", and at least block-level, so the parser isn't stuck assuming that everything depends on previous stuff. That should make things less crazy for the rest of the compiler and still allow some measure of parallelism. This is how two of the other big HDLs (Verilog and VHDL) do it with their behavioral modes. It's still a pain, as you can easily have a stack of dependencies. Alternatively, you can instead use a real programming language to generate OpenSCAD syntax (SolidPython, scripts, etc), so you get the comforting and familiar iterativeness. --Joseph Lenox On Tue, Feb 3, 2015 at 2:38 PM, Adrian Grajdeanu <adriang0@cox.net> wrote: > A well reasoned, and encouraging response. I offer my help with language > improvements. Seems the need is there, i have the experience and the > interest. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
NH
nop head
Tue, Feb 3, 2015 8:52 PM

Finally then, absent variables in the language .., can everything be done?

Yes everything can be done with recursion. I don't know why people say
yuck. It's much more like pure maths and far easier to see that it is
correct.

On 3 February 2015 at 20:38, Adrian Grajdeanu adriang0@cox.net wrote:

A well reasoned, and encouraging response. I offer my help with language
improvements. Seems the need is there, i have the experience and the
interest.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

>Finally then, absent variables in the language .., can everything be done? Yes everything can be done with recursion. I don't know why people say yuck. It's much more like pure maths and far easier to see that it is correct. On 3 February 2015 at 20:38, Adrian Grajdeanu <adriang0@cox.net> wrote: > A well reasoned, and encouraging response. I offer my help with language > improvements. Seems the need is there, i have the experience and the > interest. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
NH
nop head
Tue, Feb 3, 2015 9:02 PM

function sum(v,i = 0) = i < len(v) ? v[i] + sum(v, i+1) : 0;

function ave(v) = sum(v) / len(v);

How can you get clearer or more concise than that?

On 3 February 2015 at 20:52, nop head nop.head@gmail.com wrote:

Finally then, absent variables in the language .., can everything be done?

Yes everything can be done with recursion. I don't know why people say
yuck. It's much more like pure maths and far easier to see that it is
correct.

On 3 February 2015 at 20:38, Adrian Grajdeanu adriang0@cox.net wrote:

A well reasoned, and encouraging response. I offer my help with language
improvements. Seems the need is there, i have the experience and the
interest.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

function sum(v,i = 0) = i < len(v) ? v[i] + sum(v, i+1) : 0; function ave(v) = sum(v) / len(v); How can you get clearer or more concise than that? On 3 February 2015 at 20:52, nop head <nop.head@gmail.com> wrote: > >Finally then, absent variables in the language .., can everything be done? > > Yes everything can be done with recursion. I don't know why people say > yuck. It's much more like pure maths and far easier to see that it is > correct. > > > > > > On 3 February 2015 at 20:38, Adrian Grajdeanu <adriang0@cox.net> wrote: > >> A well reasoned, and encouraging response. I offer my help with language >> improvements. Seems the need is there, i have the experience and the >> interest. >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> >
M
Michele
Tue, Feb 3, 2015 9:28 PM

/"The thing to remember with OpenSCAD is that it is timeless."/

This cannot be true.  Otherwise, "rotate translate object" would be
non-deterministicly identical to "translate rotate object", and they're not.
Where object ends up depends on which transformation gets executed first.
And if something gets executed "first", then time is involved.

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

/"The thing to remember with OpenSCAD is that it is timeless."/ This cannot be true. Otherwise, "rotate translate object" would be non-deterministicly identical to "translate rotate object", and they're not. Where object ends up depends on which transformation gets executed first. And if something gets executed "first", then time is involved. -- View this message in context: http://forum.openscad.org/A-A-1-tp11385p11420.html Sent from the OpenSCAD mailing list archive at Nabble.com.
ED
Ethan Dicks
Tue, Feb 3, 2015 9:31 PM

On Tue, Feb 3, 2015 at 4:28 PM, Michele denber@mindspring.com wrote:

/"The thing to remember with OpenSCAD is that it is timeless."/

This cannot be true.  Otherwise, "rotate translate object" would be
non-deterministicly identical to "translate rotate object", and they're not.
Where object ends up depends on which transformation gets executed first.
And if something gets executed "first", then time is involved.

"Timeless" does not mean "Non-Hierarchical".  R T O is not the same as
T R O because it's R->T not T->R.

There is an order, but it's not iterative nor is there a frozen
"moment in time" one could peek at the state of things and alter the
outcome.

-ethan

On Tue, Feb 3, 2015 at 4:28 PM, Michele <denber@mindspring.com> wrote: > /"The thing to remember with OpenSCAD is that it is timeless."/ > > This cannot be true. Otherwise, "rotate translate object" would be > non-deterministicly identical to "translate rotate object", and they're not. > Where object ends up depends on which transformation gets executed first. > And if something gets executed "first", then time is involved. "Timeless" does not mean "Non-Hierarchical". R T O is not the same as T R O because it's R->T not T->R. There is an order, but it's not iterative nor is there a frozen "moment in time" one could peek at the state of things and alter the outcome. -ethan
DE
David Eccles (gringer)
Tue, Feb 3, 2015 10:24 PM

I don't have a problem with OpenSCAD, because I treat it as a functional
language (with some recursion limitations), and everything is fine. There
are ways to implement variable modification in functional languages by
including a data store as an additional function parameter -- I'd have to
dig out my CS notes to find the way I was taught -- but it's frequently the
case that such a design is not necessary.

The 'concat' operator was, in my opinion, the final advance to make the
language essentially turing complete (and therefore fully expressive).
However, for proper use of functional languages, recursion is required in
many cases.

Thinking about the vector sum question, here's a recursive version that
basically uses assignment. The "cumSum" argument stores the current sum, and
the "pos" argument stores the current location in the vector:

function vsum(vec, pos = 0, cumSum = 0) =
pos >= len(vec) ? cumSum : vsum(vec, pos+1, cumSum + vec[pos]);

echo(vsum([1,2,3,8]));

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

I don't have a problem with OpenSCAD, because I treat it as a functional language (with some recursion limitations), and everything is fine. There are ways to implement variable modification in functional languages by including a data store as an additional function parameter -- I'd have to dig out my CS notes to find the way I was taught -- but it's frequently the case that such a design is not necessary. The 'concat' operator was, in my opinion, the final advance to make the language essentially turing complete (and therefore fully expressive). However, for proper use of functional languages, recursion is required in many cases. Thinking about the vector sum question, here's a recursive version that basically uses assignment. The "cumSum" argument stores the current sum, and the "pos" argument stores the current location in the vector: function vsum(vec, pos = 0, cumSum = 0) = pos >= len(vec) ? cumSum : vsum(vec, pos+1, cumSum + vec[pos]); echo(vsum([1,2,3,8])); -- View this message in context: http://forum.openscad.org/A-A-1-tp11385p11422.html Sent from the OpenSCAD mailing list archive at Nabble.com.