Variable bug?

classic Classic list List threaded Threaded
61 messages Options
1234
Reply | Threaded
Open this post in threaded view
|

Variable bug?

Brent Burton
Hi guys,
I'm new to OpenSCAD, but learning it quickly.

I stumbled upon an error in one of my scripts, and I boiled it down to this situation. The workaround is to simplify scripts to avoid this, but there may be situations, like in an if-statement, that this would occur.

/* variable bug.
* Mac OS X, OpenSCAD 2011.12
*/
C = 250;   // Comment this line to hide bug
B = 100;
C = B + 25; // Error: unknown var 'B'

echo("B: ",B);
echo("C Size: ",C);

cube([1,1,1]);

Reply | Threaded
Open this post in threaded view
|

Re: Variable bug?

Triffid Hunter
openscad "variables" are immutable. you can only set them once. The closest we have to mutable variables are loop variables.

If you're familiar with C, think of them as defines rather than actual variables.

On Wed, Nov 28, 2012 at 2:03 PM, Brent Burton <[hidden email]> wrote:
Hi guys,
I'm new to OpenSCAD, but learning it quickly.

I stumbled upon an error in one of my scripts, and I boiled it down to this situation. The workaround is to simplify scripts to avoid this, but there may be situations, like in an if-statement, that this would occur.

/* variable bug.
* Mac OS X, OpenSCAD 2011.12
*/
C = 250;   // Comment this line to hide bug
B = 100;
C = B + 25; // Error: unknown var 'B'

echo("B: ",B);
echo("C Size: ",C);

cube([1,1,1]);


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566

Reply | Threaded
Open this post in threaded view
|

Re: Variable bug?

Taylor Alexander

Speaking of that... Why? It seems like such a major omission.

On Nov 27, 2012 9:30 PM, "Triffid Hunter" <[hidden email]> wrote:
openscad "variables" are immutable. you can only set them once. The closest we have to mutable variables are loop variables.

If you're familiar with C, think of them as defines rather than actual variables.

On Wed, Nov 28, 2012 at 2:03 PM, Brent Burton <[hidden email]> wrote:
Hi guys,
I'm new to OpenSCAD, but learning it quickly.

I stumbled upon an error in one of my scripts, and I boiled it down to this situation. The workaround is to simplify scripts to avoid this, but there may be situations, like in an if-statement, that this would occur.

/* variable bug.
* Mac OS X, OpenSCAD 2011.12
*/
C = 250;   // Comment this line to hide bug
B = 100;
C = B + 25; // Error: unknown var 'B'

echo("B: ",B);
echo("C Size: ",C);

cube([1,1,1]);


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566
Reply | Threaded
Open this post in threaded view
|

Re: Variable bug?

nophead
In reply to this post by Triffid Hunter
I think it is a bug because the error message makes no sense:

WARNING: Ignoring unknown variable 'B'.
ECHO: "B: ", 100
ECHO: "C Size: ", undef


This has caught me out a few times and wasted time trying to find the problem in a large multi-file project. Why does B become unknown?


Also:

C = 250; // Comment this line to hide bug
B = 100;
C = 4 + 25; // Error: unknown var 'B'
echo("B: ",B);
echo("C Size: ",C);


Gives:

ECHO: "B: ", 100
ECHO: "C Size: ", 29


I.e. no error, simply uses the second value for C throughout, and IIRC this is what the manual specifies.




On 28 November 2012 05:30, Triffid Hunter <[hidden email]> wrote:
openscad "variables" are immutable. you can only set them once. The closest we have to mutable variables are loop variables.

If you're familiar with C, think of them as defines rather than actual variables.

On Wed, Nov 28, 2012 at 2:03 PM, Brent Burton <[hidden email]> wrote:
Hi guys,
I'm new to OpenSCAD, but learning it quickly.

I stumbled upon an error in one of my scripts, and I boiled it down to this situation. The workaround is to simplify scripts to avoid this, but there may be situations, like in an if-statement, that this would occur.

/* variable bug.
* Mac OS X, OpenSCAD 2011.12
*/
C = 250;   // Comment this line to hide bug
B = 100;
C = B + 25; // Error: unknown var 'B'

echo("B: ",B);
echo("C Size: ",C);

cube([1,1,1]);


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566

Reply | Threaded
Open this post in threaded view
|

Re: Variable bug?

Whosawhatsis
I think what's happening is that it's trying to declare C with the last value where it is first declared, before B is declared. I'm not saying it makes sense, just that that explanation is consistent with the error as I have encountered it.

On Wednesday, November 28, 2012 at 1:07 AM, nop head wrote:

I think it is a bug because the error message makes no sense:

WARNING: Ignoring unknown variable 'B'.
ECHO: "B: ", 100
ECHO: "C Size: ", undef


This has caught me out a few times and wasted time trying to find the problem in a large multi-file project. Why does B become unknown?


Also:

C = 250; // Comment this line to hide bug
B = 100;
C = 4 + 25; // Error: unknown var 'B'
echo("B: ",B);
echo("C Size: ",C);


Gives:

ECHO: "B: ", 100
ECHO: "C Size: ", 29


I.e. no error, simply uses the second value for C throughout, and IIRC this is what the manual specifies.




On 28 November 2012 05:30, Triffid Hunter <[hidden email]> wrote:
openscad "variables" are immutable. you can only set them once. The closest we have to mutable variables are loop variables.

If you're familiar with C, think of them as defines rather than actual variables.

On Wed, Nov 28, 2012 at 2:03 PM, Brent Burton <[hidden email]> wrote:
Hi guys,
I'm new to OpenSCAD, but learning it quickly.

I stumbled upon an error in one of my scripts, and I boiled it down to this situation. The workaround is to simplify scripts to avoid this, but there may be situations, like in an if-statement, that this would occur.

/* variable bug.
* Mac OS X, OpenSCAD 2011.12
*/
C = 250;   // Comment this line to hide bug
B = 100;
C = B + 25; // Error: unknown var 'B'

echo("B: ",B);
echo("C Size: ",C);

cube([1,1,1]);


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


Reply | Threaded
Open this post in threaded view
|

Re: Variable bug?

Peter Falke
Hi,

I see that reassigning variables is one of the most wished for thing in OpenSCAD.

I learned that you can live without it, but it takes lots of brain energy and makes for really odd and old school looking code.

Up to know I have not been able to understand why OpenSCAD could not be expanded to do that.
What is the underlying reason not to implement variables?

TakeItAndRun


On 28 November 2012 10:44, whosawhatsis <[hidden email]> wrote:
I think what's happening is that it's trying to declare C with the last value where it is first declared, before B is declared. I'm not saying it makes sense, just that that explanation is consistent with the error as I have encountered it.

On Wednesday, November 28, 2012 at 1:07 AM, nop head wrote:

I think it is a bug because the error message makes no sense:

WARNING: Ignoring unknown variable 'B'.
ECHO: "B: ", 100
ECHO: "C Size: ", undef


This has caught me out a few times and wasted time trying to find the problem in a large multi-file project. Why does B become unknown?


Also:

C = 250; // Comment this line to hide bug
B = 100;
C = 4 + 25; // Error: unknown var 'B'
echo("B: ",B);
echo("C Size: ",C);


Gives:

ECHO: "B: ", 100
ECHO: "C Size: ", 29


I.e. no error, simply uses the second value for C throughout, and IIRC this is what the manual specifies.




On 28 November 2012 05:30, Triffid Hunter <[hidden email]> wrote:
openscad "variables" are immutable. you can only set them once. The closest we have to mutable variables are loop variables.

If you're familiar with C, think of them as defines rather than actual variables.

On Wed, Nov 28, 2012 at 2:03 PM, Brent Burton <[hidden email]> wrote:
Hi guys,
I'm new to OpenSCAD, but learning it quickly.

I stumbled upon an error in one of my scripts, and I boiled it down to this situation. The workaround is to simplify scripts to avoid this, but there may be situations, like in an if-statement, that this would occur.

/* variable bug.
* Mac OS X, OpenSCAD 2011.12
*/
C = 250;   // Comment this line to hide bug
B = 100;
C = B + 25; // Error: unknown var 'B'

echo("B: ",B);
echo("C Size: ",C);

cube([1,1,1]);


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



--
[hidden email]

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!

Reply | Threaded
Open this post in threaded view
|

Re: Variable bug?

nophead
Not sure what you mean by old school, You have to write in a functional programming style, the same as you do when writing C++ template meta programs, which also don't have mutable variables at compile time. That also takes a lot of brain energy!

On 28 November 2012 12:11, Peter Falke <[hidden email]> wrote:
Hi,

I see that reassigning variables is one of the most wished for thing in OpenSCAD.

I learned that you can live without it, but it takes lots of brain energy and makes for really odd and old school looking code.

Up to know I have not been able to understand why OpenSCAD could not be expanded to do that.
What is the underlying reason not to implement variables?

TakeItAndRun



On 28 November 2012 10:44, whosawhatsis <[hidden email]> wrote:
I think what's happening is that it's trying to declare C with the last value where it is first declared, before B is declared. I'm not saying it makes sense, just that that explanation is consistent with the error as I have encountered it.

On Wednesday, November 28, 2012 at 1:07 AM, nop head wrote:

I think it is a bug because the error message makes no sense:

WARNING: Ignoring unknown variable 'B'.
ECHO: "B: ", 100
ECHO: "C Size: ", undef


This has caught me out a few times and wasted time trying to find the problem in a large multi-file project. Why does B become unknown?


Also:

C = 250; // Comment this line to hide bug
B = 100;
C = 4 + 25; // Error: unknown var 'B'
echo("B: ",B);
echo("C Size: ",C);


Gives:

ECHO: "B: ", 100
ECHO: "C Size: ", 29


I.e. no error, simply uses the second value for C throughout, and IIRC this is what the manual specifies.




On 28 November 2012 05:30, Triffid Hunter <[hidden email]> wrote:
openscad "variables" are immutable. you can only set them once. The closest we have to mutable variables are loop variables.

If you're familiar with C, think of them as defines rather than actual variables.

On Wed, Nov 28, 2012 at 2:03 PM, Brent Burton <[hidden email]> wrote:
Hi guys,
I'm new to OpenSCAD, but learning it quickly.

I stumbled upon an error in one of my scripts, and I boiled it down to this situation. The workaround is to simplify scripts to avoid this, but there may be situations, like in an if-statement, that this would occur.

/* variable bug.
* Mac OS X, OpenSCAD 2011.12
*/
C = 250;   // Comment this line to hide bug
B = 100;
C = B + 25; // Error: unknown var 'B'

echo("B: ",B);
echo("C Size: ",C);

cube([1,1,1]);


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



--
[hidden email]

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566

Reply | Threaded
Open this post in threaded view
|

Re: Variable bug?

Giles Bathgate-2

Programing paradigms aside it's just a major inconvenience to have immutable "variables", and no mutable ones.

This is why I implemented both in RapCAD

Reply | Threaded
Open this post in threaded view
|

Re: Variable bug?

nophead
Also it seems odd to have the assign() statement. Why can't the same thing be achieved with the normal assignment syntax?

E,g.

for(i = [1,10]) {
    a = i * 5;
}

instead of
for(i = [1,10])
    assign(a=i * 5)



On 28 November 2012 12:45, Giles Bathgate <[hidden email]> wrote:

Programing paradigms aside it's just a major inconvenience to have immutable "variables", and no mutable ones.

This is why I implemented both in RapCAD


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566

Reply | Threaded
Open this post in threaded view
|

Re: Variable bug?

Giles Bathgate-2
The way I see it the assign() module is just a hack to allow
assignment. It doesn't really "assign" in a strict sense at all. Its a
module which takes named arguments and those arguments are then
available within the module as parameters. The assign module thus
cannot modify existing variables. It can only allow new values to be
created (with the same name)

On 28 November 2012 13:04, nop head <[hidden email]> wrote:
> Also it seems odd to have the assign() statement. Why can't the same thing
> be achieved with the normal assignment syntax?
>
> E,g.
>
> for(i = [1,10]) {
>     a = i * 5;
> }

In RapCAD this is how you do assignment there is no assign module.

Regards

Giles

Reply | Threaded
Open this post in threaded view
|

Re: Variable bug?

kintel
Administrator
On 2012-11-28, at 08:27 , Giles Bathgate wrote:

> The way I see it the assign() module is just a hack to allow
> assignment.

assign() basically creates a new scope defining a context where the value is defined.
Being able to modify values defined within a scope makes sense - it just never gets bumped to the top of the list of things to do :/

I think I mentioned earlier that it would be interesting to look into the possibilities of creating a common backend/parser/evaluator engine for OpenSCAD/RapCad/etc., to avoid having multiple different variations of what is essentially the same language.
I think the RapCad parser is by far cleaner that the one in OpenSCAD right now, with the primary strength of OpenSCAD is having a test framework and a larger user base.

Anyway, food for thought after the upcoming release.

 -Marius


Reply | Threaded
Open this post in threaded view
|

Re: Variable bug?

Alan Cox
> I think I mentioned earlier that it would be interesting to look into the possibilities of creating a common backend/parser/evaluator engine for OpenSCAD/RapCad/etc., to avoid having multiple different variations of what is essentially the same language.

They are different variants of a very quirky and soemwhat broken
language. I would hope unifying it would also involve fixing some of the
deep weirdnesses even if it means also having a translator for "old"
language format.

Alan

Reply | Threaded
Open this post in threaded view
|

Re: Variable bug?

kintel
Administrator
On 2012-11-28, at 09:29 , Alan Cox wrote:
>
> They are different variants of a very quirky and soemwhat broken language.

I'm uncertain how to best go about this. I think the main issue is that the language was never designed, but rather evolved based on immediate need.

To use web terminology (for a lack of a better one right now), OpenSCAD feels a bit like XSLT, and having dealt a little with XSLT, I think it's slightly annoying to deal with. On the up-side, it's a well-defined language and there won't be weird side-effects.

..so what we've got is a transformation language (scad) which transforms its input into a pure csg description (scad without variables, for loops, modules etc. = what would be output when doing "Export CSG").

The way out of this could be defining the pure csg description properly, and defining an API making it possible to build the description programmatically, with the risk that developers can mess up things pretty badly (aka. Javascript modifying a DOM).
The API could run embedded using e.g. a Javascript or Lua binding, or all the way to a C or Python binding of offline use.

Anyway, these are all larger changes, and would need a fair amount of resources to pull off + a fair amount of headache to ensure that old models won't break (unless we make a clean break), so it's pretty much in the blue for now.

ok, that's what the top of my head could contribute for now ;)

 -Marius


Reply | Threaded
Open this post in threaded view
|

Re: Variable bug?

Philipp Tiefenbacher
In reply to this post by kintel
One thought about the functional style vs why can't we reassign "variables":
It's much easier to create a visual interactive modeller for
functional languages than for fully turing complete programming
languages because you can't display any part of the object/program
without having to worry about side effects like global variables
changing. For a functional openscad model thats no problem.

Also I see nothing strange or hackish about the assign(), but maybe
thats just because I like lisp...

OpenSCAD is like HTML...you are asking for javascript ;)

On Wed, Nov 28, 2012 at 2:51 PM, Marius Kintel <[hidden email]> wrote:
> Anyway, food for thought after the upcoming release.

huge cheer!



--
:: Philipp Tiefenbacher
:: custom electronics/magic
:: http://magicshifter.net/
:: http://metalab.at/

Any sufficiently advanced technology is indistinguishable from magic
--Arthur C. Clarke

Reply | Threaded
Open this post in threaded view
|

Re: Variable bug?

Drew Rogge
There's an interesting example of interactive programming in this talk
by Bret Victor, http://worrydream.com

http://www.youtube.com/watch?v=PUv66718DII

I wonder what kind of horse power it would take to do the same thing with
CSG.

On 11/28/2012 07:34 AM, Philipp Tiefenbacher wrote:

> One thought about the functional style vs why can't we reassign "variables":
> It's much easier to create a visual interactive modeller for
> functional languages than for fully turing complete programming
> languages because you can't display any part of the object/program
> without having to worry about side effects like global variables
> changing. For a functional openscad model thats no problem.
>
> Also I see nothing strange or hackish about the assign(), but maybe
> thats just because I like lisp...
>
> OpenSCAD is like HTML...you are asking for javascript ;)
>
> On Wed, Nov 28, 2012 at 2:51 PM, Marius Kintel<[hidden email]>  wrote:
>> Anyway, food for thought after the upcoming release.
>
> huge cheer!
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Variable bug?

Peter Falke
In reply to this post by kintel
HI,

thanks Marius for your reply.

I guess the thing that is so puzzling for me is that I dont understand the underlying problematic, here. With "for" the running variable can be reassigned. Why can not this part of the code reused for that?
And I fully understand that I will never be able to understand the inner working of a language that has grown to be able to do so much.

I understand that people have used Python to write a pre-code that they than pass on to OpenSCAD.
Unfortunately I failed to figure out how to do this on my windows system. And back then I could not find a tutorial on how to make it work.

I just like to bring up this point once and again in the hope that enough people with good programming skills come together to work on this point.


Sincerly,

TakeItAndRun






On 28 November 2012 16:15, Marius Kintel <[hidden email]> wrote:
On 2012-11-28, at 09:29 , Alan Cox wrote:
>
> They are different variants of a very quirky and soemwhat broken language.

I'm uncertain how to best go about this. I think the main issue is that the language was never designed, but rather evolved based on immediate need.

To use web terminology (for a lack of a better one right now), OpenSCAD feels a bit like XSLT, and having dealt a little with XSLT, I think it's slightly annoying to deal with. On the up-side, it's a well-defined language and there won't be weird side-effects.

..so what we've got is a transformation language (scad) which transforms its input into a pure csg description (scad without variables, for loops, modules etc. = what would be output when doing "Export CSG").

The way out of this could be defining the pure csg description properly, and defining an API making it possible to build the description programmatically, with the risk that developers can mess up things pretty badly (aka. Javascript modifying a DOM).
The API could run embedded using e.g. a Javascript or Lua binding, or all the way to a C or Python binding of offline use.

Anyway, these are all larger changes, and would need a fair amount of resources to pull off + a fair amount of headache to ensure that old models won't break (unless we make a clean break), so it's pretty much in the blue for now.

ok, that's what the top of my head could contribute for now ;)

 -Marius

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566



--
[hidden email]

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!

Reply | Threaded
Open this post in threaded view
|

Re: Variable bug?

Alan Cox
On Wed, 28 Nov 2012 16:55:03 +0100
Peter Falke <[hidden email]> wrote:

> HI,
>
> thanks Marius for your reply.
>
> I guess the thing that is so puzzling for me is that I dont understand the
> underlying problematic, here. With "for" the running variable can be
> reassigned.

It's not really reassigning the variable, its expanding the list of
values in the "for" as a list and generating the subtree for each case.


Reply | Threaded
Open this post in threaded view
|

Re: Variable bug?

Peter Falke
Alan,

Yup. Now how to use this for reassigning variables. I dont care if they are temporally expanded into a list.

Drew,

nice things he does in this video.
The medium: fingernail in clay, chisel in stone, or thumb on Ipad does change how and what you'll write.

I like Openscad

On 28 November 2012 17:09, Alan Cox <[hidden email]> wrote:
On Wed, 28 Nov 2012 16:55:03 +0100
Peter Falke <[hidden email]> wrote:

> HI,
>
> thanks Marius for your reply.
>
> I guess the thing that is so puzzling for me is that I dont understand the
> underlying problematic, here. With "for" the running variable can be
> reassigned.

It's not really reassigning the variable, its expanding the list of
values in the "for" as a list and generating the subtree for each case.




--
[hidden email]

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!

Reply | Threaded
Open this post in threaded view
|

Re: Variable bug?

Brad Pitcher
Can you reproduce the problem without reassigning a variable? If there is no legitimate use case to reproduce this, it's not really a bug, right?

---------
Brad Pitcher
Software Developer
(702)723-8255


On Wed, Nov 28, 2012 at 8:49 AM, Peter Falke <[hidden email]> wrote:
Alan,

Yup. Now how to use this for reassigning variables. I dont care if they are temporally expanded into a list.

Drew,

nice things he does in this video.
The medium: fingernail in clay, chisel in stone, or thumb on Ipad does change how and what you'll write.

I like Openscad

On 28 November 2012 17:09, Alan Cox <[hidden email]> wrote:
On Wed, 28 Nov 2012 16:55:03 +0100
Peter Falke <[hidden email]> wrote:

> HI,
>
> thanks Marius for your reply.
>
> I guess the thing that is so puzzling for me is that I dont understand the
> underlying problematic, here. With "for" the running variable can be
> reassigned.

It's not really reassigning the variable, its expanding the list of
values in the "for" as a list and generating the subtree for each case.




--
[hidden email]

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566

Reply | Threaded
Open this post in threaded view
|

Re: Variable bug?

nophead
Going back to the start of this conversation I think there is a bug. Not that you can't change a variable, but that it says B is undefined.

I don't think the lack of mutable variables stops you doing anything and functional languages can be Turing complete. I am not sure whether OpenScad is or not. You can compute a lot of things with recursive functions and the ? operator.

On 28 November 2012 16:59, Brad Pitcher <[hidden email]> wrote:
Can you reproduce the problem without reassigning a variable? If there is no legitimate use case to reproduce this, it's not really a bug, right?

---------
Brad Pitcher
Software Developer
<a href="tel:%28702%29723-8255" value="+17027238255" target="_blank">(702)723-8255


On Wed, Nov 28, 2012 at 8:49 AM, Peter Falke <[hidden email]> wrote:
Alan,

Yup. Now how to use this for reassigning variables. I dont care if they are temporally expanded into a list.

Drew,

nice things he does in this video.
The medium: fingernail in clay, chisel in stone, or thumb on Ipad does change how and what you'll write.

I like Openscad

On 28 November 2012 17:09, Alan Cox <[hidden email]> wrote:
On Wed, 28 Nov 2012 16:55:03 +0100
Peter Falke <[hidden email]> wrote:

> HI,
>
> thanks Marius for your reply.
>
> I guess the thing that is so puzzling for me is that I dont understand the
> underlying problematic, here. With "for" the running variable can be
> reassigned.

It's not really reassigning the variable, its expanding the list of
values in the "for" as a list and generating the subtree for each case.




--
[hidden email]

P.S. Falls meine E-Mail kürzer ausfällt als Dir angenehm ist:
Ich probiere gerade aus kurze Antworten statt gar keine Antworten zu schreiben.
Wenn Du gerne mehr lesen möchtest, dann lass es mich bitte wissen.

P.S. In case my e-mail is shorter than you enjoy:
I am currently trying short replies instead of no replies at all.
Please let me know, if you like to read more.

Enjoy!


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://rocklinux.net/mailman/listinfo/openscad
http://openscad.org - https://flattr.com/thing/121566

1234