J
jon
Tue, Aug 30, 2016 8:31 PM
While "variable" may have a long history in math and logic, we are
dealing with a programming language here, and the term "variable" has a
common meaning that is, unfortunately, different than what is intended
in OpenSCAD. I think calling those beasts "named constants" is the
closest we will come, and it will be much less confusing (to a
programmer) than "variable". We need to document for the intended audience.
IMHO, of course. Goes without saying
Jon
On 8/30/2016 4:14 PM, doug moen wrote:
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
mailto: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.
While "variable" may have a long history in math and logic, we are
dealing with a programming language here, and the term "variable" has a
common meaning that is, unfortunately, different than what is intended
in OpenSCAD. I think calling those beasts "named constants" is the
closest we will come, and it will be much less confusing (to a
programmer) than "variable". We need to document for the intended audience.
IMHO, of course. Goes without saying
Jon
On 8/30/2016 4:14 PM, doug moen wrote:
> 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
> <mailto: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.
>
R
Ronaldo
Tue, Aug 30, 2016 10:00 PM
On Tue, Aug 30, 2016, 16:28 — jdawgaz wrote:
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.
Any assignment that changes an existing value (e.g. x := x + 1) is
disallowed in purely functional languages.[4] In functional programming,
assignment is discouraged in favor of single assignment, also called
initialization. Single assignment is an example of name binding and
differs from assignment as described in this article in that it can only
be done once, usually when the variable is created; no subsequent
reassignment is allowed.
Named constant seems fair to me.
On Tue, Aug 30, 2016, 16:28 — jdawgaz wrote:
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.
In none programming language I know, function and procedure arguments are
called variables. They are a way to reference values. In OpenSCAD for
statements, the identifier that index the iteration is just a named
reference of a value in a list or range inside a specific scope. It is not a
true variable.
--
View this message in context: http://forum.openscad.org/What-to-call-variables-tp18260p18271.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
> On Tue, Aug 30, 2016, 16:28 — jdawgaz wrote:
> 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.
I am far from being an expert in programming languages and I don't want to
start a controversy.
According to wikipedia
<https://en.wikipedia.org/wiki/Assignment_(computer_science)#Single_assignment>
:
> Any assignment that changes an existing value (e.g. x := x + 1) is
> disallowed in purely functional languages.[4] In functional programming,
> assignment is discouraged in favor of single assignment, also called
> initialization. Single assignment is an example of name binding and
> differs from assignment as described in this article in that it can only
> be done once, usually when the variable is created; no subsequent
> reassignment is allowed.
Named constant seems fair to me.
> On Tue, Aug 30, 2016, 16:28 — jdawgaz wrote:
> 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.
In none programming language I know, function and procedure arguments are
called variables. They are a way to reference values. In OpenSCAD for
statements, the identifier that index the iteration is just a named
reference of a value in a list or range inside a specific scope. It is not a
true variable.
--
View this message in context: http://forum.openscad.org/What-to-call-variables-tp18260p18271.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
M
MichaelAtOz
Wed, Aug 31, 2016 5:14 AM
True, but they are also more
for (a =[3:5])echo(a); // 3 4 5
Remember this is not an iterative language, the for() does not loop in the
programmatic sense, it builds a tree of objects one branch for each
representation of the loop 'identifier', inside each of which the 'variable'
is a specific and seperate instantiation of that 'identifier'.
So:
for (i=[0:3])
translate([i*10,0,0])
cube(i+1);
Produces:
group() {
group() {
multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
cube(size = [1, 1, 1], center = false);
}
multmatrix([[1, 0, 0, 10], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
cube(size = [2, 2, 2], center = false);
}
multmatrix([[1, 0, 0, 20], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
cube(size = [3, 3, 3], center = false);
}
multmatrix([[1, 0, 0, 30], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
cube(size = [4, 4, 4], center = false);
}
}
}
All instances of the for() exist at the same time, they do not iterate
sequentially.
In imperative programming languages 'variable' by definition can vary, thus
they also have 'constants' which can't. {corollary to Murphy's law: variable
won't & constants aren't}
{wikipedia} "In pure functional and logic languages,variables{*1} are bound
to expressions and keep a single value during their entire lifetime due to
the requirements of referential transparency", but it is common to use the
term 'variable' even tho they don't, and they don't generally have the
concept of 'constants'.
So technically, as a declarative language, 'variable' as a term IS
appropriate, but for imperative programmers 'constant' would be better.
{*1} I'd argue that wikipedia definition is wrong, it should be "
'identifiers' are bound to ..."
So how about, in the manual, we use the term 'identifier', and expunge
'variable'? Also any reference to 'assignment' changes to 'binding'.
?
Admin - PM me if you need anything, or if I've done something stupid...
Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.
The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!
View this message in context: http://forum.openscad.org/What-to-call-variables-tp18260p18275.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
L Boyd wrote
> True, but they are also more
>
> for (a =[3:5])echo(a); // 3 4 5
Remember this is not an iterative language, the for() does not loop in the
programmatic sense, it builds a tree of objects one branch for each
representation of the loop 'identifier', inside each of which the 'variable'
is a specific and seperate instantiation of that 'identifier'.
So:
for (i=[0:3])
translate([i*10,0,0])
cube(i+1);
Produces:
group() {
group() {
multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
cube(size = [1, 1, 1], center = false);
}
multmatrix([[1, 0, 0, 10], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
cube(size = [2, 2, 2], center = false);
}
multmatrix([[1, 0, 0, 20], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
cube(size = [3, 3, 3], center = false);
}
multmatrix([[1, 0, 0, 30], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
cube(size = [4, 4, 4], center = false);
}
}
}
All instances of the for() exist at the same time, they do not iterate
sequentially.
In imperative programming languages 'variable' by definition can vary, thus
they also have 'constants' which can't. {corollary to Murphy's law: variable
won't & constants aren't}
{wikipedia} "In pure functional and logic languages,variables{*1} are bound
to expressions and keep a single value during their entire lifetime due to
the requirements of referential transparency", but it is common to use the
term 'variable' even tho they don't, and they don't generally have the
concept of 'constants'.
So technically, as a declarative language, 'variable' as a term IS
appropriate, but for imperative programmers 'constant' would be better.
{*1} I'd argue that wikipedia definition is wrong, it should be "
'identifiers' are bound to ..."
So how about, in the manual, we use the term 'identifier', and expunge
'variable'? Also any reference to 'assignment' changes to 'binding'.
?
-----
Admin - PM me if you need anything, or if I've done something stupid...
Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.
The TPP is no simple “trade agreement.” Fight it! http://www.ourfairdeal.org/ time is running out!
--
View this message in context: http://forum.openscad.org/What-to-call-variables-tp18260p18275.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
LB
L Boyd
Wed, Aug 31, 2016 1:23 PM
I know how OpenSCAD variables work and don't personally have a problem with
the name.
Having said that, imperative programmers, new to OpenSCAD, stumble on this.
They assume the terms variable and constant have the meaning they are use
to.
In their view, our variables are neither, but fall somewhere in between.
Perhaps semiconstant?
Larry
View this message in context: http://forum.openscad.org/What-to-call-variables-tp18260p18281.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
I know how OpenSCAD variables work and don't personally have a problem with
the name.
Having said that, imperative programmers, new to OpenSCAD, stumble on this.
They assume the terms variable and constant have the meaning they are use
to.
In their view, our variables are neither, but fall somewhere in between.
Perhaps semiconstant?
-----
Larry
--
View this message in context: http://forum.openscad.org/What-to-call-variables-tp18260p18281.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
DS
Dan Shriver
Wed, Aug 31, 2016 1:27 PM
What's wrong with "scoped constant" . Only uses two words and it describes
the behavior. Variables is definitely extremely misleading.
On Aug 31, 2016 9:23 AM, "L Boyd" lboyd@frontiernet.net wrote:
I know how OpenSCAD variables work and don't personally have a problem with
the name.
Having said that, imperative programmers, new to OpenSCAD, stumble on this.
They assume the terms variable and constant have the meaning they are use
to.
In their view, our variables are neither, but fall somewhere in between.
Perhaps semiconstant?
Larry
View this message in context: http://forum.openscad.org/
What-to-call-variables-tp18260p18281.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
What's wrong with "scoped constant" . Only uses two words and it describes
the behavior. Variables is definitely extremely misleading.
On Aug 31, 2016 9:23 AM, "L Boyd" <lboyd@frontiernet.net> wrote:
> I know how OpenSCAD variables work and don't personally have a problem with
> the name.
>
> Having said that, imperative programmers, new to OpenSCAD, stumble on this.
> They assume the terms variable and constant have the meaning they are use
> to.
>
> In their view, our variables are neither, but fall somewhere in between.
>
> Perhaps semiconstant?
>
>
>
> -----
> Larry
> --
> View this message in context: http://forum.openscad.org/
> What-to-call-variables-tp18260p18281.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
>
LB
L Boyd
Wed, Aug 31, 2016 1:35 PM
Interesting possibility.
MichaelAtOz wrote
So how about, in the manual, we use the term 'identifier', and expunge
'variable'? Also any reference to 'assignment' changes to 'binding'.?
Interesting possibility.
MichaelAtOz wrote
> So how about, in the manual, we use the term 'identifier', and expunge
> 'variable'? Also any reference to 'assignment' changes to 'binding'.?
-----
Larry
--
View this message in context: http://forum.openscad.org/What-to-call-variables-tp18260p18283.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
LV
Lucas Vinicius Hartmann
Wed, Aug 31, 2016 2:19 PM
Why not call them symbols, as in symbolic math?
Variables in programming language have an implied time dependency. X=X+1 is
valid because it refers to two different X symbols, old and new.
Anyway, for loop iterative math can be replaced with recursive functions,
just like the classical factorial function. Tested something like this
yesterday, and it seemed to work. While this is a little harder to write, i
am OK with the behavior.
F(n) = n<1? 1 : n*F(n-1)
For loops in rendering work as they should.
Em 31 de ago de 2016 10:28, "Dan Shriver" tabbydan@gmail.com escreveu:
What's wrong with "scoped constant" . Only uses two words and it describes
the behavior. Variables is definitely extremely misleading.
On Aug 31, 2016 9:23 AM, "L Boyd" lboyd@frontiernet.net wrote:
Why not call them symbols, as in symbolic math?
Variables in programming language have an implied time dependency. X=X+1 is
valid because it refers to two different X symbols, old and new.
Anyway, for loop iterative math can be replaced with recursive functions,
just like the classical factorial function. Tested something like this
yesterday, and it seemed to work. While this is a little harder to write, i
am OK with the behavior.
F(n) = n<1? 1 : n*F(n-1)
For loops in rendering work as they should.
Em 31 de ago de 2016 10:28, "Dan Shriver" <tabbydan@gmail.com> escreveu:
> What's wrong with "scoped constant" . Only uses two words and it describes
> the behavior. Variables is definitely extremely misleading.
> On Aug 31, 2016 9:23 AM, "L Boyd" <lboyd@frontiernet.net> wrote:
>
>> I know how OpenSCAD variables work and don't personally have a problem
>> with
>> the name.
>>
>> Having said that, imperative programmers, new to OpenSCAD, stumble on
>> this.
>> They assume the terms variable and constant have the meaning they are use
>> to.
>>
>> In their view, our variables are neither, but fall somewhere in between.
>>
>> Perhaps semiconstant?
>>
>>
>>
>> -----
>> Larry
>> --
>> View this message in context: http://forum.openscad.org/What
>> -to-call-variables-tp18260p18281.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
>
>
LB
L Boyd
Wed, Aug 31, 2016 5:48 PM
What's wrong with "scoped constant" . Only uses two words and it describes
the behavior. Variables is definitely extremely misleading.
Excellent idea. It correctly describes their behavior, while flagging the
difference from constants in many imperative programming languages.
That makes 2 votes, how about anyone else?
Larry
View this message in context: http://forum.openscad.org/What-to-call-variables-tp18260p18285.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
DanS wrote
> What's wrong with "scoped constant" . Only uses two words and it describes
> the behavior. Variables is definitely extremely misleading.
>
Excellent idea. It correctly describes their behavior, while flagging the
difference from constants in many imperative programming languages.
That makes 2 votes, how about anyone else?
-----
Larry
--
View this message in context: http://forum.openscad.org/What-to-call-variables-tp18260p18285.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
LB
L Boyd
Wed, Aug 31, 2016 5:53 PM
Good description, better than what I wrote in the manual.
MichaelAtOz wrote
Remember this is not an iterative language, the for() does not loop in the
programmatic sense, it builds a tree of objects one branch for each
representation of the loop 'identifier', inside each of which the
'variable' is a specific and seperate instantiation of that 'identifier'.
So:
for (i=[0:3])
translate([i*10,0,0])
cube(i+1);
Produces:
group() {
group() {
multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
cube(size = [1, 1, 1], center = false);
}
multmatrix([[1, 0, 0, 10], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
cube(size = [2, 2, 2], center = false);
}
multmatrix([[1, 0, 0, 20], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
cube(size = [3, 3, 3], center = false);
}
multmatrix([[1, 0, 0, 30], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
cube(size = [4, 4, 4], center = false);
}
}
}
All instances of the for() exist at the same time, they do not iterate
sequentially.
Good description, better than what I wrote in the manual.
MichaelAtOz wrote
> Remember this is not an iterative language, the for() does not loop in the
> programmatic sense, it builds a tree of objects one branch for each
> representation of the loop 'identifier', inside each of which the
> 'variable' is a specific and seperate instantiation of that 'identifier'.
>
> So:
>
> for (i=[0:3])
> translate([i*10,0,0])
> cube(i+1);
>
> Produces:
>
> group() {
> group() {
> multmatrix([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
> cube(size = [1, 1, 1], center = false);
> }
> multmatrix([[1, 0, 0, 10], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
> cube(size = [2, 2, 2], center = false);
> }
> multmatrix([[1, 0, 0, 20], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
> cube(size = [3, 3, 3], center = false);
> }
> multmatrix([[1, 0, 0, 30], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]) {
> cube(size = [4, 4, 4], center = false);
> }
> }
> }
>
> All instances of the for() exist at the same time, they do not iterate
> sequentially.
-----
Larry
--
View this message in context: http://forum.openscad.org/What-to-call-variables-tp18260p18286.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
R
runsun
Fri, Sep 2, 2016 6:09 PM
Why not call them symbols, as in symbolic math?
+1
$ Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), synwrite ( 2 ); $ tips: hash ( 2 ), matrix ( 2 , 3 ), sweep ( 2 ), var ( 2 ), lerp , animation ( gif , prodVid , animlib ), precision ( 2 ), xl-control , type , rounded polygon , chfont , tailRecur ( 2, 3 ), isosphere ( 2 ), area , vol/center , RGB , CurvedImg ; $ Apps: rollApp , blockscad , openjscad , on AWS ( pdf )
View this message in context: http://forum.openscad.org/What-to-call-variables-tp18260p18306.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
lhartmann wrote
> Why not call them symbols, as in symbolic math?
+1
-----
$ Runsun Pan, PhD $ libs: doctest , faces ( git ), offline doc ( git ), runscad.py ( 2 , git ), synwrite ( 2 ); $ tips: hash ( 2 ), matrix ( 2 , 3 ), sweep ( 2 ), var ( 2 ), lerp , animation ( gif , prodVid , animlib ), precision ( 2 ), xl-control , type , rounded polygon , chfont , tailRecur ( 2, 3 ), isosphere ( 2 ), area , vol/center , RGB , CurvedImg ; $ Apps: rollApp , blockscad , openjscad , on AWS ( pdf )
--
View this message in context: http://forum.openscad.org/What-to-call-variables-tp18260p18306.html
Sent from the OpenSCAD mailing list archive at Nabble.com.