discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Command line $ variables

NH
nop head
Thu, Nov 16, 2017 2:39 PM

I use a dynamic variable to turn on and off BOM generation, which is just
echo statements.

When I use the GUI $bom = 0 so I don't have screen clutter. When I
generated a bom I set $bom on the command line and capture the echos. All
works fine.

Occasionally I have vitamins like nuts and washers that come as part of
something else, for example a toggle switch. In that case I don't want the
parts that come with it on the bom so I override $bom to 0 before adding
the vitamins. This works from the GUI but doesn't seem to work on the
command line. The command line override seems to beat the dynamic scope
override. Is this a bug?

I use a dynamic variable to turn on and off BOM generation, which is just echo statements. When I use the GUI $bom = 0 so I don't have screen clutter. When I generated a bom I set $bom on the command line and capture the echos. All works fine. Occasionally I have vitamins like nuts and washers that come as part of something else, for example a toggle switch. In that case I don't want the parts that come with it on the bom so I override $bom to 0 before adding the vitamins. This works from the GUI but doesn't seem to work on the command line. The command line override seems to beat the dynamic scope override. Is this a bug?
O
OzAtMichael
Thu, Nov 16, 2017 9:28 PM

so I override $bom to 0 before adding the vitamins. This works from the GUI but doesn't seem to

work on the command line. The command line override seems to beat the dynamic scope override. Is
this a bug?

You'll need to show an example of where in the scope levels this is happening. ie what is 'adding
the vitamins' & where is the $bom=0 override?

As you know, the -D variables are just added to the tail of the source, what happens if you do it
likewise in the GUI?


From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of nop head
Sent: Fri, 17 Nov 2017 01:40
To: OpenSCAD general discussion
Subject: [OpenSCAD] Command line $ variables

I use a dynamic variable to turn on and off BOM generation, which is just echo statements.

When I use the GUI $bom = 0 so I don't have screen clutter. When I generated a bom I set $bom on
the command line and capture the echos. All works fine.

Occasionally I have vitamins like nuts and washers that come as part of something else, for example
a toggle switch. In that case I don't want the parts that come with it on the bom so I override
$bom to 0 before adding the vitamins. This works from the GUI but doesn't seem to work on the
command line. The command line override seems to beat the dynamic scope override. Is this a bug?

> so I override $bom to 0 before adding the vitamins. This works from the GUI but doesn't seem to work on the command line. The command line override seems to beat the dynamic scope override. Is this a bug? You'll need to show an example of where in the scope levels this is happening. ie what is 'adding the vitamins' & where is the $bom=0 override? As you know, the -D variables are just added to the tail of the source, what happens if you do it likewise in the GUI? _____ From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of nop head Sent: Fri, 17 Nov 2017 01:40 To: OpenSCAD general discussion Subject: [OpenSCAD] Command line $ variables I use a dynamic variable to turn on and off BOM generation, which is just echo statements. When I use the GUI $bom = 0 so I don't have screen clutter. When I generated a bom I set $bom on the command line and capture the echos. All works fine. Occasionally I have vitamins like nuts and washers that come as part of something else, for example a toggle switch. In that case I don't want the parts that come with it on the bom so I override $bom to 0 before adding the vitamins. This works from the GUI but doesn't seem to work on the command line. The command line override seems to beat the dynamic scope override. Is this a bug?
NH
nop head
Thu, Nov 16, 2017 10:10 PM

If I add a definition at the end of my main file it works as expected in
the GUI. It sets the variable at file scope but it can be overridden at
module scope and that is passed down the tree to other modules that can be
in other files.

Setting it on the command line instead overrides it everywhere, not just at
file scope.

Module scope should always trump file scope and I think it worked in the
past but it doesn't work with recent versions.

I will try to make a small example.

On 16 November 2017 at 21:28, OzAtMichael oz.at.michael@gmail.com wrote:

so I override $bom to 0 before adding the vitamins. This works from the

GUI but doesn't seem to work on the command line. The command line override
seems to beat the dynamic scope override. Is this a bug?

You’ll need to show an example of where in the scope levels this is
happening. ie what is ‘adding the vitamins’ & where is the $bom=0 override?

As you know, the –D variables are just added to the tail of the source,
what happens if you do it likewise in the GUI?


From: Discuss [mailto:discuss-bounces@lists.openscad.org] *On Behalf Of
*nop head
Sent: Fri, 17 Nov 2017 01:40
To: OpenSCAD general discussion
Subject: [OpenSCAD] Command line $ variables

I use a dynamic variable to turn on and off BOM generation, which is just
echo statements.

When I use the GUI $bom = 0 so I don't have screen clutter. When I
generated a bom I set $bom on the command line and capture the echos. All
works fine.

Occasionally I have vitamins like nuts and washers that come as part of
something else, for example a toggle switch. In that case I don't want the
parts that come with it on the bom so I override $bom to 0 before adding
the vitamins. This works from the GUI but doesn't seem to work on the
command line. The command line override seems to beat the dynamic scope
override. Is this a bug?


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

If I add a definition at the end of my main file it works as expected in the GUI. It sets the variable at file scope but it can be overridden at module scope and that is passed down the tree to other modules that can be in other files. Setting it on the command line instead overrides it everywhere, not just at file scope. Module scope should always trump file scope and I think it worked in the past but it doesn't work with recent versions. I will try to make a small example. On 16 November 2017 at 21:28, OzAtMichael <oz.at.michael@gmail.com> wrote: > > so I override $bom to 0 before adding the vitamins. This works from the > GUI but doesn't seem to work on the command line. The command line override > seems to beat the dynamic scope override. Is this a bug? > > > > You’ll need to show an example of where in the scope levels this is > happening. ie what is ‘adding the vitamins’ & where is the $bom=0 override? > > As you know, the –D variables are just added to the tail of the source, > what happens if you do it likewise in the GUI? > > > ------------------------------ > > *From:* Discuss [mailto:discuss-bounces@lists.openscad.org] *On Behalf Of > *nop head > *Sent:* Fri, 17 Nov 2017 01:40 > *To:* OpenSCAD general discussion > *Subject:* [OpenSCAD] Command line $ variables > > > > I use a dynamic variable to turn on and off BOM generation, which is just > echo statements. > > > > When I use the GUI $bom = 0 so I don't have screen clutter. When I > generated a bom I set $bom on the command line and capture the echos. All > works fine. > > > > Occasionally I have vitamins like nuts and washers that come as part of > something else, for example a toggle switch. In that case I don't want the > parts that come with it on the bom so I override $bom to 0 before adding > the vitamins. This works from the GUI but doesn't seem to work on the > command line. The command line override seems to beat the dynamic scope > override. Is this a bug? > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >
NH
nop head
Thu, Nov 16, 2017 10:27 PM

use.scad:

$bom = 0;

use <used.scad>

test();

let($bom = 0)
test();

$bom = 1;

used.scad:

use <used2.scad>

module test() {
echo("test:", $bom = $bom);
test2();
}

used2.scad:

module test2() {
echo("test2:", $bom=$bom);
}

In the GUI this gives:

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

ECHO: "test:", $bom = 0

ECHO: "test2:", $bom = 0

From the command line with -D$bom=1 it gives:

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

On 16 November 2017 at 22:10, nop head nop.head@gmail.com wrote:

If I add a definition at the end of my main file it works as expected in
the GUI. It sets the variable at file scope but it can be overridden at
module scope and that is passed down the tree to other modules that can be
in other files.

Setting it on the command line instead overrides it everywhere, not just
at file scope.

Module scope should always trump file scope and I think it worked in the
past but it doesn't work with recent versions.

I will try to make a small example.

On 16 November 2017 at 21:28, OzAtMichael oz.at.michael@gmail.com wrote:

so I override $bom to 0 before adding the vitamins. This works from

the GUI but doesn't seem to work on the command line. The command line
override seems to beat the dynamic scope override. Is this a bug?

You’ll need to show an example of where in the scope levels this is
happening. ie what is ‘adding the vitamins’ & where is the $bom=0 override?

As you know, the –D variables are just added to the tail of the source,
what happens if you do it likewise in the GUI?


From: Discuss [mailto:discuss-bounces@lists.openscad.org] *On Behalf
Of *nop head
Sent: Fri, 17 Nov 2017 01:40
To: OpenSCAD general discussion
Subject: [OpenSCAD] Command line $ variables

I use a dynamic variable to turn on and off BOM generation, which is just
echo statements.

When I use the GUI $bom = 0 so I don't have screen clutter. When I
generated a bom I set $bom on the command line and capture the echos. All
works fine.

Occasionally I have vitamins like nuts and washers that come as part of
something else, for example a toggle switch. In that case I don't want the
parts that come with it on the bom so I override $bom to 0 before adding
the vitamins. This works from the GUI but doesn't seem to work on the
command line. The command line override seems to beat the dynamic scope
override. Is this a bug?


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

use.scad: ------------ $bom = 0; use <used.scad> test(); let($bom = 0) test(); $bom = 1; used.scad: -------------- use <used2.scad> module test() { echo("test:", $bom = $bom); test2(); } used2.scad: ---------------- module test2() { echo("test2:", $bom=$bom); } In the GUI this gives: ECHO: "test:", $bom = 1 ECHO: "test2:", $bom = 1 ECHO: "test:", $bom = 0 ECHO: "test2:", $bom = 0 >From the command line with -D$bom=1 it gives: ECHO: "test:", $bom = 1 ECHO: "test2:", $bom = 1 ECHO: "test:", $bom = 1 ECHO: "test2:", $bom = 1 On 16 November 2017 at 22:10, nop head <nop.head@gmail.com> wrote: > If I add a definition at the end of my main file it works as expected in > the GUI. It sets the variable at file scope but it can be overridden at > module scope and that is passed down the tree to other modules that can be > in other files. > > Setting it on the command line instead overrides it everywhere, not just > at file scope. > > Module scope should always trump file scope and I think it worked in the > past but it doesn't work with recent versions. > > I will try to make a small example. > > > > > > On 16 November 2017 at 21:28, OzAtMichael <oz.at.michael@gmail.com> wrote: > >> > so I override $bom to 0 before adding the vitamins. This works from >> the GUI but doesn't seem to work on the command line. The command line >> override seems to beat the dynamic scope override. Is this a bug? >> >> >> >> You’ll need to show an example of where in the scope levels this is >> happening. ie what is ‘adding the vitamins’ & where is the $bom=0 override? >> >> As you know, the –D variables are just added to the tail of the source, >> what happens if you do it likewise in the GUI? >> >> >> ------------------------------ >> >> *From:* Discuss [mailto:discuss-bounces@lists.openscad.org] *On Behalf >> Of *nop head >> *Sent:* Fri, 17 Nov 2017 01:40 >> *To:* OpenSCAD general discussion >> *Subject:* [OpenSCAD] Command line $ variables >> >> >> >> I use a dynamic variable to turn on and off BOM generation, which is just >> echo statements. >> >> >> >> When I use the GUI $bom = 0 so I don't have screen clutter. When I >> generated a bom I set $bom on the command line and capture the echos. All >> works fine. >> >> >> >> Occasionally I have vitamins like nuts and washers that come as part of >> something else, for example a toggle switch. In that case I don't want the >> parts that come with it on the bom so I override $bom to 0 before adding >> the vitamins. This works from the GUI but doesn't seem to work on the >> command line. The command line override seems to beat the dynamic scope >> override. Is this a bug? >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >> >
MM
Michael Marx
Fri, Nov 17, 2017 12:44 AM

What version are you using?


From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of nop head
Sent: Fri, 17 Nov 2017 09:28
To: OpenSCAD general discussion
Subject: Re: [OpenSCAD] Command line $ variables

use.scad:


$bom = 0;

use <used.scad>

test();

let($bom = 0)

test();

$bom = 1;

used.scad:


use <used2.scad>

module test() {

echo("test:", $bom = $bom);

      test2();

}

used2.scad:


module test2() {

echo("test2:", $bom=$bom);

}

In the GUI this gives:

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

ECHO: "test:", $bom = 0

ECHO: "test2:", $bom = 0

From the command line with -D$bom=1 it gives:

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

On 16 November 2017 at 22:10, nop head nop.head@gmail.com wrote:

If I add a definition at the end of my main file it works as expected in the GUI. It sets the
variable at file scope but it can be overridden at module scope and that is passed down the tree to
other modules that can be in other files.

Setting it on the command line instead overrides it everywhere, not just at file scope.

Module scope should always trump file scope and I think it worked in the past but it doesn't work
with recent versions.

I will try to make a small example.

On 16 November 2017 at 21:28, OzAtMichael oz.at.michael@gmail.com wrote:

so I override $bom to 0 before adding the vitamins. This works from the GUI but doesn't seem to

work on the command line. The command line override seems to beat the dynamic scope override. Is
this a bug?

You'll need to show an example of where in the scope levels this is happening. ie what is 'adding
the vitamins' & where is the $bom=0 override?

As you know, the -D variables are just added to the tail of the source, what happens if you do it
likewise in the GUI?


From: Discuss [mailto:discuss-bounces@lists. mailto:discuss-bounces@lists.openscad.org
openscad.org] On Behalf Of nop head
Sent: Fri, 17 Nov 2017 01:40
To: OpenSCAD general discussion
Subject: [OpenSCAD] Command line $ variables

I use a dynamic variable to turn on and off BOM generation, which is just echo statements.

When I use the GUI $bom = 0 so I don't have screen clutter. When I generated a bom I set $bom on
the command line and capture the echos. All works fine.

Occasionally I have vitamins like nuts and washers that come as part of something else, for example
a toggle switch. In that case I don't want the parts that come with it on the bom so I override
$bom to 0 before adding the vitamins. This works from the GUI but doesn't seem to work on the
command line. The command line override seems to beat the dynamic scope override. Is this a bug?


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

What version are you using? _____ From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of nop head Sent: Fri, 17 Nov 2017 09:28 To: OpenSCAD general discussion Subject: Re: [OpenSCAD] Command line $ variables use.scad: ------------ $bom = 0; use <used.scad> test(); let($bom = 0) test(); $bom = 1; used.scad: -------------- use <used2.scad> module test() { echo("test:", $bom = $bom); test2(); } used2.scad: ---------------- module test2() { echo("test2:", $bom=$bom); } In the GUI this gives: ECHO: "test:", $bom = 1 ECHO: "test2:", $bom = 1 ECHO: "test:", $bom = 0 ECHO: "test2:", $bom = 0 >From the command line with -D$bom=1 it gives: ECHO: "test:", $bom = 1 ECHO: "test2:", $bom = 1 ECHO: "test:", $bom = 1 ECHO: "test2:", $bom = 1 On 16 November 2017 at 22:10, nop head <nop.head@gmail.com> wrote: If I add a definition at the end of my main file it works as expected in the GUI. It sets the variable at file scope but it can be overridden at module scope and that is passed down the tree to other modules that can be in other files. Setting it on the command line instead overrides it everywhere, not just at file scope. Module scope should always trump file scope and I think it worked in the past but it doesn't work with recent versions. I will try to make a small example. On 16 November 2017 at 21:28, OzAtMichael <oz.at.michael@gmail.com> wrote: > so I override $bom to 0 before adding the vitamins. This works from the GUI but doesn't seem to work on the command line. The command line override seems to beat the dynamic scope override. Is this a bug? You'll need to show an example of where in the scope levels this is happening. ie what is 'adding the vitamins' & where is the $bom=0 override? As you know, the -D variables are just added to the tail of the source, what happens if you do it likewise in the GUI? _____ From: Discuss [mailto:discuss-bounces@lists. <mailto:discuss-bounces@lists.openscad.org> openscad.org] On Behalf Of nop head Sent: Fri, 17 Nov 2017 01:40 To: OpenSCAD general discussion Subject: [OpenSCAD] Command line $ variables I use a dynamic variable to turn on and off BOM generation, which is just echo statements. When I use the GUI $bom = 0 so I don't have screen clutter. When I generated a bom I set $bom on the command line and capture the echos. All works fine. Occasionally I have vitamins like nuts and washers that come as part of something else, for example a toggle switch. In that case I don't want the parts that come with it on the bom so I override $bom to 0 before adding the vitamins. This works from the GUI but doesn't seem to work on the command line. The command line override seems to beat the dynamic scope override. Is this a bug? _______________________________________________ OpenSCAD mailing list Discuss@lists.openscad.org http://lists.openscad.org/mail <http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org> man/listinfo/discuss_lists.openscad.org
MM
Michael Marx
Fri, Nov 17, 2017 1:33 AM

On the other hand (see below)

I now recall one of my "doesn't feel right" issues was with use<>

use<> has always had funny scope.

I replaced use<> with include<> and cmd line works the same as the GUI.

I also added (with use<>)

assign($bom=2)

test();

It shows the same inconsistency, ie $bom is echoed as 1 via cmd line, 2 via GUI.

So I suspect an issue with use<> scope and how -D is scoped.

=============I typed the below before the above===================

Looks like let()'s scope hasn't been entirely nailed down? (edit prob. not)

I can't think of something that would normally differ GUI v's cmd line, perhaps there is a #ifdef
confounding it?

As mentioned a few times the scope rules are not well documented and particularly the $variables.

Perhaps someone(?) needs to review the codebase to document the scope 'as-is' state in a high level
language so it can be looked at.

Every so often I come across something which doesn't feel right, but without the 'what it is mean
to be' documented it is hard to know.


From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of nop head
Sent: Fri, 17 Nov 2017 09:28
To: OpenSCAD general discussion
Subject: Re: [OpenSCAD] Command line $ variables

use.scad:


$bom = 0;

use <used.scad>

test();

let($bom = 0)

test();

$bom = 1;

used.scad:


use <used2.scad>

module test() {

echo("test:", $bom = $bom);

      test2();

}

used2.scad:


module test2() {

echo("test2:", $bom=$bom);

}

In the GUI this gives:

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

ECHO: "test:", $bom = 0

ECHO: "test2:", $bom = 0

From the command line with -D$bom=1 it gives:

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

On 16 November 2017 at 22:10, nop head nop.head@gmail.com wrote:

If I add a definition at the end of my main file it works as expected in the GUI. It sets the
variable at file scope but it can be overridden at module scope and that is passed down the tree to
other modules that can be in other files.

Setting it on the command line instead overrides it everywhere, not just at file scope.

Module scope should always trump file scope and I think it worked in the past but it doesn't work
with recent versions.

I will try to make a small example.

On 16 November 2017 at 21:28, OzAtMichael oz.at.michael@gmail.com wrote:

so I override $bom to 0 before adding the vitamins. This works from the GUI but doesn't seem to

work on the command line. The command line override seems to beat the dynamic scope override. Is
this a bug?

You'll need to show an example of where in the scope levels this is happening. ie what is 'adding
the vitamins' & where is the $bom=0 override?

As you know, the -D variables are just added to the tail of the source, what happens if you do it
likewise in the GUI?


From: Discuss [mailto:discuss-bounces@lists. mailto:discuss-bounces@lists.openscad.org
openscad.org] On Behalf Of nop head
Sent: Fri, 17 Nov 2017 01:40
To: OpenSCAD general discussion
Subject: [OpenSCAD] Command line $ variables

I use a dynamic variable to turn on and off BOM generation, which is just echo statements.

When I use the GUI $bom = 0 so I don't have screen clutter. When I generated a bom I set $bom on
the command line and capture the echos. All works fine.

Occasionally I have vitamins like nuts and washers that come as part of something else, for example
a toggle switch. In that case I don't want the parts that come with it on the bom so I override
$bom to 0 before adding the vitamins. This works from the GUI but doesn't seem to work on the
command line. The command line override seems to beat the dynamic scope override. Is this a bug?


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

On the other hand (see below) I now recall one of my "doesn't feel right" issues was with use<> use<> has always had funny scope. I replaced use<> with include<> and cmd line works the same as the GUI. I also added (with use<>) assign($bom=2) test(); It shows the same inconsistency, ie $bom is echoed as 1 via cmd line, 2 via GUI. So I suspect an issue with use<> scope and how -D is scoped. =============I typed the below before the above=================== Looks like let()'s scope hasn't been entirely nailed down? (edit prob. not) I can't think of something that would normally differ GUI v's cmd line, perhaps there is a #ifdef confounding it? As mentioned a few times the scope rules are not well documented and particularly the $variables. Perhaps someone(?) needs to review the codebase to document the scope 'as-is' state in a high level language so it can be looked at. Every so often I come across something which doesn't feel right, but without the 'what it is mean to be' documented it is hard to know. _____ From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of nop head Sent: Fri, 17 Nov 2017 09:28 To: OpenSCAD general discussion Subject: Re: [OpenSCAD] Command line $ variables use.scad: ------------ $bom = 0; use <used.scad> test(); let($bom = 0) test(); $bom = 1; used.scad: -------------- use <used2.scad> module test() { echo("test:", $bom = $bom); test2(); } used2.scad: ---------------- module test2() { echo("test2:", $bom=$bom); } In the GUI this gives: ECHO: "test:", $bom = 1 ECHO: "test2:", $bom = 1 ECHO: "test:", $bom = 0 ECHO: "test2:", $bom = 0 >From the command line with -D$bom=1 it gives: ECHO: "test:", $bom = 1 ECHO: "test2:", $bom = 1 ECHO: "test:", $bom = 1 ECHO: "test2:", $bom = 1 On 16 November 2017 at 22:10, nop head <nop.head@gmail.com> wrote: If I add a definition at the end of my main file it works as expected in the GUI. It sets the variable at file scope but it can be overridden at module scope and that is passed down the tree to other modules that can be in other files. Setting it on the command line instead overrides it everywhere, not just at file scope. Module scope should always trump file scope and I think it worked in the past but it doesn't work with recent versions. I will try to make a small example. On 16 November 2017 at 21:28, OzAtMichael <oz.at.michael@gmail.com> wrote: > so I override $bom to 0 before adding the vitamins. This works from the GUI but doesn't seem to work on the command line. The command line override seems to beat the dynamic scope override. Is this a bug? You'll need to show an example of where in the scope levels this is happening. ie what is 'adding the vitamins' & where is the $bom=0 override? As you know, the -D variables are just added to the tail of the source, what happens if you do it likewise in the GUI? _____ From: Discuss [mailto:discuss-bounces@lists. <mailto:discuss-bounces@lists.openscad.org> openscad.org] On Behalf Of nop head Sent: Fri, 17 Nov 2017 01:40 To: OpenSCAD general discussion Subject: [OpenSCAD] Command line $ variables I use a dynamic variable to turn on and off BOM generation, which is just echo statements. When I use the GUI $bom = 0 so I don't have screen clutter. When I generated a bom I set $bom on the command line and capture the echos. All works fine. Occasionally I have vitamins like nuts and washers that come as part of something else, for example a toggle switch. In that case I don't want the parts that come with it on the bom so I override $bom to 0 before adding the vitamins. This works from the GUI but doesn't seem to work on the command line. The command line override seems to beat the dynamic scope override. Is this a bug? _______________________________________________ OpenSCAD mailing list Discuss@lists.openscad.org http://lists.openscad.org/mail <http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org> man/listinfo/discuss_lists.openscad.org
NH
nop head
Fri, Nov 17, 2017 8:45 AM

I upgraded to the latest Windows snapshot when after I noticed this
problem: version 2017.11.12 (git 7cb1e93). Before that I was using a
version I compiled myself. In the more distant past I think this worked as
expected because I used the technique in Mendel90.

If the -D option just appends code to the  main file don't understand how
it makes any difference at all with this test because I already set it at
the end of the file.

It behaves as if it puts the command line stuff in a new scope that has
super powers.

On 17 November 2017 at 01:33, Michael Marx michael.marx@tpg.com.au wrote:

On the other hand (see below)

I now recall one of my “doesn’t feel right” issues was with use<>

use<> has always had funny scope.

I replaced use<> with include<> and cmd line works the same as the GUI.

I also added (with use<>)

assign($bom=2)

test();

It shows the same inconsistency, ie $bom is echoed as 1 via cmd line, 2
via GUI.

So I suspect an issue with use<> scope and how –D is scoped.

=============I typed the below before the above===================

Looks like let()’s scope hasn’t been entirely nailed down? (edit prob. not)

I can’t think of something that would normally differ GUI v’s cmd line,
perhaps there is a #ifdef confounding it?

As mentioned a few times the scope rules are not well documented and
particularly the $variables.

Perhaps someone(?) needs to review the codebase to document the scope
‘as-is’ state in a high level language so it can be looked at.

Every so often I come across something which doesn’t feel right, but
without the ‘what it is mean to be’ documented it is hard to know.


From: Discuss [mailto:discuss-bounces@lists.openscad.org] *On Behalf Of
*nop head
Sent: Fri, 17 Nov 2017 09:28
To: OpenSCAD general discussion
Subject: Re: [OpenSCAD] Command line $ variables

use.scad:


$bom = 0;

use <used.scad>

test();

let($bom = 0)

test();

$bom = 1;

used.scad:


use <used2.scad>

module test() {

 echo("test:", $bom = $bom);

       test2();

}

used2.scad:


module test2() {

 echo("test2:", $bom=$bom);

}

In the GUI this gives:

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

ECHO: "test:", $bom = 0

ECHO: "test2:", $bom = 0

From the command line with -D$bom=1 it gives:

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

On 16 November 2017 at 22:10, nop head nop.head@gmail.com wrote:

If I add a definition at the end of my main file it works as expected in
the GUI. It sets the variable at file scope but it can be overridden at
module scope and that is passed down the tree to other modules that can be
in other files.

Setting it on the command line instead overrides it everywhere, not just
at file scope.

Module scope should always trump file scope and I think it worked in the
past but it doesn't work with recent versions.

I will try to make a small example.

On 16 November 2017 at 21:28, OzAtMichael oz.at.michael@gmail.com wrote:

so I override $bom to 0 before adding the vitamins. This works from the

GUI but doesn't seem to work on the command line. The command line override
seems to beat the dynamic scope override. Is this a bug?

You’ll need to show an example of where in the scope levels this is
happening. ie what is ‘adding the vitamins’ & where is the $bom=0 override?

As you know, the –D variables are just added to the tail of the source,
what happens if you do it likewise in the GUI?


From: Discuss [mailto:discuss-bounces@lists.openscad.org] *On Behalf Of
*nop head
Sent: Fri, 17 Nov 2017 01:40
To: OpenSCAD general discussion
Subject: [OpenSCAD] Command line $ variables

I use a dynamic variable to turn on and off BOM generation, which is just
echo statements.

When I use the GUI $bom = 0 so I don't have screen clutter. When I
generated a bom I set $bom on the command line and capture the echos. All
works fine.

Occasionally I have vitamins like nuts and washers that come as part of
something else, for example a toggle switch. In that case I don't want the
parts that come with it on the bom so I override $bom to 0 before adding
the vitamins. This works from the GUI but doesn't seem to work on the
command line. The command line override seems to beat the dynamic scope
override. Is this a bug?


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

I upgraded to the latest Windows snapshot when after I noticed this problem: version 2017.11.12 (git 7cb1e93). Before that I was using a version I compiled myself. In the more distant past I think this worked as expected because I used the technique in Mendel90. If the -D option just appends code to the main file don't understand how it makes any difference at all with this test because I already set it at the end of the file. It behaves as if it puts the command line stuff in a new scope that has super powers. On 17 November 2017 at 01:33, Michael Marx <michael.marx@tpg.com.au> wrote: > On the other hand (see below) > > I now recall one of my “doesn’t feel right” issues was with use<> > > > > use<> has always had funny scope. > > > > I replaced use<> with include<> and cmd line works the same as the GUI. > > > > I also added (with use<>) > > > > assign($bom=2) > > test(); > > > > It shows the same inconsistency, ie $bom is echoed as 1 via cmd line, 2 > via GUI. > > > > So I suspect an issue with use<> scope and how –D is scoped. > > > > > > =============I typed the below before the above=================== > > Looks like let()’s scope hasn’t been entirely nailed down? (edit prob. not) > > I can’t think of something that would normally differ GUI v’s cmd line, > perhaps there is a #ifdef confounding it? > > > > > > As mentioned a few times the scope rules are not well documented and > particularly the $variables. > > Perhaps someone(?) needs to review the codebase to document the scope > ‘as-is’ state in a high level language so it can be looked at. > > Every so often I come across something which doesn’t feel right, but > without the ‘what it is mean to be’ documented it is hard to know. > > > ------------------------------ > > *From:* Discuss [mailto:discuss-bounces@lists.openscad.org] *On Behalf Of > *nop head > *Sent:* Fri, 17 Nov 2017 09:28 > *To:* OpenSCAD general discussion > *Subject:* Re: [OpenSCAD] Command line $ variables > > > > use.scad: > > ------------ > > $bom = 0; > > > > use <used.scad> > > > > test(); > > > > let($bom = 0) > > test(); > > > > $bom = 1; > > > > used.scad: > > -------------- > > use <used2.scad> > > > > module test() { > > echo("test:", $bom = $bom); > > test2(); > > } > > > > used2.scad: > > ---------------- > > module test2() { > > echo("test2:", $bom=$bom); > > } > > > > In the GUI this gives: > > ECHO: "test:", $bom = 1 > > ECHO: "test2:", $bom = 1 > > ECHO: "test:", $bom = 0 > > ECHO: "test2:", $bom = 0 > > > > From the command line with -D$bom=1 it gives: > > ECHO: "test:", $bom = 1 > > ECHO: "test2:", $bom = 1 > > ECHO: "test:", $bom = 1 > > ECHO: "test2:", $bom = 1 > > > > > > > > > > > > > > On 16 November 2017 at 22:10, nop head <nop.head@gmail.com> wrote: > > If I add a definition at the end of my main file it works as expected in > the GUI. It sets the variable at file scope but it can be overridden at > module scope and that is passed down the tree to other modules that can be > in other files. > > > > Setting it on the command line instead overrides it everywhere, not just > at file scope. > > > > Module scope should always trump file scope and I think it worked in the > past but it doesn't work with recent versions. > > > > I will try to make a small example. > > > > > > > > > > > > On 16 November 2017 at 21:28, OzAtMichael <oz.at.michael@gmail.com> wrote: > > > so I override $bom to 0 before adding the vitamins. This works from the > GUI but doesn't seem to work on the command line. The command line override > seems to beat the dynamic scope override. Is this a bug? > > > > You’ll need to show an example of where in the scope levels this is > happening. ie what is ‘adding the vitamins’ & where is the $bom=0 override? > > As you know, the –D variables are just added to the tail of the source, > what happens if you do it likewise in the GUI? > > > ------------------------------ > > *From:* Discuss [mailto:discuss-bounces@lists.openscad.org] *On Behalf Of > *nop head > *Sent:* Fri, 17 Nov 2017 01:40 > *To:* OpenSCAD general discussion > *Subject:* [OpenSCAD] Command line $ variables > > > > I use a dynamic variable to turn on and off BOM generation, which is just > echo statements. > > > > When I use the GUI $bom = 0 so I don't have screen clutter. When I > generated a bom I set $bom on the command line and capture the echos. All > works fine. > > > > Occasionally I have vitamins like nuts and washers that come as part of > something else, for example a toggle switch. In that case I don't want the > parts that come with it on the bom so I override $bom to 0 before adding > the vitamins. This works from the GUI but doesn't seem to work on the > command line. The command line override seems to beat the dynamic scope > override. Is this a bug? > > > > _______________________________________________ > 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 > >
NH
nop head
Fri, Nov 17, 2017 9:06 AM

Looking at the source code it does simply concatenate the -D text on the
end of the main file:
https://github.com/openscad/openscad/blob/master/src/openscad.cc#L402

I am therefore baffled as to how this can go wrong.

On 17 November 2017 at 08:45, nop head nop.head@gmail.com wrote:

I upgraded to the latest Windows snapshot when after I noticed this
problem: version 2017.11.12 (git 7cb1e93). Before that I was using a
version I compiled myself. In the more distant past I think this worked as
expected because I used the technique in Mendel90.

If the -D option just appends code to the  main file don't understand how
it makes any difference at all with this test because I already set it at
the end of the file.

It behaves as if it puts the command line stuff in a new scope that has
super powers.

On 17 November 2017 at 01:33, Michael Marx michael.marx@tpg.com.au
wrote:

On the other hand (see below)

I now recall one of my “doesn’t feel right” issues was with use<>

use<> has always had funny scope.

I replaced use<> with include<> and cmd line works the same as the GUI.

I also added (with use<>)

assign($bom=2)

test();

It shows the same inconsistency, ie $bom is echoed as 1 via cmd line, 2
via GUI.

So I suspect an issue with use<> scope and how –D is scoped.

=============I typed the below before the above===================

Looks like let()’s scope hasn’t been entirely nailed down? (edit prob.
not)

I can’t think of something that would normally differ GUI v’s cmd line,
perhaps there is a #ifdef confounding it?

As mentioned a few times the scope rules are not well documented and
particularly the $variables.

Perhaps someone(?) needs to review the codebase to document the scope
‘as-is’ state in a high level language so it can be looked at.

Every so often I come across something which doesn’t feel right, but
without the ‘what it is mean to be’ documented it is hard to know.


From: Discuss [mailto:discuss-bounces@lists.openscad.org] *On Behalf
Of *nop head
Sent: Fri, 17 Nov 2017 09:28
To: OpenSCAD general discussion
Subject: Re: [OpenSCAD] Command line $ variables

use.scad:


$bom = 0;

use <used.scad>

test();

let($bom = 0)

test();

$bom = 1;

used.scad:


use <used2.scad>

module test() {

 echo("test:", $bom = $bom);

       test2();

}

used2.scad:


module test2() {

 echo("test2:", $bom=$bom);

}

In the GUI this gives:

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

ECHO: "test:", $bom = 0

ECHO: "test2:", $bom = 0

From the command line with -D$bom=1 it gives:

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

On 16 November 2017 at 22:10, nop head nop.head@gmail.com wrote:

If I add a definition at the end of my main file it works as expected in
the GUI. It sets the variable at file scope but it can be overridden at
module scope and that is passed down the tree to other modules that can be
in other files.

Setting it on the command line instead overrides it everywhere, not just
at file scope.

Module scope should always trump file scope and I think it worked in the
past but it doesn't work with recent versions.

I will try to make a small example.

On 16 November 2017 at 21:28, OzAtMichael oz.at.michael@gmail.com
wrote:

so I override $bom to 0 before adding the vitamins. This works from

the GUI but doesn't seem to work on the command line. The command line
override seems to beat the dynamic scope override. Is this a bug?

You’ll need to show an example of where in the scope levels this is
happening. ie what is ‘adding the vitamins’ & where is the $bom=0 override?

As you know, the –D variables are just added to the tail of the source,
what happens if you do it likewise in the GUI?


From: Discuss [mailto:discuss-bounces@lists.openscad.org] *On Behalf
Of *nop head
Sent: Fri, 17 Nov 2017 01:40
To: OpenSCAD general discussion
Subject: [OpenSCAD] Command line $ variables

I use a dynamic variable to turn on and off BOM generation, which is just
echo statements.

When I use the GUI $bom = 0 so I don't have screen clutter. When I
generated a bom I set $bom on the command line and capture the echos. All
works fine.

Occasionally I have vitamins like nuts and washers that come as part of
something else, for example a toggle switch. In that case I don't want the
parts that come with it on the bom so I override $bom to 0 before adding
the vitamins. This works from the GUI but doesn't seem to work on the
command line. The command line override seems to beat the dynamic scope
override. Is this a bug?


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

Looking at the source code it does simply concatenate the -D text on the end of the main file: https://github.com/openscad/openscad/blob/master/src/openscad.cc#L402 I am therefore baffled as to how this can go wrong. On 17 November 2017 at 08:45, nop head <nop.head@gmail.com> wrote: > I upgraded to the latest Windows snapshot when after I noticed this > problem: version 2017.11.12 (git 7cb1e93). Before that I was using a > version I compiled myself. In the more distant past I think this worked as > expected because I used the technique in Mendel90. > > If the -D option just appends code to the main file don't understand how > it makes any difference at all with this test because I already set it at > the end of the file. > > It behaves as if it puts the command line stuff in a new scope that has > super powers. > > > On 17 November 2017 at 01:33, Michael Marx <michael.marx@tpg.com.au> > wrote: > >> On the other hand (see below) >> >> I now recall one of my “doesn’t feel right” issues was with use<> >> >> >> >> use<> has always had funny scope. >> >> >> >> I replaced use<> with include<> and cmd line works the same as the GUI. >> >> >> >> I also added (with use<>) >> >> >> >> assign($bom=2) >> >> test(); >> >> >> >> It shows the same inconsistency, ie $bom is echoed as 1 via cmd line, 2 >> via GUI. >> >> >> >> So I suspect an issue with use<> scope and how –D is scoped. >> >> >> >> >> >> =============I typed the below before the above=================== >> >> Looks like let()’s scope hasn’t been entirely nailed down? (edit prob. >> not) >> >> I can’t think of something that would normally differ GUI v’s cmd line, >> perhaps there is a #ifdef confounding it? >> >> >> >> >> >> As mentioned a few times the scope rules are not well documented and >> particularly the $variables. >> >> Perhaps someone(?) needs to review the codebase to document the scope >> ‘as-is’ state in a high level language so it can be looked at. >> >> Every so often I come across something which doesn’t feel right, but >> without the ‘what it is mean to be’ documented it is hard to know. >> >> >> ------------------------------ >> >> *From:* Discuss [mailto:discuss-bounces@lists.openscad.org] *On Behalf >> Of *nop head >> *Sent:* Fri, 17 Nov 2017 09:28 >> *To:* OpenSCAD general discussion >> *Subject:* Re: [OpenSCAD] Command line $ variables >> >> >> >> use.scad: >> >> ------------ >> >> $bom = 0; >> >> >> >> use <used.scad> >> >> >> >> test(); >> >> >> >> let($bom = 0) >> >> test(); >> >> >> >> $bom = 1; >> >> >> >> used.scad: >> >> -------------- >> >> use <used2.scad> >> >> >> >> module test() { >> >> echo("test:", $bom = $bom); >> >> test2(); >> >> } >> >> >> >> used2.scad: >> >> ---------------- >> >> module test2() { >> >> echo("test2:", $bom=$bom); >> >> } >> >> >> >> In the GUI this gives: >> >> ECHO: "test:", $bom = 1 >> >> ECHO: "test2:", $bom = 1 >> >> ECHO: "test:", $bom = 0 >> >> ECHO: "test2:", $bom = 0 >> >> >> >> From the command line with -D$bom=1 it gives: >> >> ECHO: "test:", $bom = 1 >> >> ECHO: "test2:", $bom = 1 >> >> ECHO: "test:", $bom = 1 >> >> ECHO: "test2:", $bom = 1 >> >> >> >> >> >> >> >> >> >> >> >> >> >> On 16 November 2017 at 22:10, nop head <nop.head@gmail.com> wrote: >> >> If I add a definition at the end of my main file it works as expected in >> the GUI. It sets the variable at file scope but it can be overridden at >> module scope and that is passed down the tree to other modules that can be >> in other files. >> >> >> >> Setting it on the command line instead overrides it everywhere, not just >> at file scope. >> >> >> >> Module scope should always trump file scope and I think it worked in the >> past but it doesn't work with recent versions. >> >> >> >> I will try to make a small example. >> >> >> >> >> >> >> >> >> >> >> >> On 16 November 2017 at 21:28, OzAtMichael <oz.at.michael@gmail.com> >> wrote: >> >> > so I override $bom to 0 before adding the vitamins. This works from >> the GUI but doesn't seem to work on the command line. The command line >> override seems to beat the dynamic scope override. Is this a bug? >> >> >> >> You’ll need to show an example of where in the scope levels this is >> happening. ie what is ‘adding the vitamins’ & where is the $bom=0 override? >> >> As you know, the –D variables are just added to the tail of the source, >> what happens if you do it likewise in the GUI? >> >> >> ------------------------------ >> >> *From:* Discuss [mailto:discuss-bounces@lists.openscad.org] *On Behalf >> Of *nop head >> *Sent:* Fri, 17 Nov 2017 01:40 >> *To:* OpenSCAD general discussion >> *Subject:* [OpenSCAD] Command line $ variables >> >> >> >> I use a dynamic variable to turn on and off BOM generation, which is just >> echo statements. >> >> >> >> When I use the GUI $bom = 0 so I don't have screen clutter. When I >> generated a bom I set $bom on the command line and capture the echos. All >> works fine. >> >> >> >> Occasionally I have vitamins like nuts and washers that come as part of >> something else, for example a toggle switch. In that case I don't want the >> parts that come with it on the bom so I override $bom to 0 before adding >> the vitamins. This works from the GUI but doesn't seem to work on the >> command line. The command line override seems to beat the dynamic scope >> override. Is this a bug? >> >> >> >> _______________________________________________ >> 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 >> >> >
MM
Michael Marx
Fri, Nov 17, 2017 12:40 PM

I have recollection of a few Git issues re special variable. So searching.

I need to reread this* without the red wine, but I think it is relevant with my rose glasses.

From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of nop head
Sent: Fri, 17 Nov 2017 20:06
To: OpenSCAD general discussion
Subject: Re: [OpenSCAD] Command line $ variables

Looking at the source code it does simply concatenate the -D text on the end of the main file:
https://github.com/openscad/openscad/blob/master/src/openscad.cc#L402

I am therefore baffled as to how this can go wrong.

On 17 November 2017 at 08:45, nop head nop.head@gmail.com wrote:

I upgraded to the latest Windows snapshot when after I noticed this problem: version 2017.11.12
(git 7cb1e93). Before that I was using a version I compiled myself. In the more distant past I
think this worked as expected because I used the technique in Mendel90.

If the -D option just appends code to the  main file don't understand how it makes any difference
at all with this test because I already set it at the end of the file.

It behaves as if it puts the command line stuff in a new scope that has super powers.

On 17 November 2017 at 01:33, Michael Marx michael.marx@tpg.com.au wrote:

On the other hand (see below)

I now recall one of my "doesn't feel right" issues was with use<>

use<> has always had funny scope.

I replaced use<> with include<> and cmd line works the same as the GUI.

I also added (with use<>)

assign($bom=2)

test();

It shows the same inconsistency, ie $bom is echoed as 1 via cmd line, 2 via GUI.

So I suspect an issue with use<> scope and how -D is scoped.

=============I typed the below before the above===================

Looks like let()'s scope hasn't been entirely nailed down? (edit prob. not)

I can't think of something that would normally differ GUI v's cmd line, perhaps there is a #ifdef
confounding it?

As mentioned a few times the scope rules are not well documented and particularly the $variables.

Perhaps someone(?) needs to review the codebase to document the scope 'as-is' state in a high level
language so it can be looked at.

Every so often I come across something which doesn't feel right, but without the 'what it is mean
to be' documented it is hard to know.


From: Discuss [mailto:discuss-bounces@lists. mailto:discuss-bounces@lists.openscad.org
openscad.org] On Behalf Of nop head
Sent: Fri, 17 Nov 2017 09:28
To: OpenSCAD general discussion
Subject: Re: [OpenSCAD] Command line $ variables

use.scad:


$bom = 0;

use <used.scad>

test();

let($bom = 0)

test();

$bom = 1;

used.scad:


use <used2.scad>

module test() {

echo("test:", $bom = $bom);

      test2();

}

used2.scad:


module test2() {

echo("test2:", $bom=$bom);

}

In the GUI this gives:

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

ECHO: "test:", $bom = 0

ECHO: "test2:", $bom = 0

From the command line with -D$bom=1 it gives:

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

On 16 November 2017 at 22:10, nop head nop.head@gmail.com wrote:

If I add a definition at the end of my main file it works as expected in the GUI. It sets the
variable at file scope but it can be overridden at module scope and that is passed down the tree to
other modules that can be in other files.

Setting it on the command line instead overrides it everywhere, not just at file scope.

Module scope should always trump file scope and I think it worked in the past but it doesn't work
with recent versions.

I will try to make a small example.

On 16 November 2017 at 21:28, OzAtMichael oz.at.michael@gmail.com wrote:

so I override $bom to 0 before adding the vitamins. This works from the GUI but doesn't seem to

work on the command line. The command line override seems to beat the dynamic scope override. Is
this a bug?

You'll need to show an example of where in the scope levels this is happening. ie what is 'adding
the vitamins' & where is the $bom=0 override?

As you know, the -D variables are just added to the tail of the source, what happens if you do it
likewise in the GUI?


From: Discuss [mailto:discuss-bounces@lists. mailto:discuss-bounces@lists.openscad.org
openscad.org] On Behalf Of nop head
Sent: Fri, 17 Nov 2017 01:40
To: OpenSCAD general discussion
Subject: [OpenSCAD] Command line $ variables

I use a dynamic variable to turn on and off BOM generation, which is just echo statements.

When I use the GUI $bom = 0 so I don't have screen clutter. When I generated a bom I set $bom on
the command line and capture the echos. All works fine.

Occasionally I have vitamins like nuts and washers that come as part of something else, for example
a toggle switch. In that case I don't want the parts that come with it on the bom so I override
$bom to 0 before adding the vitamins. This works from the GUI but doesn't seem to work on the
command line. The command line override seems to beat the dynamic scope override. Is this a bug?


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


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

I have recollection of a few Git issues re special variable. So searching. I need to reread this* without the red wine, but I think it is relevant with my rose glasses. * https://github.com/openscad/openscad/issues/1968 _____ From: Discuss [mailto:discuss-bounces@lists.openscad.org] On Behalf Of nop head Sent: Fri, 17 Nov 2017 20:06 To: OpenSCAD general discussion Subject: Re: [OpenSCAD] Command line $ variables Looking at the source code it does simply concatenate the -D text on the end of the main file: https://github.com/openscad/openscad/blob/master/src/openscad.cc#L402 I am therefore baffled as to how this can go wrong. On 17 November 2017 at 08:45, nop head <nop.head@gmail.com> wrote: I upgraded to the latest Windows snapshot when after I noticed this problem: version 2017.11.12 (git 7cb1e93). Before that I was using a version I compiled myself. In the more distant past I think this worked as expected because I used the technique in Mendel90. If the -D option just appends code to the main file don't understand how it makes any difference at all with this test because I already set it at the end of the file. It behaves as if it puts the command line stuff in a new scope that has super powers. On 17 November 2017 at 01:33, Michael Marx <michael.marx@tpg.com.au> wrote: On the other hand (see below) I now recall one of my "doesn't feel right" issues was with use<> use<> has always had funny scope. I replaced use<> with include<> and cmd line works the same as the GUI. I also added (with use<>) assign($bom=2) test(); It shows the same inconsistency, ie $bom is echoed as 1 via cmd line, 2 via GUI. So I suspect an issue with use<> scope and how -D is scoped. =============I typed the below before the above=================== Looks like let()'s scope hasn't been entirely nailed down? (edit prob. not) I can't think of something that would normally differ GUI v's cmd line, perhaps there is a #ifdef confounding it? As mentioned a few times the scope rules are not well documented and particularly the $variables. Perhaps someone(?) needs to review the codebase to document the scope 'as-is' state in a high level language so it can be looked at. Every so often I come across something which doesn't feel right, but without the 'what it is mean to be' documented it is hard to know. _____ From: Discuss [mailto:discuss-bounces@lists. <mailto:discuss-bounces@lists.openscad.org> openscad.org] On Behalf Of nop head Sent: Fri, 17 Nov 2017 09:28 To: OpenSCAD general discussion Subject: Re: [OpenSCAD] Command line $ variables use.scad: ------------ $bom = 0; use <used.scad> test(); let($bom = 0) test(); $bom = 1; used.scad: -------------- use <used2.scad> module test() { echo("test:", $bom = $bom); test2(); } used2.scad: ---------------- module test2() { echo("test2:", $bom=$bom); } In the GUI this gives: ECHO: "test:", $bom = 1 ECHO: "test2:", $bom = 1 ECHO: "test:", $bom = 0 ECHO: "test2:", $bom = 0 >From the command line with -D$bom=1 it gives: ECHO: "test:", $bom = 1 ECHO: "test2:", $bom = 1 ECHO: "test:", $bom = 1 ECHO: "test2:", $bom = 1 On 16 November 2017 at 22:10, nop head <nop.head@gmail.com> wrote: If I add a definition at the end of my main file it works as expected in the GUI. It sets the variable at file scope but it can be overridden at module scope and that is passed down the tree to other modules that can be in other files. Setting it on the command line instead overrides it everywhere, not just at file scope. Module scope should always trump file scope and I think it worked in the past but it doesn't work with recent versions. I will try to make a small example. On 16 November 2017 at 21:28, OzAtMichael <oz.at.michael@gmail.com> wrote: > so I override $bom to 0 before adding the vitamins. This works from the GUI but doesn't seem to work on the command line. The command line override seems to beat the dynamic scope override. Is this a bug? You'll need to show an example of where in the scope levels this is happening. ie what is 'adding the vitamins' & where is the $bom=0 override? As you know, the -D variables are just added to the tail of the source, what happens if you do it likewise in the GUI? _____ From: Discuss [mailto:discuss-bounces@lists. <mailto:discuss-bounces@lists.openscad.org> openscad.org] On Behalf Of nop head Sent: Fri, 17 Nov 2017 01:40 To: OpenSCAD general discussion Subject: [OpenSCAD] Command line $ variables I use a dynamic variable to turn on and off BOM generation, which is just echo statements. When I use the GUI $bom = 0 so I don't have screen clutter. When I generated a bom I set $bom on the command line and capture the echos. All works fine. Occasionally I have vitamins like nuts and washers that come as part of something else, for example a toggle switch. In that case I don't want the parts that come with it on the bom so I override $bom to 0 before adding the vitamins. This works from the GUI but doesn't seem to work on the command line. The command line override seems to beat the dynamic scope override. Is this a bug? _______________________________________________ OpenSCAD mailing list Discuss@lists.openscad.org http://lists.openscad.org/mail <http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org> man/listinfo/discuss_lists.openscad.org _______________________________________________ OpenSCAD mailing list Discuss@lists.openscad.org http://lists.openscad.org/mail <http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org> man/listinfo/discuss_lists.openscad.org
NH
nop head
Fri, Nov 17, 2017 1:19 PM

I think this is a different bug. Namely setting a special variable with -D
has a different effect to setting the same variable at the end of the main
file. Since -D just adds to the end of the main file the effect should be
identical.

I have looked at the code and can't explain how this happens.

On 17 November 2017 at 12:40, Michael Marx michael.marx@tpg.com.au wrote:

I have recollection of a few Git issues re special variable. So searching…

I need to reread this* without the red wine, but I think it is relevant
with my rose glasses…


From: Discuss [mailto:discuss-bounces@lists.openscad.org] *On Behalf Of
*nop head
Sent: Fri, 17 Nov 2017 20:06

To: OpenSCAD general discussion
Subject: Re: [OpenSCAD] Command line $ variables

Looking at the source code it does simply concatenate the -D text on the
end of the main file: https://github.com/openscad/openscad/blob/master/
src/openscad.cc#L402

I am therefore baffled as to how this can go wrong.

On 17 November 2017 at 08:45, nop head nop.head@gmail.com wrote:

I upgraded to the latest Windows snapshot when after I noticed this
problem: version 2017.11.12 (git 7cb1e93). Before that I was using a
version I compiled myself. In the more distant past I think this worked as
expected because I used the technique in Mendel90.

If the -D option just appends code to the  main file don't understand how
it makes any difference at all with this test because I already set it at
the end of the file.

It behaves as if it puts the command line stuff in a new scope that has
super powers.

On 17 November 2017 at 01:33, Michael Marx michael.marx@tpg.com.au
wrote:

On the other hand (see below)

I now recall one of my “doesn’t feel right” issues was with use<>

use<> has always had funny scope.

I replaced use<> with include<> and cmd line works the same as the GUI.

I also added (with use<>)

assign($bom=2)

test();

It shows the same inconsistency, ie $bom is echoed as 1 via cmd line, 2
via GUI.

So I suspect an issue with use<> scope and how –D is scoped.

=============I typed the below before the above===================

Looks like let()’s scope hasn’t been entirely nailed down? (edit prob. not)

I can’t think of something that would normally differ GUI v’s cmd line,
perhaps there is a #ifdef confounding it?

As mentioned a few times the scope rules are not well documented and
particularly the $variables.

Perhaps someone(?) needs to review the codebase to document the scope
‘as-is’ state in a high level language so it can be looked at.

Every so often I come across something which doesn’t feel right, but
without the ‘what it is mean to be’ documented it is hard to know.


From: Discuss [mailto:discuss-bounces@lists.openscad.org] *On Behalf Of
*nop head
Sent: Fri, 17 Nov 2017 09:28
To: OpenSCAD general discussion
Subject: Re: [OpenSCAD] Command line $ variables

use.scad:


$bom = 0;

use <used.scad>

test();

let($bom = 0)

test();

$bom = 1;

used.scad:


use <used2.scad>

module test() {

 echo("test:", $bom = $bom);

       test2();

}

used2.scad:


module test2() {

 echo("test2:", $bom=$bom);

}

In the GUI this gives:

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

ECHO: "test:", $bom = 0

ECHO: "test2:", $bom = 0

From the command line with -D$bom=1 it gives:

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

ECHO: "test:", $bom = 1

ECHO: "test2:", $bom = 1

On 16 November 2017 at 22:10, nop head nop.head@gmail.com wrote:

If I add a definition at the end of my main file it works as expected in
the GUI. It sets the variable at file scope but it can be overridden at
module scope and that is passed down the tree to other modules that can be
in other files.

Setting it on the command line instead overrides it everywhere, not just
at file scope.

Module scope should always trump file scope and I think it worked in the
past but it doesn't work with recent versions.

I will try to make a small example.

On 16 November 2017 at 21:28, OzAtMichael oz.at.michael@gmail.com wrote:

so I override $bom to 0 before adding the vitamins. This works from the

GUI but doesn't seem to work on the command line. The command line override
seems to beat the dynamic scope override. Is this a bug?

You’ll need to show an example of where in the scope levels this is
happening. ie what is ‘adding the vitamins’ & where is the $bom=0 override?

As you know, the –D variables are just added to the tail of the source,
what happens if you do it likewise in the GUI?


From: Discuss [mailto:discuss-bounces@lists.openscad.org] *On Behalf Of
*nop head
Sent: Fri, 17 Nov 2017 01:40
To: OpenSCAD general discussion
Subject: [OpenSCAD] Command line $ variables

I use a dynamic variable to turn on and off BOM generation, which is just
echo statements.

When I use the GUI $bom = 0 so I don't have screen clutter. When I
generated a bom I set $bom on the command line and capture the echos. All
works fine.

Occasionally I have vitamins like nuts and washers that come as part of
something else, for example a toggle switch. In that case I don't want the
parts that come with it on the bom so I override $bom to 0 before adding
the vitamins. This works from the GUI but doesn't seem to work on the
command line. The command line override seems to beat the dynamic scope
override. Is this a bug?


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


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

I think this is a different bug. Namely setting a special variable with -D has a different effect to setting the same variable at the end of the main file. Since -D just adds to the end of the main file the effect should be identical. I have looked at the code and can't explain how this happens. On 17 November 2017 at 12:40, Michael Marx <michael.marx@tpg.com.au> wrote: > I have recollection of a few Git issues re special variable. So searching… > > > > I need to reread this* without the red wine, but I think it is relevant > with my rose glasses… > > > > * https://github.com/openscad/openscad/issues/1968 > > > ------------------------------ > > *From:* Discuss [mailto:discuss-bounces@lists.openscad.org] *On Behalf Of > *nop head > *Sent:* Fri, 17 Nov 2017 20:06 > > *To:* OpenSCAD general discussion > *Subject:* Re: [OpenSCAD] Command line $ variables > > > > Looking at the source code it does simply concatenate the -D text on the > end of the main file: https://github.com/openscad/openscad/blob/master/ > src/openscad.cc#L402 > > > > I am therefore baffled as to how this can go wrong. > > > > On 17 November 2017 at 08:45, nop head <nop.head@gmail.com> wrote: > > I upgraded to the latest Windows snapshot when after I noticed this > problem: version 2017.11.12 (git 7cb1e93). Before that I was using a > version I compiled myself. In the more distant past I think this worked as > expected because I used the technique in Mendel90. > > > > If the -D option just appends code to the main file don't understand how > it makes any difference at all with this test because I already set it at > the end of the file. > > > > It behaves as if it puts the command line stuff in a new scope that has > super powers. > > > > > > On 17 November 2017 at 01:33, Michael Marx <michael.marx@tpg.com.au> > wrote: > > On the other hand (see below) > > I now recall one of my “doesn’t feel right” issues was with use<> > > > > use<> has always had funny scope. > > > > I replaced use<> with include<> and cmd line works the same as the GUI. > > > > I also added (with use<>) > > > > assign($bom=2) > > test(); > > > > It shows the same inconsistency, ie $bom is echoed as 1 via cmd line, 2 > via GUI. > > > > So I suspect an issue with use<> scope and how –D is scoped. > > > > > > =============I typed the below before the above=================== > > Looks like let()’s scope hasn’t been entirely nailed down? (edit prob. not) > > I can’t think of something that would normally differ GUI v’s cmd line, > perhaps there is a #ifdef confounding it? > > > > > > As mentioned a few times the scope rules are not well documented and > particularly the $variables. > > Perhaps someone(?) needs to review the codebase to document the scope > ‘as-is’ state in a high level language so it can be looked at. > > Every so often I come across something which doesn’t feel right, but > without the ‘what it is mean to be’ documented it is hard to know. > > > ------------------------------ > > *From:* Discuss [mailto:discuss-bounces@lists.openscad.org] *On Behalf Of > *nop head > *Sent:* Fri, 17 Nov 2017 09:28 > *To:* OpenSCAD general discussion > *Subject:* Re: [OpenSCAD] Command line $ variables > > > > use.scad: > > ------------ > > $bom = 0; > > > > use <used.scad> > > > > test(); > > > > let($bom = 0) > > test(); > > > > $bom = 1; > > > > used.scad: > > -------------- > > use <used2.scad> > > > > module test() { > > echo("test:", $bom = $bom); > > test2(); > > } > > > > used2.scad: > > ---------------- > > module test2() { > > echo("test2:", $bom=$bom); > > } > > > > In the GUI this gives: > > ECHO: "test:", $bom = 1 > > ECHO: "test2:", $bom = 1 > > ECHO: "test:", $bom = 0 > > ECHO: "test2:", $bom = 0 > > > > From the command line with -D$bom=1 it gives: > > ECHO: "test:", $bom = 1 > > ECHO: "test2:", $bom = 1 > > ECHO: "test:", $bom = 1 > > ECHO: "test2:", $bom = 1 > > > > > > > > > > > > > > On 16 November 2017 at 22:10, nop head <nop.head@gmail.com> wrote: > > If I add a definition at the end of my main file it works as expected in > the GUI. It sets the variable at file scope but it can be overridden at > module scope and that is passed down the tree to other modules that can be > in other files. > > > > Setting it on the command line instead overrides it everywhere, not just > at file scope. > > > > Module scope should always trump file scope and I think it worked in the > past but it doesn't work with recent versions. > > > > I will try to make a small example. > > > > > > > > > > > > On 16 November 2017 at 21:28, OzAtMichael <oz.at.michael@gmail.com> wrote: > > > so I override $bom to 0 before adding the vitamins. This works from the > GUI but doesn't seem to work on the command line. The command line override > seems to beat the dynamic scope override. Is this a bug? > > > > You’ll need to show an example of where in the scope levels this is > happening. ie what is ‘adding the vitamins’ & where is the $bom=0 override? > > As you know, the –D variables are just added to the tail of the source, > what happens if you do it likewise in the GUI? > > > ------------------------------ > > *From:* Discuss [mailto:discuss-bounces@lists.openscad.org] *On Behalf Of > *nop head > *Sent:* Fri, 17 Nov 2017 01:40 > *To:* OpenSCAD general discussion > *Subject:* [OpenSCAD] Command line $ variables > > > > I use a dynamic variable to turn on and off BOM generation, which is just > echo statements. > > > > When I use the GUI $bom = 0 so I don't have screen clutter. When I > generated a bom I set $bom on the command line and capture the echos. All > works fine. > > > > Occasionally I have vitamins like nuts and washers that come as part of > something else, for example a toggle switch. In that case I don't want the > parts that come with it on the bom so I override $bom to 0 before adding > the vitamins. This works from the GUI but doesn't seem to work on the > command line. The command line override seems to beat the dynamic scope > override. Is this a bug? > > > > _______________________________________________ > 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 > > > > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org > >