discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Name resolution different on different PCs.

NH
nop head
Sun, Jan 19, 2020 1:13 PM

I think this shows a bug:

file1.scad:
module m1(){echo("file1 m1");}
module m2(){echo("file1 m2");}

file2.scad:
use <file1.scad>
module m1() { echo("file2 m1"); }

file3.scad:
use <file1.scad>
module m2() { echo("file3 m2"); }

main.scad:
use <file1.scad>
use <file2.scad>
use <file3.scad>
m1();
m2();

ECHO: "file1 m1"

ECHO: "file3 m2"

I think m1 should come from file2.scad and it does if I comment out
use<file1.scad> from main.

On Fri, 17 Jan 2020 at 16:26, nop head nop.head@gmail.com wrote:

I use "use" to mean use<> and "include" to mean include<>.

Unfortunately my code is far too big to post as it is a 3D printer made
from hundreds of files and so far I haven't managed to distil a small
example .

I don't fully understand the paragraph you quoted but it sounds like it
might be relevant but still doesn't explain why two PCs give different
results with the same code.

On Fri, 17 Jan 2020 at 11:20, MichaelAtOz oz.at.michael@gmail.com wrote:

It would help if you utilised 'use<>', 'include<>' when you refer to
syntax
v's generic use or include as normal words. A compact example would help.

Without the code, I can't visualise what you are doing.

I also note the wiki mentions:
Nested Include and Use
OpenSCAD will execute nested calls to include and use. There is one caveat
to this, that use only brings functions and modules into the local file
context. As a result, nested calls to use will have no effect on the
environment of the base file; the child use call will work in the parent
use
context, but the modules and functions so imported will fall out of
context
before they are seen by the base context.


Admin - email* me if you need anything,  or if I've done something
stupid...

  • click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the
Public Domain; to the extent possible under law, I have waived all
copyright and related or neighbouring rights to this work. Obviously
inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/


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

I think this shows a bug: file1.scad: module m1(){echo("file1 m1");} module m2(){echo("file1 m2");} file2.scad: use <file1.scad> module m1() { echo("file2 m1"); } file3.scad: use <file1.scad> module m2() { echo("file3 m2"); } main.scad: use <file1.scad> use <file2.scad> use <file3.scad> m1(); m2(); ECHO: "file1 m1" ECHO: "file3 m2" I think m1 should come from file2.scad and it does if I comment out use<file1.scad> from main. On Fri, 17 Jan 2020 at 16:26, nop head <nop.head@gmail.com> wrote: > I use "use" to mean use<> and "include" to mean include<>. > > Unfortunately my code is far too big to post as it is a 3D printer made > from hundreds of files and so far I haven't managed to distil a small > example . > > I don't fully understand the paragraph you quoted but it sounds like it > might be relevant but still doesn't explain why two PCs give different > results with the same code. > > On Fri, 17 Jan 2020 at 11:20, MichaelAtOz <oz.at.michael@gmail.com> wrote: > >> It would help if you utilised 'use<>', 'include<>' when you refer to >> syntax >> v's generic use or include as normal words. A compact example would help. >> >> Without the code, I can't visualise what you are doing. >> >> I also note the wiki mentions: >> Nested Include and Use >> OpenSCAD will execute nested calls to include and use. There is one caveat >> to this, that use only brings functions and modules into the local file >> context. As a result, nested calls to use will have no effect on the >> environment of the base file; the child use call will work in the parent >> use >> context, but the modules and functions so imported will fall out of >> context >> before they are seen by the base context. >> >> >> >> ----- >> Admin - email* me if you need anything, or if I've done something >> stupid... >> >> * click on my MichaelAtOz label, there is a link to email me. >> >> Unless specifically shown otherwise above, my contribution is in the >> Public Domain; to the extent possible under law, I have waived all >> copyright and related or neighbouring rights to this work. Obviously >> inclusion of works of previous authors is not included in the above. >> >> -- >> Sent from: http://forum.openscad.org/ >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >
NH
nop head
Sun, Jan 19, 2020 1:28 PM

If I swap the order of uses:
use <file1.scad>
use <file3.scad>
use <file2.scad>
m1();
m2();

I get:

ECHO: "file2 m1"

ECHO: "file1 m2"

So this time m2 is wrong. Why does changing the order make a difference?

On Sun, 19 Jan 2020 at 13:13, nop head nop.head@gmail.com wrote:

I think this shows a bug:

file1.scad:
module m1(){echo("file1 m1");}
module m2(){echo("file1 m2");}

file2.scad:
use <file1.scad>
module m1() { echo("file2 m1"); }

file3.scad:
use <file1.scad>
module m2() { echo("file3 m2"); }

main.scad:
use <file1.scad>
use <file2.scad>
use <file3.scad>
m1();
m2();

ECHO: "file1 m1"

ECHO: "file3 m2"

I think m1 should come from file2.scad and it does if I comment out
use<file1.scad> from main.

On Fri, 17 Jan 2020 at 16:26, nop head nop.head@gmail.com wrote:

I use "use" to mean use<> and "include" to mean include<>.

Unfortunately my code is far too big to post as it is a 3D printer made
from hundreds of files and so far I haven't managed to distil a small
example .

I don't fully understand the paragraph you quoted but it sounds like it
might be relevant but still doesn't explain why two PCs give different
results with the same code.

On Fri, 17 Jan 2020 at 11:20, MichaelAtOz oz.at.michael@gmail.com
wrote:

It would help if you utilised 'use<>', 'include<>' when you refer to
syntax
v's generic use or include as normal words. A compact example would help.

Without the code, I can't visualise what you are doing.

I also note the wiki mentions:
Nested Include and Use
OpenSCAD will execute nested calls to include and use. There is one
caveat
to this, that use only brings functions and modules into the local file
context. As a result, nested calls to use will have no effect on the
environment of the base file; the child use call will work in the parent
use
context, but the modules and functions so imported will fall out of
context
before they are seen by the base context.


Admin - email* me if you need anything,  or if I've done something
stupid...

  • click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the
Public Domain; to the extent possible under law, I have waived all
copyright and related or neighbouring rights to this work. Obviously
inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/


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

If I swap the order of uses: use <file1.scad> use <file3.scad> use <file2.scad> m1(); m2(); I get: ECHO: "file2 m1" ECHO: "file1 m2" So this time m2 is wrong. Why does changing the order make a difference? On Sun, 19 Jan 2020 at 13:13, nop head <nop.head@gmail.com> wrote: > I think this shows a bug: > > file1.scad: > module m1(){echo("file1 m1");} > module m2(){echo("file1 m2");} > > file2.scad: > use <file1.scad> > module m1() { echo("file2 m1"); } > > file3.scad: > use <file1.scad> > module m2() { echo("file3 m2"); } > > main.scad: > use <file1.scad> > use <file2.scad> > use <file3.scad> > m1(); > m2(); > > ECHO: "file1 m1" > > ECHO: "file3 m2" > > > I think m1 should come from file2.scad and it does if I comment out > use<file1.scad> from main. > > > On Fri, 17 Jan 2020 at 16:26, nop head <nop.head@gmail.com> wrote: > >> I use "use" to mean use<> and "include" to mean include<>. >> >> Unfortunately my code is far too big to post as it is a 3D printer made >> from hundreds of files and so far I haven't managed to distil a small >> example . >> >> I don't fully understand the paragraph you quoted but it sounds like it >> might be relevant but still doesn't explain why two PCs give different >> results with the same code. >> >> On Fri, 17 Jan 2020 at 11:20, MichaelAtOz <oz.at.michael@gmail.com> >> wrote: >> >>> It would help if you utilised 'use<>', 'include<>' when you refer to >>> syntax >>> v's generic use or include as normal words. A compact example would help. >>> >>> Without the code, I can't visualise what you are doing. >>> >>> I also note the wiki mentions: >>> Nested Include and Use >>> OpenSCAD will execute nested calls to include and use. There is one >>> caveat >>> to this, that use only brings functions and modules into the local file >>> context. As a result, nested calls to use will have no effect on the >>> environment of the base file; the child use call will work in the parent >>> use >>> context, but the modules and functions so imported will fall out of >>> context >>> before they are seen by the base context. >>> >>> >>> >>> ----- >>> Admin - email* me if you need anything, or if I've done something >>> stupid... >>> >>> * click on my MichaelAtOz label, there is a link to email me. >>> >>> Unless specifically shown otherwise above, my contribution is in the >>> Public Domain; to the extent possible under law, I have waived all >>> copyright and related or neighbouring rights to this work. Obviously >>> inclusion of works of previous authors is not included in the above. >>> >>> -- >>> Sent from: http://forum.openscad.org/ >>> >>> _______________________________________________ >>> OpenSCAD mailing list >>> Discuss@lists.openscad.org >>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >>> >>
MK
Marius Kintel
Sun, Jan 19, 2020 9:16 PM

It looks like it simply uses the last seen definition. In that regard, use<> and include<> would probably yield the same result.
Use<> imports functions and modules into its scope, so indirect use<> would let all these bubble up.

Whether this is good behaviour or not is a different discussion.
Do you feel that this behaviour has changed recently?

-Marius

On Jan 19, 2020, at 08:13, nop head nop.head@gmail.com wrote:

I think this shows a bug:

file1.scad:
module m1(){echo("file1 m1");}
module m2(){echo("file1 m2");}

file2.scad:
use <file1.scad>
module m1() { echo("file2 m1"); }

file3.scad:
use <file1.scad>
module m2() { echo("file3 m2"); }

main.scad:
use <file1.scad>
use <file2.scad>
use <file3.scad>
m1();
m2();

ECHO: "file1 m1"
ECHO: "file3 m2"

I think m1 should come from file2.scad and it does if I comment out use<file1.scad> from main.

On Fri, 17 Jan 2020 at 16:26, nop head <nop.head@gmail.com mailto:nop.head@gmail.com> wrote:
I use "use" to mean use<> and "include" to mean include<>.

Unfortunately my code is far too big to post as it is a 3D printer made from hundreds of files and so far I haven't managed to distil a small example .

I don't fully understand the paragraph you quoted but it sounds like it might be relevant but still doesn't explain why two PCs give different results with the same code.

On Fri, 17 Jan 2020 at 11:20, MichaelAtOz <oz.at.michael@gmail.com mailto:oz.at.michael@gmail.com> wrote:
It would help if you utilised 'use<>', 'include<>' when you refer to syntax
v's generic use or include as normal words. A compact example would help.

Without the code, I can't visualise what you are doing.

I also note the wiki mentions:
Nested Include and Use
OpenSCAD will execute nested calls to include and use. There is one caveat
to this, that use only brings functions and modules into the local file
context. As a result, nested calls to use will have no effect on the
environment of the base file; the child use call will work in the parent use
context, but the modules and functions so imported will fall out of context
before they are seen by the base context.


Admin - email* me if you need anything,  or if I've done something stupid...

  • click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/ http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org mailto:Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/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

It looks like it simply uses the last seen definition. In that regard, use<> and include<> would probably yield the same result. Use<> imports functions and modules into its scope, so indirect use<> would let all these bubble up. Whether this is good behaviour or not is a different discussion. Do you feel that this behaviour has changed recently? -Marius > On Jan 19, 2020, at 08:13, nop head <nop.head@gmail.com> wrote: > > I think this shows a bug: > > file1.scad: > module m1(){echo("file1 m1");} > module m2(){echo("file1 m2");} > > file2.scad: > use <file1.scad> > module m1() { echo("file2 m1"); } > > file3.scad: > use <file1.scad> > module m2() { echo("file3 m2"); } > > main.scad: > use <file1.scad> > use <file2.scad> > use <file3.scad> > m1(); > m2(); > > ECHO: "file1 m1" > ECHO: "file3 m2" > > I think m1 should come from file2.scad and it does if I comment out use<file1.scad> from main. > > > On Fri, 17 Jan 2020 at 16:26, nop head <nop.head@gmail.com <mailto:nop.head@gmail.com>> wrote: > I use "use" to mean use<> and "include" to mean include<>. > > Unfortunately my code is far too big to post as it is a 3D printer made from hundreds of files and so far I haven't managed to distil a small example . > > I don't fully understand the paragraph you quoted but it sounds like it might be relevant but still doesn't explain why two PCs give different results with the same code. > > On Fri, 17 Jan 2020 at 11:20, MichaelAtOz <oz.at.michael@gmail.com <mailto:oz.at.michael@gmail.com>> wrote: > It would help if you utilised 'use<>', 'include<>' when you refer to syntax > v's generic use or include as normal words. A compact example would help. > > Without the code, I can't visualise what you are doing. > > I also note the wiki mentions: > Nested Include and Use > OpenSCAD will execute nested calls to include and use. There is one caveat > to this, that use only brings functions and modules into the local file > context. As a result, nested calls to use will have no effect on the > environment of the base file; the child use call will work in the parent use > context, but the modules and functions so imported will fall out of context > before they are seen by the base context. > > > > ----- > Admin - email* me if you need anything, or if I've done something stupid... > > * click on my MichaelAtOz label, there is a link to email me. > > Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. > > -- > Sent from: http://forum.openscad.org/ <http://forum.openscad.org/> > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org <mailto:Discuss@lists.openscad.org> > http://lists.openscad.org/mailman/listinfo/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
Sun, Jan 19, 2020 9:24 PM

It should use the last definition but it doesn't. Names from indirect used
files should not be visible.

I don't know if behaviour has changed. All I know is that it behaves
differently on two machines and on the machine I have access to ATM it is
wrong.

On Sun, 19 Jan 2020, 21:17 Marius Kintel, kintel@kintel.net wrote:

It looks like it simply uses the last seen definition. In that regard,
use<> and include<> would probably yield the same result.
Use<> imports functions and modules into its scope, so indirect use<>
would let all these bubble up.

Whether this is good behaviour or not is a different discussion.
Do you feel that this behaviour has changed recently?

-Marius

On Jan 19, 2020, at 08:13, nop head nop.head@gmail.com wrote:

I think this shows a bug:

file1.scad:
module m1(){echo("file1 m1");}
module m2(){echo("file1 m2");}

file2.scad:
use <file1.scad>
module m1() { echo("file2 m1"); }

file3.scad:
use <file1.scad>
module m2() { echo("file3 m2"); }

main.scad:
use <file1.scad>
use <file2.scad>
use <file3.scad>
m1();
m2();

ECHO: "file1 m1"
ECHO: "file3 m2"

I think m1 should come from file2.scad and it does if I comment out
use<file1.scad> from main.

On Fri, 17 Jan 2020 at 16:26, nop head nop.head@gmail.com wrote:

I use "use" to mean use<> and "include" to mean include<>.

Unfortunately my code is far too big to post as it is a 3D printer made
from hundreds of files and so far I haven't managed to distil a small
example .

I don't fully understand the paragraph you quoted but it sounds like it
might be relevant but still doesn't explain why two PCs give different
results with the same code.

On Fri, 17 Jan 2020 at 11:20, MichaelAtOz oz.at.michael@gmail.com
wrote:

It would help if you utilised 'use<>', 'include<>' when you refer to
syntax
v's generic use or include as normal words. A compact example would help.

Without the code, I can't visualise what you are doing.

I also note the wiki mentions:
Nested Include and Use
OpenSCAD will execute nested calls to include and use. There is one
caveat
to this, that use only brings functions and modules into the local file
context. As a result, nested calls to use will have no effect on the
environment of the base file; the child use call will work in the parent
use
context, but the modules and functions so imported will fall out of
context
before they are seen by the base context.


Admin - email* me if you need anything,  or if I've done something
stupid...

  • click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the
Public Domain; to the extent possible under law, I have waived all
copyright and related or neighbouring rights to this work. Obviously
inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/


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


It should use the last definition but it doesn't. Names from indirect used files should not be visible. I don't know if behaviour has changed. All I know is that it behaves differently on two machines and on the machine I have access to ATM it is wrong. On Sun, 19 Jan 2020, 21:17 Marius Kintel, <kintel@kintel.net> wrote: > It looks like it simply uses the last seen definition. In that regard, > use<> and include<> would probably yield the same result. > Use<> imports functions and modules into its scope, so indirect use<> > would let all these bubble up. > > Whether this is good behaviour or not is a different discussion. > Do you feel that this behaviour has changed recently? > > -Marius > > On Jan 19, 2020, at 08:13, nop head <nop.head@gmail.com> wrote: > > I think this shows a bug: > > file1.scad: > module m1(){echo("file1 m1");} > module m2(){echo("file1 m2");} > > file2.scad: > use <file1.scad> > module m1() { echo("file2 m1"); } > > file3.scad: > use <file1.scad> > module m2() { echo("file3 m2"); } > > main.scad: > use <file1.scad> > use <file2.scad> > use <file3.scad> > m1(); > m2(); > > ECHO: "file1 m1" > ECHO: "file3 m2" > > I think m1 should come from file2.scad and it does if I comment out > use<file1.scad> from main. > > > On Fri, 17 Jan 2020 at 16:26, nop head <nop.head@gmail.com> wrote: > >> I use "use" to mean use<> and "include" to mean include<>. >> >> Unfortunately my code is far too big to post as it is a 3D printer made >> from hundreds of files and so far I haven't managed to distil a small >> example . >> >> I don't fully understand the paragraph you quoted but it sounds like it >> might be relevant but still doesn't explain why two PCs give different >> results with the same code. >> >> On Fri, 17 Jan 2020 at 11:20, MichaelAtOz <oz.at.michael@gmail.com> >> wrote: >> >>> It would help if you utilised 'use<>', 'include<>' when you refer to >>> syntax >>> v's generic use or include as normal words. A compact example would help. >>> >>> Without the code, I can't visualise what you are doing. >>> >>> I also note the wiki mentions: >>> Nested Include and Use >>> OpenSCAD will execute nested calls to include and use. There is one >>> caveat >>> to this, that use only brings functions and modules into the local file >>> context. As a result, nested calls to use will have no effect on the >>> environment of the base file; the child use call will work in the parent >>> use >>> context, but the modules and functions so imported will fall out of >>> context >>> before they are seen by the base context. >>> >>> >>> >>> ----- >>> Admin - email* me if you need anything, or if I've done something >>> stupid... >>> >>> * click on my MichaelAtOz label, there is a link to email me. >>> >>> Unless specifically shown otherwise above, my contribution is in the >>> Public Domain; to the extent possible under law, I have waived all >>> copyright and related or neighbouring rights to this work. Obviously >>> inclusion of works of previous authors is not included in the above. >>> >>> -- >>> Sent from: http://forum.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 > > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
NH
nop head
Sun, Jan 19, 2020 11:06 PM

file1 defines default implementations for m1 and m2.

file2 defines m1 and file3 defines m2. Since they are both used after file1
then both m1 and m2 should be overridden but only one is.

Both file2 and file3 use file1 but any names in file1 should not be
exported from file2 or file3.

I appears perhaps the use of file1 is leaked from file2 and file3 but if
file1 is not included in main then they don't.

So something weird is going wrong and is seems to be machine dependent but
as I only have access to one machine at a time it is hard to prove that.

On Sun, 19 Jan 2020 at 21:24, nop head nop.head@gmail.com wrote:

It should use the last definition but it doesn't. Names from indirect used
files should not be visible.

I don't know if behaviour has changed. All I know is that it behaves
differently on two machines and on the machine I have access to ATM it is
wrong.

On Sun, 19 Jan 2020, 21:17 Marius Kintel, kintel@kintel.net wrote:

It looks like it simply uses the last seen definition. In that regard,
use<> and include<> would probably yield the same result.
Use<> imports functions and modules into its scope, so indirect use<>
would let all these bubble up.

Whether this is good behaviour or not is a different discussion.
Do you feel that this behaviour has changed recently?

-Marius

On Jan 19, 2020, at 08:13, nop head nop.head@gmail.com wrote:

I think this shows a bug:

file1.scad:
module m1(){echo("file1 m1");}
module m2(){echo("file1 m2");}

file2.scad:
use <file1.scad>
module m1() { echo("file2 m1"); }

file3.scad:
use <file1.scad>
module m2() { echo("file3 m2"); }

main.scad:
use <file1.scad>
use <file2.scad>
use <file3.scad>
m1();
m2();

ECHO: "file1 m1"
ECHO: "file3 m2"

I think m1 should come from file2.scad and it does if I comment out
use<file1.scad> from main.

On Fri, 17 Jan 2020 at 16:26, nop head nop.head@gmail.com wrote:

I use "use" to mean use<> and "include" to mean include<>.

Unfortunately my code is far too big to post as it is a 3D printer made
from hundreds of files and so far I haven't managed to distil a small
example .

I don't fully understand the paragraph you quoted but it sounds like it
might be relevant but still doesn't explain why two PCs give different
results with the same code.

On Fri, 17 Jan 2020 at 11:20, MichaelAtOz oz.at.michael@gmail.com
wrote:

It would help if you utilised 'use<>', 'include<>' when you refer to
syntax
v's generic use or include as normal words. A compact example would
help.

Without the code, I can't visualise what you are doing.

I also note the wiki mentions:
Nested Include and Use
OpenSCAD will execute nested calls to include and use. There is one
caveat
to this, that use only brings functions and modules into the local file
context. As a result, nested calls to use will have no effect on the
environment of the base file; the child use call will work in the
parent use
context, but the modules and functions so imported will fall out of
context
before they are seen by the base context.


Admin - email* me if you need anything,  or if I've done something
stupid...

  • click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the
Public Domain; to the extent possible under law, I have waived all
copyright and related or neighbouring rights to this work. Obviously
inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/


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


file1 defines default implementations for m1 and m2. file2 defines m1 and file3 defines m2. Since they are both used after file1 then both m1 and m2 should be overridden but only one is. Both file2 and file3 use file1 but any names in file1 should not be exported from file2 or file3. I appears perhaps the use of file1 is leaked from file2 and file3 but if file1 is not included in main then they don't. So something weird is going wrong and is seems to be machine dependent but as I only have access to one machine at a time it is hard to prove that. On Sun, 19 Jan 2020 at 21:24, nop head <nop.head@gmail.com> wrote: > It should use the last definition but it doesn't. Names from indirect used > files should not be visible. > > I don't know if behaviour has changed. All I know is that it behaves > differently on two machines and on the machine I have access to ATM it is > wrong. > > On Sun, 19 Jan 2020, 21:17 Marius Kintel, <kintel@kintel.net> wrote: > >> It looks like it simply uses the last seen definition. In that regard, >> use<> and include<> would probably yield the same result. >> Use<> imports functions and modules into its scope, so indirect use<> >> would let all these bubble up. >> >> Whether this is good behaviour or not is a different discussion. >> Do you feel that this behaviour has changed recently? >> >> -Marius >> >> On Jan 19, 2020, at 08:13, nop head <nop.head@gmail.com> wrote: >> >> I think this shows a bug: >> >> file1.scad: >> module m1(){echo("file1 m1");} >> module m2(){echo("file1 m2");} >> >> file2.scad: >> use <file1.scad> >> module m1() { echo("file2 m1"); } >> >> file3.scad: >> use <file1.scad> >> module m2() { echo("file3 m2"); } >> >> main.scad: >> use <file1.scad> >> use <file2.scad> >> use <file3.scad> >> m1(); >> m2(); >> >> ECHO: "file1 m1" >> ECHO: "file3 m2" >> >> I think m1 should come from file2.scad and it does if I comment out >> use<file1.scad> from main. >> >> >> On Fri, 17 Jan 2020 at 16:26, nop head <nop.head@gmail.com> wrote: >> >>> I use "use" to mean use<> and "include" to mean include<>. >>> >>> Unfortunately my code is far too big to post as it is a 3D printer made >>> from hundreds of files and so far I haven't managed to distil a small >>> example . >>> >>> I don't fully understand the paragraph you quoted but it sounds like it >>> might be relevant but still doesn't explain why two PCs give different >>> results with the same code. >>> >>> On Fri, 17 Jan 2020 at 11:20, MichaelAtOz <oz.at.michael@gmail.com> >>> wrote: >>> >>>> It would help if you utilised 'use<>', 'include<>' when you refer to >>>> syntax >>>> v's generic use or include as normal words. A compact example would >>>> help. >>>> >>>> Without the code, I can't visualise what you are doing. >>>> >>>> I also note the wiki mentions: >>>> Nested Include and Use >>>> OpenSCAD will execute nested calls to include and use. There is one >>>> caveat >>>> to this, that use only brings functions and modules into the local file >>>> context. As a result, nested calls to use will have no effect on the >>>> environment of the base file; the child use call will work in the >>>> parent use >>>> context, but the modules and functions so imported will fall out of >>>> context >>>> before they are seen by the base context. >>>> >>>> >>>> >>>> ----- >>>> Admin - email* me if you need anything, or if I've done something >>>> stupid... >>>> >>>> * click on my MichaelAtOz label, there is a link to email me. >>>> >>>> Unless specifically shown otherwise above, my contribution is in the >>>> Public Domain; to the extent possible under law, I have waived all >>>> copyright and related or neighbouring rights to this work. Obviously >>>> inclusion of works of previous authors is not included in the above. >>>> >>>> -- >>>> Sent from: http://forum.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 >> >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> >
MK
Marius Kintel
Mon, Jan 20, 2020 3:27 AM

On Jan 19, 2020, at 16:24, nop head nop.head@gmail.com wrote:

It should use the last definition but it doesn't. Names from indirect used files should not be visible.

Yeah, I haven’t reviewed the code, but it feels like it uses the last definition taking all indirect used files into account.

While I agree that this doesn’t feel right, I’m not sure we can just change it without potentially breaking a lot of existing code.

-Marius

On Jan 19, 2020, at 16:24, nop head <nop.head@gmail.com> wrote: > > It should use the last definition but it doesn't. Names from indirect used files should not be visible. > Yeah, I haven’t reviewed the code, but it feels like it uses the last definition taking all indirect used files into account. While I agree that this doesn’t feel right, I’m not sure we can just change it without potentially breaking a lot of existing code. -Marius
M
MichaelAtOz
Mon, Jan 20, 2020 3:53 AM

I get the same on my W7 VM, OpenSCAD 2019.05;
ECHO: "file1 m1"
ECHO: "file3 m2"

But W7 VM, OpenSCAD 2015.03 I get;
ECHO: "file2 m1"
ECHO: "file3 m2"

But on Debian, OpenSCAD 2019.12.22.nightly, & 2015.03
ECHO: "file2 m1"
ECHO: "file3 m2"

So looks like Windows 2019.05 is wrong.


Admin - email* me if you need anything,  or if I've done something stupid...

  • click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/

I get the same on my W7 VM, OpenSCAD 2019.05; ECHO: "file1 m1" ECHO: "file3 m2" But W7 VM, OpenSCAD 2015.03 I get; ECHO: "file2 m1" ECHO: "file3 m2" But on Debian, OpenSCAD 2019.12.22.nightly, & 2015.03 ECHO: "file2 m1" ECHO: "file3 m2" So looks like Windows 2019.05 is wrong. ----- Admin - email* me if you need anything, or if I've done something stupid... * click on my MichaelAtOz label, there is a link to email me. Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. -- Sent from: http://forum.openscad.org/
NH
nop head
Mon, Jan 20, 2020 9:24 AM

Curiously this order gives the intended result but shouldn't.

use <file2.scad>
use <file1.scad>
use <file3.scad>
m1();
m2();

ECHO: "file2 m1"

ECHO: "file3 m2"

So it seems that the search order for these three files is last, first,
second or first, last, second. Odd that the search order seems to depend on
the order of usage but in a non-logical way and machine and platform
dependent. Perhaps the wrong type of container is being used.

On Mon, 20 Jan 2020 at 03:52, MichaelAtOz oz.at.michael@gmail.com wrote:

I get the same on my W7 VM, OpenSCAD 2019.05;
ECHO: "file1 m1"
ECHO: "file3 m2"

But W7 VM, OpenSCAD 2015.03 I get;
ECHO: "file2 m1"
ECHO: "file3 m2"

But on Debian, OpenSCAD 2019.12.22.nightly, & 2015.03
ECHO: "file2 m1"
ECHO: "file3 m2"

So looks like Windows 2019.05 is wrong.


Admin - email* me if you need anything,  or if I've done something
stupid...

  • click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the
Public Domain; to the extent possible under law, I have waived all
copyright and related or neighbouring rights to this work. Obviously
inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/


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

Curiously this order gives the intended result but shouldn't. use <file2.scad> use <file1.scad> use <file3.scad> m1(); m2(); ECHO: "file2 m1" ECHO: "file3 m2" So it seems that the search order for these three files is last, first, second or first, last, second. Odd that the search order seems to depend on the order of usage but in a non-logical way and machine and platform dependent. Perhaps the wrong type of container is being used. On Mon, 20 Jan 2020 at 03:52, MichaelAtOz <oz.at.michael@gmail.com> wrote: > I get the same on my W7 VM, OpenSCAD 2019.05; > ECHO: "file1 m1" > ECHO: "file3 m2" > > But W7 VM, OpenSCAD 2015.03 I get; > ECHO: "file2 m1" > ECHO: "file3 m2" > > But on Debian, OpenSCAD 2019.12.22.nightly, & 2015.03 > ECHO: "file2 m1" > ECHO: "file3 m2" > > So looks like Windows 2019.05 is wrong. > > > > > ----- > Admin - email* me if you need anything, or if I've done something > stupid... > > * click on my MichaelAtOz label, there is a link to email me. > > Unless specifically shown otherwise above, my contribution is in the > Public Domain; to the extent possible under law, I have waived all > copyright and related or neighbouring rights to this work. Obviously > inclusion of works of previous authors is not included in the above. > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
M
MichaelAtOz
Mon, Jan 20, 2020 9:53 AM

You did some work on caching the use/include files IIRC, did that have any
debug calls that could help, ie command line --debug?


Admin - email* me if you need anything,  or if I've done something stupid...

  • click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/

You did some work on caching the use/include files IIRC, did that have any debug calls that could help, ie command line --debug? ----- Admin - email* me if you need anything, or if I've done something stupid... * click on my MichaelAtOz label, there is a link to email me. Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above. -- Sent from: http://forum.openscad.org/
NH
nop head
Mon, Jan 20, 2020 10:03 AM

The work I did was on dependency tracking of uses and includes in order to
decide what needs to be re-parsed and compiled to update the preview. It is
a much earlier phase than module instantiation name lookup. I am struggling
to understand how that works.

On Mon, 20 Jan 2020 at 09:51, MichaelAtOz oz.at.michael@gmail.com wrote:

You did some work on caching the use/include files IIRC, did that have any
debug calls that could help, ie command line --debug?


Admin - email* me if you need anything,  or if I've done something
stupid...

  • click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the
Public Domain; to the extent possible under law, I have waived all
copyright and related or neighbouring rights to this work. Obviously
inclusion of works of previous authors is not included in the above.

--
Sent from: http://forum.openscad.org/


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

The work I did was on dependency tracking of uses and includes in order to decide what needs to be re-parsed and compiled to update the preview. It is a much earlier phase than module instantiation name lookup. I am struggling to understand how that works. On Mon, 20 Jan 2020 at 09:51, MichaelAtOz <oz.at.michael@gmail.com> wrote: > You did some work on caching the use/include files IIRC, did that have any > debug calls that could help, ie command line --debug? > > > > ----- > Admin - email* me if you need anything, or if I've done something > stupid... > > * click on my MichaelAtOz label, there is a link to email me. > > Unless specifically shown otherwise above, my contribution is in the > Public Domain; to the extent possible under law, I have waived all > copyright and related or neighbouring rights to this work. Obviously > inclusion of works of previous authors is not included in the above. > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >