discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

What to call "variables"

LB
L Boyd
Tue, Aug 30, 2016 12:09 PM

I see multiple question from those new to OpenSCAD about what we call
variables. They are confused because they are different from the variables
used in many programming languages. They don't understand why the can't do
a=a+1.

They are not really constants either, because they can be overridden locally
within inner scopes.

Perhaps we should use an unfamiliar name, so that they have to read the
definition for how to use them.

I don't have any suggestions, but we need to discuss this before changing
the manual.


Larry

View this message in context: http://forum.openscad.org/What-to-call-variables-tp18260.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

I see multiple question from those new to OpenSCAD about what we call variables. They are confused because they are different from the variables used in many programming languages. They don't understand why the can't do a=a+1. They are not really constants either, because they can be overridden locally within inner scopes. Perhaps we should use an unfamiliar name, so that they have to read the definition for how to use them. I don't have any suggestions, but we need to discuss this before changing the manual. ----- Larry -- View this message in context: http://forum.openscad.org/What-to-call-variables-tp18260.html Sent from the OpenSCAD mailing list archive at Nabble.com.
AC
Alan Cox
Tue, Aug 30, 2016 12:31 PM

On Tue, 30 Aug 2016 05:09:39 -0700 (MST)
L Boyd lboyd@frontiernet.net wrote:

I see multiple question from those new to OpenSCAD about what we call
variables. They are confused because they are different from the variables
used in many programming languages. They don't understand why the can't do
a=a+1.

They are not really constants either, because they can be overridden locally
within inner scopes.

Perhaps we should use an unfamiliar name, so that they have to read the
definition for how to use them.

I don't have any suggestions, but we need to discuss this before changing
the manual.

They are constants but they are scoped. No different to C

const x = 1

static void foo(void)
{
const x = 4;

blah;

}

Or perhaps think of them as functions or macros, they are really just an
expansion.

Alan

On Tue, 30 Aug 2016 05:09:39 -0700 (MST) L Boyd <lboyd@frontiernet.net> wrote: > I see multiple question from those new to OpenSCAD about what we call > variables. They are confused because they are different from the variables > used in many programming languages. They don't understand why the can't do > a=a+1. > > They are not really constants either, because they can be overridden locally > within inner scopes. > > Perhaps we should use an unfamiliar name, so that they have to read the > definition for how to use them. > > I don't have any suggestions, but we need to discuss this before changing > the manual. They are constants but they are scoped. No different to C const x = 1 static void foo(void) { const x = 4; blah; } Or perhaps think of them as functions or macros, they are really just an expansion. Alan
LB
L Boyd
Tue, Aug 30, 2016 3:31 PM

Alan Cox wrote

On Tue, 30 Aug 2016 05:09:39 -0700 (MST)
L Boyd <

lboyd@

> wrote:

I see multiple question from those new to OpenSCAD about what we call
variables. They are confused because they are different from the
variables
used in many programming languages. They don't understand why the can't
do
a=a+1.

They are not really constants either, because they can be overridden
locally
within inner scopes.

Perhaps we should use an unfamiliar name, so that they have to read the
definition for how to use them.

I don't have any suggestions, but we need to discuss this before changing
the manual.

They are constants but they are scoped. No different to C

const x = 1

static void foo(void)
{
const x = 4;

blah;

}

Or perhaps think of them as functions or macros, they are really just an
expansion.

Alan

True, but they are also more

for (a =[3:5])echo(a);    // 3 4 5

The question is what word should be used in the manual.


OpenSCAD mailing list

Discuss@.openscad


Larry

View this message in context: http://forum.openscad.org/What-to-call-variables-tp18260p18262.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

Alan Cox wrote > On Tue, 30 Aug 2016 05:09:39 -0700 (MST) > L Boyd &lt; > lboyd@ > &gt; wrote: > >> I see multiple question from those new to OpenSCAD about what we call >> variables. They are confused because they are different from the >> variables >> used in many programming languages. They don't understand why the can't >> do >> a=a+1. >> >> They are not really constants either, because they can be overridden >> locally >> within inner scopes. >> >> Perhaps we should use an unfamiliar name, so that they have to read the >> definition for how to use them. >> >> I don't have any suggestions, but we need to discuss this before changing >> the manual. > > They are constants but they are scoped. No different to C > > const x = 1 > > static void foo(void) > { > const x = 4; > > blah; > } > > > > Or perhaps think of them as functions or macros, they are really just an > expansion. > > Alan > > True, but they are also more > > for (a =[3:5])echo(a); // 3 4 5 > > The question is what word should be used in the manual. > _______________________________________________ > OpenSCAD mailing list > Discuss@.openscad > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org ----- Larry -- View this message in context: http://forum.openscad.org/What-to-call-variables-tp18260p18262.html Sent from the OpenSCAD mailing list archive at Nabble.com.
FV
Frank van der Hulst
Tue, Aug 30, 2016 6:18 PM

Why NOT make them behave like variables in other languages and allow a = a

  • 1 ?

On Wed, Aug 31, 2016 at 12:09 AM, L Boyd lboyd@frontiernet.net wrote:

I see multiple question from those new to OpenSCAD about what we call
variables. They are confused because they are different from the variables
used in many programming languages. They don't understand why the can't do
a=a+1.

They are not really constants either, because they can be overridden
locally
within inner scopes.

Perhaps we should use an unfamiliar name, so that they have to read the
definition for how to use them.

I don't have any suggestions, but we need to discuss this before changing
the manual.


Larry

View this message in context: http://forum.openscad.org/
What-to-call-variables-tp18260.html
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

Why NOT make them behave like variables in other languages and allow a = a + 1 ? On Wed, Aug 31, 2016 at 12:09 AM, L Boyd <lboyd@frontiernet.net> wrote: > I see multiple question from those new to OpenSCAD about what we call > variables. They are confused because they are different from the variables > used in many programming languages. They don't understand why the can't do > a=a+1. > > They are not really constants either, because they can be overridden > locally > within inner scopes. > > Perhaps we should use an unfamiliar name, so that they have to read the > definition for how to use them. > > I don't have any suggestions, but we need to discuss this before changing > the manual. > > > > ----- > Larry > -- > View this message in context: http://forum.openscad.org/ > What-to-call-variables-tp18260.html > 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 >
DS
Dan Shriver
Tue, Aug 30, 2016 6:22 PM

"Constants within a scope"?

That would describe them.
On Aug 30, 2016 8:10 AM, "L Boyd" lboyd@frontiernet.net wrote:

I see multiple question from those new to OpenSCAD about what we call
variables. They are confused because they are different from the variables
used in many programming languages. They don't understand why the can't do
a=a+1.

They are not really constants either, because they can be overridden
locally
within inner scopes.

Perhaps we should use an unfamiliar name, so that they have to read the
definition for how to use them.

I don't have any suggestions, but we need to discuss this before changing
the manual.


Larry

View this message in context: http://forum.openscad.org/
What-to-call-variables-tp18260.html
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

"Constants within a scope"? That would describe them. On Aug 30, 2016 8:10 AM, "L Boyd" <lboyd@frontiernet.net> wrote: > I see multiple question from those new to OpenSCAD about what we call > variables. They are confused because they are different from the variables > used in many programming languages. They don't understand why the can't do > a=a+1. > > They are not really constants either, because they can be overridden > locally > within inner scopes. > > Perhaps we should use an unfamiliar name, so that they have to read the > definition for how to use them. > > I don't have any suggestions, but we need to discuss this before changing > the manual. > > > > ----- > Larry > -- > View this message in context: http://forum.openscad.org/ > What-to-call-variables-tp18260.html > 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 >
MD
Michele Denber
Tue, Aug 30, 2016 6:23 PM

On 08-30-2016 2:18 PM, Frank van der Hulst wrote:

Why NOT make them behave like variables in other languages and allow a
= a + 1 ?

I second that.

         - Michele
On 08-30-2016 2:18 PM, Frank van der Hulst wrote: > Why NOT make them behave like variables in other languages and allow a > = a + 1 ? I second that. - Michele
R
Ronaldo
Tue, Aug 30, 2016 7:06 PM

Why NOT make them behave like variables in other languages and allow a = a

  • 1 ?

Because there is no assignment in OpenSCAD. When you write:

  a = 10;

in OpenSCAD, this is a definition, like in math, not an assignment.
Assignments are the cause of many misleading code and many languages
restrict their effects. Functional programming languages have no variables
neither assignments. We don't need them.

--
View this message in context: http://forum.openscad.org/What-to-call-variables-tp18260p18266.html
Sent from the OpenSCAD mailing list archive at Nabble.com.

> Why NOT make them behave like variables in other languages and allow a = a > + 1 ? Because there is no assignment in OpenSCAD. When you write: > a = 10; in OpenSCAD, this is a definition, like in math, not an assignment. Assignments are the cause of many misleading code and many languages restrict their effects. Functional programming languages have no variables neither assignments. We don't need them. -- View this message in context: http://forum.openscad.org/What-to-call-variables-tp18260p18266.html Sent from the OpenSCAD mailing list archive at Nabble.com.
JD
Jerry Davis
Tue, Aug 30, 2016 7:28 PM

On Tue, Aug 30, 2016 at 12:06 PM, Ronaldo rcmpersiano@gmail.com wrote:

Why NOT make them behave like variables in other languages and allow a =

a

  • 1 ?

Because there is no assignment in OpenSCAD. When you write:

  a = 10;

in OpenSCAD, this is a definition, like in math, not an assignment.
Assignments are the cause of many misleading code and many languages
restrict their effects. Functional programming languages have no variables
neither assignments. We don't need them.

excuse me? There are assignments in Functional programming languages.
And yes, we really could use them. Functional programming languages in
simple terms make a
difference between where the variable (in memory) is, and the value that
points
to it.

So, why have true variables only in certain circumstances (like for loops,
arguments in module calls, functions, etc), and not in others.
If a value could be assigned to a "variable" at any time, then the
controversy would just go away.

Jerry

--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Openscad developer

The most exciting phrase to hear in science - the one that heralds new
discoveries - is not "Eureka!" but "That's funny...".
- Isaac. Asimov

On Tue, Aug 30, 2016 at 12:06 PM, Ronaldo <rcmpersiano@gmail.com> wrote: > > Why NOT make them behave like variables in other languages and allow a = > a > > + 1 ? > > Because there is no assignment in OpenSCAD. When you write: > > > a = 10; > > in OpenSCAD, this is a definition, like in math, not an assignment. > Assignments are the cause of many misleading code and many languages > restrict their effects. Functional programming languages have no variables > neither assignments. We don't need them. excuse me? There are assignments in Functional programming languages. And yes, we really could use them. Functional programming languages in simple terms make a difference between where the variable (in memory) is, and the value that points to it. So, why have true variables only in certain circumstances (like for loops, arguments in module calls, functions, etc), and not in others. If a value could be assigned to a "variable" at any time, then the controversy would just go away. Jerry -- Extra Ham Operator: K7AZJ Registered Linux User: 275424 Raspberry Pi and Openscad developer *The most exciting phrase to hear in science - the one that heralds new discoveries - is not "Eureka!" but "That's funny...".*- Isaac. Asimov
DM
doug moen
Tue, Aug 30, 2016 8:14 PM

OpenSCAD is a mathematical notation for describing geometric shapes. It's
not a general purpose programming language.

OpenSCAD's use of the term "variable" is consistent with the meaning of
"variable" in mathematics, and in pure functional programming languages.
The word "variable" in mathematics and formal logic has a distinguished
history going back hundreds of years, and I don't think there's a problem
using that word with its traditional meaning.

The terminology I'd get rid of instead is "assignment statement". I
consider x = 1; to be a "definition" of x. It's a mathematical equation
that defines the meaning of x within its scope. The underlying
mathematical reason that x = x + 1; is invalid is because this is not a
valid equation defining x. There is no number x that is equal to itself
plus 1.

On 30 August 2016 at 08:09, L Boyd lboyd@frontiernet.net wrote:

I see multiple question from those new to OpenSCAD about what we call
variables. They are confused because they are different from the variables
used in many programming languages. They don't understand why the can't do
a=a+1.

They are not really constants either, because they can be overridden
locally
within inner scopes.

Perhaps we should use an unfamiliar name, so that they have to read the
definition for how to use them.

I don't have any suggestions, but we need to discuss this before changing
the manual.


Larry

View this message in context: http://forum.openscad.org/
What-to-call-variables-tp18260.html
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 is a mathematical notation for describing geometric shapes. It's not a general purpose programming language. OpenSCAD's use of the term "variable" is consistent with the meaning of "variable" in mathematics, and in pure functional programming languages. The word "variable" in mathematics and formal logic has a distinguished history going back hundreds of years, and I don't think there's a problem using that word with its traditional meaning. The terminology I'd get rid of instead is "assignment statement". I consider `x = 1;` to be a "definition" of `x`. It's a mathematical equation that defines the meaning of `x` within its scope. The underlying mathematical reason that `x = x + 1;` is invalid is because this is not a valid equation defining `x`. There is no number `x` that is equal to itself plus 1. On 30 August 2016 at 08:09, L Boyd <lboyd@frontiernet.net> wrote: > I see multiple question from those new to OpenSCAD about what we call > variables. They are confused because they are different from the variables > used in many programming languages. They don't understand why the can't do > a=a+1. > > They are not really constants either, because they can be overridden > locally > within inner scopes. > > Perhaps we should use an unfamiliar name, so that they have to read the > definition for how to use them. > > I don't have any suggestions, but we need to discuss this before changing > the manual. > > > > ----- > Larry > -- > View this message in context: http://forum.openscad.org/ > What-to-call-variables-tp18260.html > 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 > > >
DW
Don Wooton
Tue, Aug 30, 2016 8:31 PM

How about having a warning message something like
WARNING Value reassigned: line 6
and a preferences to turn this one warning off.  If the warning
is on by default, it may cause the new user to notice that this
procedure is not expected and to look in the manual.

- Don

On Aug 30, doug moen propounded certain bytes, to wit:

Subject: Re: [OpenSCAD] What to call "variables"

OpenSCAD is a mathematical notation for describing geometric shapes. It's
not a general purpose programming language.

OpenSCAD's use of the term "variable" is consistent with the meaning of
"variable" in mathematics, and in pure functional programming languages.
The word "variable" in mathematics and formal logic has a distinguished
history going back hundreds of years, and I don't think there's a problem
using that word with its traditional meaning.

The terminology I'd get rid of instead is "assignment statement". I
consider x = 1; to be a "definition" of x. It's a mathematical equation
that defines the meaning of x within its scope. The underlying
mathematical reason that x = x + 1; is invalid is because this is not a
valid equation defining x. There is no number x that is equal to itself
plus 1.

On 30 August 2016 at 08:09, L Boyd lboyd@frontiernet.net wrote:

I see multiple question from those new to OpenSCAD about what we call
variables. They are confused because they are different from the variables
used in many programming languages. They don't understand why the can't do
a=a+1.

They are not really constants either, because they can be overridden
locally
within inner scopes.

Perhaps we should use an unfamiliar name, so that they have to read the
definition for how to use them.

I don't have any suggestions, but we need to discuss this before changing
the manual.


Larry

View this message in context: http://forum.openscad.org/
What-to-call-variables-tp18260.html
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

-- End of excerpt from doug moen'

How about having a warning message something like WARNING Value reassigned: line 6 and a preferences to turn this one warning off. If the warning is on by default, it may cause the new user to notice that this procedure is not expected and to look in the manual. - Don On Aug 30, doug moen propounded certain bytes, to wit: > Subject: Re: [OpenSCAD] What to call "variables" > > OpenSCAD is a mathematical notation for describing geometric shapes. It's > not a general purpose programming language. > > OpenSCAD's use of the term "variable" is consistent with the meaning of > "variable" in mathematics, and in pure functional programming languages. > The word "variable" in mathematics and formal logic has a distinguished > history going back hundreds of years, and I don't think there's a problem > using that word with its traditional meaning. > > The terminology I'd get rid of instead is "assignment statement". I > consider `x = 1;` to be a "definition" of `x`. It's a mathematical equation > that defines the meaning of `x` within its scope. The underlying > mathematical reason that `x = x + 1;` is invalid is because this is not a > valid equation defining `x`. There is no number `x` that is equal to itself > plus 1. > > On 30 August 2016 at 08:09, L Boyd <lboyd@frontiernet.net> wrote: > > > I see multiple question from those new to OpenSCAD about what we call > > variables. They are confused because they are different from the variables > > used in many programming languages. They don't understand why the can't do > > a=a+1. > > > > They are not really constants either, because they can be overridden > > locally > > within inner scopes. > > > > Perhaps we should use an unfamiliar name, so that they have to read the > > definition for how to use them. > > > > I don't have any suggestions, but we need to discuss this before changing > > the manual. > > > > > > > > ----- > > Larry > > -- > > View this message in context: http://forum.openscad.org/ > > What-to-call-variables-tp18260.html > > 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 >-- End of excerpt from doug moen'