discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: [OpenSCAD] A = A + 1;

AG
Adrian Grajdeanu
Tue, Feb 3, 2015 4:40 PM

You may beat this into me, but you will not squash most people's expectation. Hence you will have no peace.

Why is there this stubborness to cripple variables? Is there a technical reason, or is merely adherence to some purist dogma?

I can understand the tree structure of an openscad 'program'. Not only can i understand it, but appreciate it enormously. This paradigm simplifies things and enables caching of geometrical elements. However programers feel the need for variables (in the classical way). If at some point you accept this statement, and endeavor to provide variables in a languge, then embrace it all the way and support variables in a manner free of gotchas or arbitrarily seeming limitation. 

-------- Original message --------
From: Alan Cox alan@lxorguk.ukuu.org.uk
Date:03/02/2015  11:19  (GMT-05:00)
To: Adrian Grajdeanu adriang0@cox.net
Cc: OpenSCAD general discussion discuss@lists.openscad.org
Subject: Re: [OpenSCAD] A = A + 1;

On Tue, 03 Feb 2015 10:20:53 -0500
Adrian Grajdeanu adriang0@cox.net wrote:

If this were an equation, you'd be right. But it isn't an equation. It is an assignment.

Depending how you look at it the statements in question are either
equations or just definitions.

In openscad  X = Y + 1 is a definition of X with a scope.

You cannot define X to be two things at once any more than you can define
anything else in life to be two conflicting things at once.

If you see it as an assignment you are going to continue suffering from
iterative programmer disease. Think of it as #define

Alan

You may beat this into me, but you will not squash most people's expectation. Hence you will have no peace. Why is there this stubborness to cripple variables? Is there a technical reason, or is merely adherence to some purist dogma? I can understand the tree structure of an openscad 'program'. Not only can i understand it, but appreciate it enormously. This paradigm simplifies things and enables caching of geometrical elements. However programers feel the need for variables (in the classical way). If at some point you accept this statement, and endeavor to provide variables in a languge, then embrace it all the way and support variables in a manner free of gotchas or arbitrarily seeming limitation.  -------- Original message -------- From: Alan Cox <alan@lxorguk.ukuu.org.uk> Date:03/02/2015 11:19 (GMT-05:00) To: Adrian Grajdeanu <adriang0@cox.net> Cc: OpenSCAD general discussion <discuss@lists.openscad.org> Subject: Re: [OpenSCAD] A = A + 1; On Tue, 03 Feb 2015 10:20:53 -0500 Adrian Grajdeanu <adriang0@cox.net> wrote: > If this were an equation, you'd be right. But it isn't an equation. It is an assignment. Depending how you look at it the statements in question are either equations or just definitions. In openscad X = Y + 1 is a definition of X with a scope. You cannot define X to be two things at once any more than you can define anything else in life to be two conflicting things at once. If you see it as an assignment you are going to continue suffering from iterative programmer disease. Think of it as #define Alan
GW
G. Wade Johnson
Tue, Feb 3, 2015 5:21 PM

On Tue, 03 Feb 2015 11:40:48 -0500
Adrian Grajdeanu adriang0@cox.net wrote:

You may beat this into me, but you will not squash most people's
expectation. Hence you will have no peace.

As a long-time programmer, I understand what you are saying. However,
an OpenSCAD file is not a program. It does not execute. I think many of
us agree that "constant" would be a better name than "variable" for
this concept.

Like many have said, the variable concept makes no sense in OpenSCAD,
because the file is not a program executing in time.

Think of it as a description of a physical object. I can't have a
physical sphere with a variable diameter (barring inflatables, and
such). I describe the sphere with a dimension and it does not change.

What OpenSCAD calls variables are really named constants. Since
variables do not exist in the language, there is no "crippling" of them.

Why is there this stubborness to cripple variables? Is there a
technical reason, or is merely adherence to some purist dogma?

The technical reason is that the file does not execute in time. Several
people have pointed this out.

I can understand the tree structure of an openscad 'program'. Not
only can i understand it, but appreciate it enormously. This paradigm
simplifies things and enables caching of geometrical elements.
However programers feel the need for variables (in the classical
way). If at some point you accept this statement, and endeavor to

As I said, decades of programming experience here and I have not felt
limited in my OpenSCAD designs by a lack of variables.

G. Wade

provide variables in a languge, then embrace it all the way and
support variables in a manner free of gotchas or arbitrarily seeming
limitation. 

-------- Original message --------
From: Alan Cox alan@lxorguk.ukuu.org.uk
Date:03/02/2015  11:19  (GMT-05:00)
To: Adrian Grajdeanu adriang0@cox.net
Cc: OpenSCAD general discussion discuss@lists.openscad.org
Subject: Re: [OpenSCAD] A = A + 1;

On Tue, 03 Feb 2015 10:20:53 -0500
Adrian Grajdeanu adriang0@cox.net wrote:

If this were an equation, you'd be right. But it isn't an equation.
It is an assignment.

Depending how you look at it the statements in question are either
equations or just definitions.

In openscad  X = Y + 1 is a definition of X with a scope.

You cannot define X to be two things at once any more than you can
define anything else in life to be two conflicting things at once.

If you see it as an assignment you are going to continue suffering
from iterative programmer disease. Think of it as #define

Alan

--
There will always be things we wish to say in our programs that in all
known languages can only be said poorly.            -- Alan Perlis

On Tue, 03 Feb 2015 11:40:48 -0500 Adrian Grajdeanu <adriang0@cox.net> wrote: > You may beat this into me, but you will not squash most people's > expectation. Hence you will have no peace. As a long-time programmer, I understand what you are saying. However, an OpenSCAD file is not a program. It does not execute. I think many of us agree that "constant" would be a better name than "variable" for this concept. Like many have said, the variable concept makes no sense in OpenSCAD, because the file is not a program executing in time. Think of it as a description of a physical object. I can't have a physical sphere with a variable diameter (barring inflatables, and such). I describe the sphere with a dimension and it does not change. What OpenSCAD calls variables are really named constants. Since variables do not exist in the language, there is no "crippling" of them. > Why is there this stubborness to cripple variables? Is there a > technical reason, or is merely adherence to some purist dogma? The technical reason is that the file does not execute in time. Several people have pointed this out. > I can understand the tree structure of an openscad 'program'. Not > only can i understand it, but appreciate it enormously. This paradigm > simplifies things and enables caching of geometrical elements. > However programers feel the need for variables (in the classical > way). If at some point you accept this statement, and endeavor to As I said, decades of programming experience here and I have not felt limited in my OpenSCAD designs by a lack of variables. G. Wade > provide variables in a languge, then embrace it all the way and > support variables in a manner free of gotchas or arbitrarily seeming > limitation.  > > -------- Original message -------- > From: Alan Cox <alan@lxorguk.ukuu.org.uk> > Date:03/02/2015 11:19 (GMT-05:00) > To: Adrian Grajdeanu <adriang0@cox.net> > Cc: OpenSCAD general discussion <discuss@lists.openscad.org> > Subject: Re: [OpenSCAD] A = A + 1; > > On Tue, 03 Feb 2015 10:20:53 -0500 > Adrian Grajdeanu <adriang0@cox.net> wrote: > > > If this were an equation, you'd be right. But it isn't an equation. > > It is an assignment. > > Depending how you look at it the statements in question are either > equations or just definitions. > > In openscad X = Y + 1 is a definition of X with a scope. > > You cannot define X to be two things at once any more than you can > define anything else in life to be two conflicting things at once. > > If you see it as an assignment you are going to continue suffering > from iterative programmer disease. Think of it as #define > > Alan -- There will always be things we wish to say in our programs that in all known languages can only be said poorly. -- Alan Perlis
JL
Joseph Lenox
Tue, Feb 3, 2015 5:47 PM

Because this is a HDL, not a programming language. The closest cousin I
know to openscad in the hdl world is a limited subset of vhdl or verilog.

Identifiers in loops (which aren't really loops, they are a big expansion
macro) are parameters.

For there to be true variables we would need to have real synthesis - a
separate mode that does run procedurally.

Personally I think every mention of "variable" should be purged from the
official docs and the wiki book. Identifiers in "loops" become parameters
as does modules. Everything else is called a constant.

If people bring their incorrect assumptions after that we can point at the
docs.

On Feb 3, 2015 10:40 AM, "Adrian Grajdeanu" adriang0@cox.net wrote:

You may beat this into me, but you will not squash most people's

expectation. Hence you will have no peace.

Why is there this stubborness to cripple variables? Is there a technical

reason, or is merely adherence to some purist dogma?

I can understand the tree structure of an openscad 'program'. Not only

can i understand it, but appreciate it enormously. This paradigm simplifies
things and enables caching of geometrical elements. However programers feel
the need for variables (in the classical way). If at some point you accept
this statement, and endeavor to provide variables in a languge, then
embrace it all the way and support variables in a manner free of gotchas or
arbitrarily seeming limitation.

-------- Original message --------
From: Alan Cox alan@lxorguk.ukuu.org.uk
Date:03/02/2015 11:19 (GMT-05:00)
To: Adrian Grajdeanu adriang0@cox.net
Cc: OpenSCAD general discussion discuss@lists.openscad.org
Subject: Re: [OpenSCAD] A = A + 1;

On Tue, 03 Feb 2015 10:20:53 -0500
Adrian Grajdeanu adriang0@cox.net wrote:

If this were an equation, you'd be right. But it isn't an equation. It

is an assignment.

Depending how you look at it the statements in question are either
equations or just definitions.

In openscad  X = Y + 1 is a definition of X with a scope.

You cannot define X to be two things at once any more than you can define
anything else in life to be two conflicting things at once.

If you see it as an assignment you are going to continue suffering from
iterative programmer disease. Think of it as #define

Alan


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

Because this is a HDL, not a programming language. The closest cousin I know to openscad in the hdl world is a limited subset of vhdl or verilog. Identifiers in loops (which aren't really loops, they are a big expansion macro) are parameters. For there to be true variables we would need to have real synthesis - a separate mode that does run procedurally. Personally I think every mention of "variable" should be purged from the official docs and the wiki book. Identifiers in "loops" become parameters as does modules. Everything else is called a constant. If people bring their incorrect assumptions after that we can point at the docs. On Feb 3, 2015 10:40 AM, "Adrian Grajdeanu" <adriang0@cox.net> wrote: > > You may beat this into me, but you will not squash most people's expectation. Hence you will have no peace. > > Why is there this stubborness to cripple variables? Is there a technical reason, or is merely adherence to some purist dogma? > > I can understand the tree structure of an openscad 'program'. Not only can i understand it, but appreciate it enormously. This paradigm simplifies things and enables caching of geometrical elements. However programers feel the need for variables (in the classical way). If at some point you accept this statement, and endeavor to provide variables in a languge, then embrace it all the way and support variables in a manner free of gotchas or arbitrarily seeming limitation. > > > -------- Original message -------- > From: Alan Cox <alan@lxorguk.ukuu.org.uk> > Date:03/02/2015 11:19 (GMT-05:00) > To: Adrian Grajdeanu <adriang0@cox.net> > Cc: OpenSCAD general discussion <discuss@lists.openscad.org> > Subject: Re: [OpenSCAD] A = A + 1; > > On Tue, 03 Feb 2015 10:20:53 -0500 > Adrian Grajdeanu <adriang0@cox.net> wrote: > > > If this were an equation, you'd be right. But it isn't an equation. It is an assignment. > > Depending how you look at it the statements in question are either > equations or just definitions. > > In openscad X = Y + 1 is a definition of X with a scope. > > You cannot define X to be two things at once any more than you can define > anything else in life to be two conflicting things at once. > > If you see it as an assignment you are going to continue suffering from > iterative programmer disease. Think of it as #define > > Alan > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
AC
Alan Cox
Tue, Feb 3, 2015 6:57 PM

On Tue, 03 Feb 2015 11:40:48 -0500
Adrian Grajdeanu adriang0@cox.net wrote:

You may beat this into me, but you will not squash most people's expectation. Hence you will have no peace.

Why is there this stubborness to cripple variables? Is there a technical reason, or is merely adherence to some purist dogma?

Technically it allows parallelism and a lot of optimisations because the
functions are all without side effects. Also because it's not a
programming language as such but a mathematical description of an object.

I can understand the tree structure of an openscad 'program'. Not only can i understand it, but appreciate it enormously. This paradigm simplifies things and enables caching of geometrical elements. However programers feel the need for variables (in the classical way).

That's why I called it 'iterative programmers disease'.

It's a peculiar worldview problem of programmers, and one that gets them
into a lot of trouble with parallelism, trying to do electronics or
write VHDL.

Programmers can use the python bindings and all the other ways of
interacting with OpenSCAD. Everyone on the other hand (including those
with a normal world view) can use OpenSCAD. Given the number of people
who 'get' openscad and its modelling who are not programmers I'd really
hate to see OpenSCAD lose that property.

The biggest problem I think is that the syntax and documentation of
OpenSCAD make it look like a variable to a programmer. It's very
misleading. Some of the other systems of similar nature do at least make
the difference explicit, or  use constructs that make it more clear what
is going on  (eg with x = [ 1, 2, 3, 4, 5] { blah } )

I'm not immune to it either - several of my tools write OpenSCAD files -
it's an output format for a program in C that computes models of model
railway coaches from a mix of inputs and an inbuilt understanding of how
they are assembled.

Alan

On Tue, 03 Feb 2015 11:40:48 -0500 Adrian Grajdeanu <adriang0@cox.net> wrote: > You may beat this into me, but you will not squash most people's expectation. Hence you will have no peace. > > Why is there this stubborness to cripple variables? Is there a technical reason, or is merely adherence to some purist dogma? Technically it allows parallelism and a lot of optimisations because the functions are all without side effects. Also because it's not a programming language as such but a mathematical description of an object. > I can understand the tree structure of an openscad 'program'. Not only can i understand it, but appreciate it enormously. This paradigm simplifies things and enables caching of geometrical elements. However programers feel the need for variables (in the classical way). That's why I called it 'iterative programmers disease'. It's a peculiar worldview problem of programmers, and one that gets them into a lot of trouble with parallelism, trying to do electronics or write VHDL. Programmers can use the python bindings and all the other ways of interacting with OpenSCAD. Everyone on the other hand (including those with a normal world view) can use OpenSCAD. Given the number of people who 'get' openscad and its modelling who are not programmers I'd really hate to see OpenSCAD lose that property. The biggest problem I think is that the syntax and documentation of OpenSCAD make it look like a variable to a programmer. It's very misleading. Some of the other systems of similar nature do at least make the difference explicit, or use constructs that make it more clear what is going on (eg with x = [ 1, 2, 3, 4, 5] { blah } ) I'm not immune to it either - several of my tools write OpenSCAD files - it's an output format for a program in C that computes models of model railway coaches from a mix of inputs and an inbuilt understanding of how they are assembled. Alan