Name resolution different on different PCs.

classic Classic list List threaded Threaded
27 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Name resolution different on different PCs.

nophead
I have two Win7 64 bit machines in two locations running OpenSCAD 2019.05. My scad files are synchronised between the machines with GoogleDrive but I get different results.

I use one file that defines some module and then use another file that defines modules with the same name. I then instantiate those modules. On my desktop machine at home the second definitions override the first ones. On my Laptop in Tenerife the first definitions are used. Why would it be different?

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Name resolution different on different PCs.

MichaelAtOz
Administrator
What happens if you manually copy files without GoogleDrive? (I'm not a
GoogleDrive user)



-----
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
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.
Reply | Threaded
Open this post in threaded view
|

Re: Name resolution different on different PCs.

nophead
Well I can't because the two machines are thousands of miles apart and the one at home is not switched on when I am not there and vice versa.

I am certain the files are the same though and everything worked fine until I moved some of my code to separate files and used them to avoid main being massive. That works fine in my summer residence but not in my winter residence.

This is the only place I define default implementations (blank panels of a box) and then override them with customised panels with parts on them. It works if the overrides are in the file that calls them but not if they are in used files.

Should I expect used files to be searched in reverse order of them being used, or is it non-deterministic?


On Thu, 16 Jan 2020 at 12:03, MichaelAtOz <[hidden email]> wrote:
What happens if you manually copy files without GoogleDrive? (I'm not a
GoogleDrive user)



-----
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Name resolution different on different PCs.

Parkinbot
In reply to this post by nophead
Are you sure that all relavant pathes (Library Folder, working directory,
PATH order) are the same on both machines? I once had a similar effect and
it was the working directory that was wrong.



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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Name resolution different on different PCs.

nophead
They are not the same in absolute terms but they are they should be equivalent. I.e. the folder structure of the project is identical but is path is different. My OPENSCADPATH variable points to the same library but it may have a different path. It is the same library though according to git.

Everything else works the same on both machines. I can run all my library tests and get the same results give or take a few pixels. It is just this lookup issue when there are two used files than define the same module. On my desktop in the UK the last definition wins. Here in the sun the first definitions wins.

On Thu, 16 Jan 2020 at 23:23, Parkinbot <[hidden email]> wrote:
Are you sure that all relavant pathes (Library Folder, working directory,
PATH order) are the same on both machines? I once had a similar effect and
it was the working directory that was wrong.



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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Name resolution different on different PCs.

nophead
If the absolute paths of the files changes the search order then that might explain the difference but surely that should not affect the semantics of the source code.

On Thu, 16 Jan 2020 at 23:31, nop head <[hidden email]> wrote:
They are not the same in absolute terms but they are they should be equivalent. I.e. the folder structure of the project is identical but is path is different. My OPENSCADPATH variable points to the same library but it may have a different path. It is the same library though according to git.

Everything else works the same on both machines. I can run all my library tests and get the same results give or take a few pixels. It is just this lookup issue when there are two used files than define the same module. On my desktop in the UK the last definition wins. Here in the sun the first definitions wins.

On Thu, 16 Jan 2020 at 23:23, Parkinbot <[hidden email]> wrote:
Are you sure that all relavant pathes (Library Folder, working directory,
PATH order) are the same on both machines? I once had a similar effect and
it was the working directory that was wrong.



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

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Name resolution different on different PCs.

MichaelAtOz
Administrator
In reply to this post by nophead
nophead wrote
> I use one file that defines some module and then use another file that
> defines modules with the same name. I then instantiate those modules.

Are both of those 'use' == 'use<file>'?

//main.scad
use<file1.scad> // defines module m1(){echo("file1")}
use<file2.scad> // also define module m1(){echo("file2")}
//or perhaps also file1.scad but in another directory??
m1();  

You get ECHO: "file1" on one system and "file2" on the other??

Wiki says Help/Library-info shows the libraries & "The locations will be
searched in the order they appear in this list"



-----
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
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.
Reply | Threaded
Open this post in threaded view
|

Re: Name resolution different on different PCs.

nophead
That works as expected on my laptop, that I have the problem with. I can't test anything on my desktop until the spring.

My code is actually more complex than that. I actually have a box.scad that defines all its panels as blanks. I use that in front.scad, sides.scad, top.scad, etc. Each one of those redefines one panel. I then use all of those in main.scad after using box.scad, expecting all the blank panels to be overridden.

I found I had accidentally used box.scad after the other files in main via an include. Moving that to before fixes most of the panels, except the front, which only works if it is included after the sides, but I don't understand why. There is nothing special about sides.scad other than it defines two panels instead of one. It has no relationship to front.scad.

They other mystery is why it worked on my desktop with the use of box.scad after all the others. It definitely did because I checked it again when I was home for a few weeks at Christmas.

I have it working now with a new order of uses, so all that remains is to see if it works on my desktop. There is definitely some strange going on but it is very subtle. 

On Thu, 16 Jan 2020 at 23:54, MichaelAtOz <[hidden email]> wrote:
nophead wrote
> I use one file that defines some module and then use another file that
> defines modules with the same name. I then instantiate those modules.

Are both of those 'use' == 'use<file>'?

//main.scad
use<file1.scad> // defines module m1(){echo("file1")}
use<file2.scad> // also define module m1(){echo("file2")}
//or perhaps also file1.scad but in another directory??
m1(); 

You get ECHO: "file1" on one system and "file2" on the other??

Wiki says Help/Library-info shows the libraries & "The locations will be
searched in the order they appear in this list"



-----
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Name resolution different on different PCs.

MichaelAtOz
Administrator
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
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.
Reply | Threaded
Open this post in threaded view
|

Re: Name resolution different on different PCs.

nophead
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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Name resolution different on different PCs.

nophead
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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Name resolution different on different PCs.

nophead
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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Name resolution different on different PCs.

Marius Kintel
In reply to this post by nophead
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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Name resolution different on different PCs.

nophead
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, <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Name resolution different on different PCs.

nophead
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 <[hidden email]> 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, <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Name resolution different on different PCs.

Marius Kintel
In reply to this post by nophead
On Jan 19, 2020, at 16:24, nop head <[hidden email]> 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


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Name resolution different on different PCs.

MichaelAtOz
Administrator
In reply to this post by nophead
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
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.
Reply | Threaded
Open this post in threaded view
|

Re: Name resolution different on different PCs.

nophead
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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Name resolution different on different PCs.

MichaelAtOz
Administrator
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
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.
Reply | Threaded
Open this post in threaded view
|

Re: Name resolution different on different PCs.

nophead
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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
12