I have (hopefully!) just got to the bottom of some odd errors that came
and went depending on exactly which parts of my model was building, and
also (oddly) whether building on Windows on Linux, though I do have
different versions of OpenSCAD on them.
It turns out that one of the Spline libraries I am using has its own
functions called transform and vec3, which clash with those in the
scad-utils transformations (etc.) libraries. Of course, their clash was
enough to trigger a warning about begin:end being the wrong way around
being deprecated but this warning doesn't have a line number just to
make life interesting.
Change the order of the use <> statements and this error would go away,
but other things relying on the "correct" version of transform would
blown up.
Is there any way to detect this and protect against it?
When name collisions happen, one way I take to workaround the problem is
defining a module and include (or use) the .scad in it. For example:
module your_design() {
module one_part() {
include <a.scad>;
//....
}
module the_other_part() {
include <b.scad>;
//....
}
one_part();
the_other_part();
...
}
The scope of xxx.scad will be constrained in the defined module. It's not a
perfect solution but works in some situations.
View this message in context: http://forum.openscad.org/Libraries-and-namespaces-tp21672p21675.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
On 2017-06-10 18:05, caterpillar wrote:
The scope of xxx.scad will be constrained in the defined module. It's not a
perfect solution but works in some situations.
Thanks for the extra info on scoping (a complex topic that the online
docs don't explain well enough for my simple brain) and it could be
handy for me.
Sadly, I was wanting to use the spline library in exactly the same
stretch of code as where I use the transformations. Oddly, the splines
vec3d, transform and project didn't seem to fail in all cases, so I need
to peer at code and run some tests to understand why, but I've currently
prefixed their names in the spline library.
I'd love a mode where you can get warnings (with line numbers, please!)
when constants, modules or functions are redefined as even working out
why I was getting lots of warnings (without line numbers!) took me some
time.
Gadgetmind wrote
I'd love a mode where you can get warnings (with line numbers, please!)
when constants, modules or functions are redefined as even working out
why I was getting lots of warnings (without line numbers!) took me some
time.
https://github.com/openscad/openscad/issues/1936
https://github.com/openscad/openscad/issues/1843
We need some more developers to get to such things...
Admin - PM me if you need anything, or if I've done something stupid...
Unless specifically shown otherwise above, my contribution is in the Public Domain; to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work. Obviously inclusion of works of previous authors is not included in the above.
View this message in context: http://forum.openscad.org/Libraries-and-namespaces-tp21672p21677.html
Sent from the OpenSCAD mailing list archive at Nabble.com.
On Sat, Jun 10, 2017 at 7:16 AM, Ian Oliver lists@foxhill.co.uk wrote:
It turns out that one of the Spline libraries I am using has its own
functions called transform and vec3, which clash with those in the
scad-utils transformations (etc.) libraries
I would presume that the spline libraries are .scad code.
Why not just rename everywhere in those library files, transform ->
stransform, vec3 -> svec3. And then change your code to use stransform and
svec3.
Without actual knowledge of the code involved, that is how I would try to
manage it. I could be wrong, but it would be my first try.
--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Openscad developer
The most exciting phrase to hear in science - the one that heralds new
discoveries - is not "Eureka!" but "That's funny...".- Isaac. Asimov
On 2017-06-11 06:27, Jerry Davis wrote:
Why not just rename everywhere in those library files, transform ->
stransform, vec3 -> svec3. And then change your code to use stransform
and svec3.
That's exactly what I did, complete with the imaginative "s" prefix, and
the fix took about 20 seconds. However, this was preceded by over an
hour of hunting and fishing to actually work out where in my 1k lines of
scad across half a dozen lines of code and pulling in many libraries the
issue lay.
grep and sed or grep and vi are useful.
--
Extra Ham Operator: K7AZJ
Registered Linux User: 275424
Raspberry Pi and Openscad developer
The most exciting phrase to hear in science - the one that heralds new
discoveries - is not "Eureka!" but "That's funny...".- Isaac. Asimov
On Sun, Jun 11, 2017 at 9:57 AM, Ian Oliver lists@foxhill.co.uk wrote:
On 2017-06-11 06:27, Jerry Davis wrote:
Why not just rename everywhere in those library files, transform ->
stransform, vec3 -> svec3. And then change your code to use stransform and
svec3.
That's exactly what I did, complete with the imaginative "s" prefix, and
the fix took about 20 seconds. However, this was preceded by over an hour
of hunting and fishing to actually work out where in my 1k lines of scad
across half a dozen lines of code and pulling in many libraries the issue
lay.
OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org