discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Questions about include statements

A
adrianv
Sun, Apr 18, 2021 12:07 AM

This strategy can be inefficient and lead to performance problems.  When I
implemented my very efficient beziers, for example, putting things in global
variables was essential to maximize computational speed, because otherwise
they were getting recomputed or reassigned with every call.

acwest wrote

In general, in files that I am using, I never define top level variables
at
all, which works well with my general aversion to global variables. Pretty
much all variables are declared inside modules, except the $ variables,
which are special. Everything else is passed in as arguments. It seems to
help

On Sat, 17 Apr 2021, 18:00 nop head, <

nop.head@

> wrote:

Yes but that would mean wrapping all my objects with functions.

The problem remains with complex machines that  their used files need
variables to calculate positions, etc. If you wrap all those expressions
in
functions you end up with an exploding tree of function calls.

On Sat, 17 Apr 2021 at 22:49, LenStruttmann <

LenStruttmann@

>

wrote:

So, would a "best practice" be:

(1) Assuming that libraries are well-designed with a minimum number of
instantiated variables,
(2) Part files include any libraries they need, but never instantiate
global variables. Instead, they expose all values only via functions.
(3) The top level assembly only "use"s part files, accessing everything
as a module or a function.

?


Sent from the OpenSCAD mailing list archive
<http://forum.openscad.org/>
at Nabble.com.


OpenSCAD mailing list
To unsubscribe send an email to

discuss-leave@.openscad


OpenSCAD mailing list
To unsubscribe send an email to

discuss-leave@.openscad


OpenSCAD mailing list
To unsubscribe send an email to

discuss-leave@.openscad

This strategy can be inefficient and lead to performance problems. When I implemented my very efficient beziers, for example, putting things in global variables was essential to maximize computational speed, because otherwise they were getting recomputed or reassigned with every call. acwest wrote > In general, in files that I am using, I never define top level variables > at > all, which works well with my general aversion to global variables. Pretty > much all variables are declared inside modules, except the $ variables, > which are special. Everything else is passed in as arguments. It seems to > help > > On Sat, 17 Apr 2021, 18:00 nop head, &lt; > nop.head@ > &gt; wrote: > >> Yes but that would mean wrapping all my objects with functions. >> >> The problem remains with complex machines that their used files need >> variables to calculate positions, etc. If you wrap all those expressions >> in >> functions you end up with an exploding tree of function calls. >> >> On Sat, 17 Apr 2021 at 22:49, LenStruttmann &lt; > LenStruttmann@ > &gt; >> wrote: >> >>> So, would a "best practice" be: >>> >>> (1) Assuming that libraries are well-designed with a minimum number of >>> instantiated variables, >>> (2) Part files include any libraries they need, but never instantiate >>> global variables. Instead, they expose all values only via functions. >>> (3) The top level assembly only "use"s part files, accessing everything >>> as a module or a function. >>> >>> ? >>> >>> ------------------------------ >>> Sent from the OpenSCAD mailing list archive >>> &lt;http://forum.openscad.org/&gt; >>> at Nabble.com. >>> _______________________________________________ >>> OpenSCAD mailing list >>> To unsubscribe send an email to > discuss-leave@.openscad >>> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to > discuss-leave@.openscad >> > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to > discuss-leave@.openscad -- Sent from: http://forum.openscad.org/
J
jon
Sun, Apr 18, 2021 12:40 AM

I write fairly simple scripts, and use global variables all of the time,
to specify sizes, offsets, and to enable/disable sections of code.  I
use them as appropriate.  Some dimensions need to be shared between
different objects, and listing them globally works well for me.

On 4/17/2021 6:03 PM, A. Craig West wrote:

In general, in files that I am using, I never define top level
variables at all, which works well with my general aversion to global
variables. Pretty much all variables are declared inside modules,
except the $ variables, which are special. Everything else is passed
in as arguments. It seems to help

I write fairly simple scripts, and use global variables all of the time, to specify sizes, offsets, and to enable/disable sections of code.  I use them as appropriate.  Some dimensions need to be shared between different objects, and listing them globally works well for me. On 4/17/2021 6:03 PM, A. Craig West wrote: > In general, in files that I am using, I never define top level > variables at all, which works well with my general aversion to global > variables. Pretty much all variables are declared inside modules, > except the $ variables, which are special. Everything else is passed > in as arguments. It seems to help >
C
caterpillar
Sun, Apr 18, 2021 1:55 AM

"include" merges all included .scad into a single source. You may use it to
include a (code) template. Because all definitions (modules/functions) are a
single source, the latter will overwrite the previous one if they are the
same. In other words, be careful of namespace pollution problems.

When you "use" a .scad, modules/functions of the used file will be visible
only in the .scad where "use" is presented. For example, a.scad have a "foo"
function. If you "use <a.scad>" in b.scad, the "foo" function is only
visible in b.scad. If you "use <b.scad>" in c.scad, you cannot see the "foo"
function. It's helpful when namespace management is required.


https://openhome.cc

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

"include" merges all included .scad into a single source. You may use it to include a (code) template. Because all definitions (modules/functions) are a single source, the latter will overwrite the previous one if they are the same. In other words, be careful of namespace pollution problems. When you "use" a .scad, modules/functions of the used file will be visible only in the .scad where "use" is presented. For example, a.scad have a "foo" function. If you "use <a.scad>" in b.scad, the "foo" function is only visible in b.scad. If you "use <b.scad>" in c.scad, you cannot see the "foo" function. It's helpful when namespace management is required. ----- https://openhome.cc -- Sent from: http://forum.openscad.org/
MM
Michael Marx
Sun, Apr 18, 2021 6:26 AM

Have we thought of adding some smarts to evaluation?

Only expressions with $variables can change, but could cascade,

a=$b*2;

c=a/$d;

e=max(c,$f);

g=w*h;

Build a dependency tree;

a {$b}, c {a, $d}, e {c, $f}, g {w, h};

once you hit EOF you could optimise the tree for reading;

a {$b} c {$b, $d} e ($f) [remove g or discard earlier]

First simple test could be only re-evaluate (all) expressions with a $variable in its tree hierarchy, ie the optimised list.

Second you could cache the last value of the $variable in the tree, if it has changed since last time re-evaluate the relevant branch.

?


From: nop head [mailto:nop.head@gmail.com]
Sent: Sun, 18 Apr 2021 06:44
To: OpenSCAD general discussion
Subject: [OpenSCAD] Re: Questions about include statements

To be clear I generally avoid including the same file twice in the same scope but screws for example are included in most sub assemblies that are themselves used, so they get included into multiple scopes as each used file has its own variables.

The fact that variables are evaluated when a module of function in a used file is called really slows down my builds and I think sets a finite limit to the complexity of the design. I am struggling with my latest 3D printed. I don't think I could model a car or an airliner in OpenSCAD. The time to instantiate the variables would tend towards infinity. It already takes minutes.

For most of my designs that only have one main file or perhaps two or three it isn't a problem but when there are 30 files it gets very slow. I think 100 would be impossible, whereas a C++ program with 100 files in it is not really a problem. There isn't really a limit because compile time is linear with the number of files, whereas with OpenSCAD it increases exponentially.

On Sat, 17 Apr 2021 at 20:32, LenStruttmann LenStruttmann@gmail.com wrote:

You can define the same function or module multiple times.  Later definitions replace earlier ones.  So including the same file repeatedly doesn't break anything.  Even definitions of global constants are just replaced if they happen in include files.

That's good to know.  I still find it odd.  If my assembly and my parts all include:

include <BOSL2/std.scad>;
include <BOSL2/metric_screws.scad>;

... it seems to me that there would be a performance hit to re-read those files for each part.  Then again, after the first file read the OS will have all (or most) of the file contents cached. I suppose I'm just showing my age, coming from a programming background where file reads were enormously expensive.  I guess that this behavior is not much different from a C compiler including .h files.

Be aware if you use "use" that any variable assignments at the top level will be executed any time you call a function in your file, which can result in huge slow downs if you call functions a lot and have something slow to compute in those top level assignments.

Thanks!  These are the types of performance hits I'd like to avoid.


Sent from the OpenSCAD http://forum.openscad.org/  mailing list archive at Nabble.com.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

--
This email has been checked for viruses by AVG.
https://www.avg.com

Have we thought of adding some smarts to evaluation? Only expressions with $variables can change, but could cascade, a=$b*2; c=a/$d; e=max(c,$f); g=w*h; Build a dependency tree; a {$b}, c {a, $d}, e {c, $f}, g {w, h}; once you hit EOF you could optimise the tree for reading; a {$b} c {$b, $d} e ($f) [remove g or discard earlier] First simple test could be only re-evaluate (all) expressions with a $variable in its tree hierarchy, ie the optimised list. Second you could cache the last value of the $variable in the tree, if it has changed since last time re-evaluate the relevant branch. ? _____ From: nop head [mailto:nop.head@gmail.com] Sent: Sun, 18 Apr 2021 06:44 To: OpenSCAD general discussion Subject: [OpenSCAD] Re: Questions about include statements To be clear I generally avoid including the same file twice in the same scope but screws for example are included in most sub assemblies that are themselves used, so they get included into multiple scopes as each used file has its own variables. The fact that variables are evaluated when a module of function in a used file is called really slows down my builds and I think sets a finite limit to the complexity of the design. I am struggling with my latest 3D printed. I don't think I could model a car or an airliner in OpenSCAD. The time to instantiate the variables would tend towards infinity. It already takes minutes. For most of my designs that only have one main file or perhaps two or three it isn't a problem but when there are 30 files it gets very slow. I think 100 would be impossible, whereas a C++ program with 100 files in it is not really a problem. There isn't really a limit because compile time is linear with the number of files, whereas with OpenSCAD it increases exponentially. On Sat, 17 Apr 2021 at 20:32, LenStruttmann <LenStruttmann@gmail.com> wrote: You can define the same function or module multiple times. Later definitions replace earlier ones. So including the same file repeatedly doesn't break anything. Even definitions of global constants are just replaced if they happen in include files. That's good to know. I still find it odd. If my assembly and my parts all include: include <BOSL2/std.scad>; include <BOSL2/metric_screws.scad>; ... it seems to me that there would be a performance hit to re-read those files for each part. Then again, after the first file read the OS will have all (or most) of the file contents cached. I suppose I'm just showing my age, coming from a programming background where file reads were enormously expensive. I guess that this behavior is not much different from a C compiler including .h files. Be aware if you use "use" that any variable assignments at the top level will be executed any time you call a function in your file, which can result in huge slow downs if you call functions a lot and have something slow to compute in those top level assignments. Thanks! These are the types of performance hits I'd like to avoid. _____ Sent from the OpenSCAD <http://forum.openscad.org/> mailing list archive at Nabble.com. _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to discuss-leave@lists.openscad.org -- This email has been checked for viruses by AVG. https://www.avg.com
NH
nop head
Sun, Apr 18, 2021 7:43 AM

Yes I think that is the only solution. Track the use of $variables through
expressions and functions and cache their values.

On Sun, 18 Apr 2021 at 07:26, Michael Marx michael@marx.id.au wrote:

Have we thought of adding some smarts to evaluation?

Only expressions with $variables can change, but could cascade,

a=$b*2;

c=a/$d;

e=max(c,$f);

g=w*h;

Build a dependency tree;

a {$b}, c {a, $d}, e {c, $f}, g {w, h};

once you hit EOF you could optimise the tree for reading;

a {$b} c {$b, $d} e ($f) [remove g or discard earlier]

First simple test could be only re-evaluate (all) expressions with a
$variable in its tree hierarchy, ie the optimised list.

Second you could cache the last value of the $variable in the tree, if it
has changed since last time re-evaluate the relevant branch.

?


From: nop head [mailto:nop.head@gmail.com]
Sent: Sun, 18 Apr 2021 06:44
To: OpenSCAD general discussion
Subject: [OpenSCAD] Re: Questions about include statements

To be clear I generally avoid including the same file twice in the same
scope but screws for example are included in most sub assemblies that are
themselves used, so they get included into multiple scopes as each used
file has its own variables.

The fact that variables are evaluated when a module of function in a used
file is called really slows down my builds and I think sets a finite limit
to the complexity of the design. I am struggling with my latest 3D printed.
I don't think I could model a car or an airliner in OpenSCAD. The time to
instantiate the variables would tend towards infinity. It already takes
minutes.

For most of my designs that only have one main file or perhaps two or
three it isn't a problem but when there are 30 files it gets very slow. I
think 100 would be impossible, whereas a C++ program with 100 files in it
is not really a problem. There isn't really a limit because compile time is
linear with the number of files, whereas with OpenSCAD it increases
exponentially.

On Sat, 17 Apr 2021 at 20:32, LenStruttmann LenStruttmann@gmail.com
wrote:

*You can define the same function or module multiple times.  Later
definitions replace earlier ones.  So including the same file repeatedly
doesn't break anything.  Even definitions of global constants are just
replaced if they happen in include files. *

That's good to know.  I still find it odd.  If my assembly and my parts
all include:

include <BOSL2/std.scad>;
include <BOSL2/metric_screws.scad>;

... it seems to me that there would be a performance hit to re-read those
files for each part.  Then again, after the first file read the OS will
have all (or most) of the file contents cached. I suppose I'm just showing
my age, coming from a programming background where file reads were
enormously expensive.  I guess that this behavior is not much different
from a C compiler including .h files.

Be aware if you use "use" that any variable assignments at the top level
will be executed any time you call a function in your file, which can
result in huge slow downs if you call functions a lot and have something
slow to compute in those top level assignments.

Thanks!  These are the types of performance hits I'd like to avoid.


Sent from the OpenSCAD mailing list archive http://forum.openscad.org/
at Nabble.com.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient Virus-free.
www.avg.com
http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient
<#m_991524928460594659_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Yes I think that is the only solution. Track the use of $variables through expressions and functions and cache their values. On Sun, 18 Apr 2021 at 07:26, Michael Marx <michael@marx.id.au> wrote: > Have we thought of adding some smarts to evaluation? > > Only expressions with $variables can change, but could cascade, > > > > a=$b*2; > > c=a/$d; > > e=max(c,$f); > > g=w*h; > > > > Build a dependency tree; > > a {$b}, c {a, $d}, e {c, $f}, g {w, h}; > > once you hit EOF you could optimise the tree for reading; > > a {$b} c {$b, $d} e ($f) [remove g or discard earlier] > > First simple test could be only re-evaluate (all) expressions with a > $variable in its tree hierarchy, ie the optimised list. > > > > Second you could cache the last value of the $variable in the tree, if it > has changed since last time re-evaluate the relevant branch. > > > > ? > > > ------------------------------ > > *From:* nop head [mailto:nop.head@gmail.com] > *Sent:* Sun, 18 Apr 2021 06:44 > *To:* OpenSCAD general discussion > *Subject:* [OpenSCAD] Re: Questions about include statements > > > > To be clear I generally avoid including the same file twice in the same > scope but screws for example are included in most sub assemblies that are > themselves used, so they get included into multiple scopes as each used > file has its own variables. > > > > The fact that variables are evaluated when a module of function in a used > file is called really slows down my builds and I think sets a finite limit > to the complexity of the design. I am struggling with my latest 3D printed. > I don't think I could model a car or an airliner in OpenSCAD. The time to > instantiate the variables would tend towards infinity. It already takes > minutes. > > > > For most of my designs that only have one main file or perhaps two or > three it isn't a problem but when there are 30 files it gets very slow. I > think 100 would be impossible, whereas a C++ program with 100 files in it > is not really a problem. There isn't really a limit because compile time is > linear with the number of files, whereas with OpenSCAD it increases > exponentially. > > > > On Sat, 17 Apr 2021 at 20:32, LenStruttmann <LenStruttmann@gmail.com> > wrote: > > > *You can define the same function or module multiple times. Later > definitions replace earlier ones. So including the same file repeatedly > doesn't break anything. Even definitions of global constants are just > replaced if they happen in include files. * > > That's good to know. I still find it odd. If my assembly and my parts > all include: > > include <BOSL2/std.scad>; > include <BOSL2/metric_screws.scad>; > > ... it seems to me that there would be a performance hit to re-read those > files for each part. Then again, after the first file read the OS will > have all (or most) of the file contents cached. I suppose I'm just showing > my age, coming from a programming background where file reads were > enormously expensive. I guess that this behavior is not much different > from a C compiler including .h files. > > *Be aware if you use "use" that any variable assignments at the top level > will be executed any time you call a function in your file, which can > result in huge slow downs if you call functions a lot and have something > slow to compute in those top level assignments.* > > Thanks! These are the types of performance hits I'd like to avoid. > > > ------------------------------ > > Sent from the OpenSCAD mailing list archive <http://forum.openscad.org/> > at Nabble.com. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> Virus-free. > www.avg.com > <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> > <#m_991524928460594659_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
L
LenStruttmann
Sun, Apr 18, 2021 3:01 PM

Thanks, everyone for this discussion. It has very much helped with my
understanding of "include".

But, I'm still unclear on the purpose of the "use" statement.  I guess that
there are only special cases where the "use" statement is appropriate.

Even files that only contain functions and modules aren't always compatible
with "use".  For example, <BOSL2/metric_screws.scad> only contains functions
and modules.  Yet, you must "include" it, presumably because it includes
other files.

So, back to my original question: I now know that:

(1) Having multiple "includes" of the same library file is not bad and there
is usually not much of a performance hit.
(2) I don't need to "include" a library in my assembly if that library is
included within a part file that the assembly includes.

Thanks!

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

Thanks, everyone for this discussion. It has very much helped with my understanding of "include". But, I'm still unclear on the purpose of the "use" statement. I guess that there are only special cases where the "use" statement is appropriate. Even files that only contain functions and modules aren't always compatible with "use". For example, <BOSL2/metric_screws.scad> only contains functions and modules. Yet, you must "include" it, presumably because it includes other files. So, back to my original question: I now know that: (1) Having multiple "includes" of the same library file is not bad and there is usually not much of a performance hit. (2) I don't need to "include" a library in my assembly if that library is included within a part file that the assembly includes. Thanks! -- Sent from: http://forum.openscad.org/
NH
nop head
Sun, Apr 18, 2021 5:27 PM

If a library file doesn't have any constants you need, just functions and
modules you should be able to use it regardless of other files it includes
or uses. The difference you get including it is you would see those
includes and uses in your file as well.

Generally it is better to encapsulate library files in a used file, so they
don't leak implementation details, like what files they include and use and
perhaps constants that are for internal use. Also used files are cached and
only parsed once. As long as the library files don't define a lot of
constants, or a few constants that take a long time to evaluate they work
well being used.

Hopefully one day the bug in OpenSCAD will be fixed so you can actually
store computed results in constants in used files and they will only be
computed once. For example I have a module that creates springs as
polyhedrons with lots of segments. I also have a module that makes
battery contacts for different cells with a tapered spring for the negative
ones, that are all the same. I found it impossible to calculate the spring
polyhedron once, store it as a constant and reuse it many times. The only
file that can have constants that are calculated once is the main top level
file and files it includes.

On Sun, 18 Apr 2021 at 16:01, LenStruttmann LenStruttmann@gmail.com wrote:

Thanks, everyone for this discussion. It has very much helped with my
understanding of "include".

But, I'm still unclear on the purpose of the "use" statement.  I guess
that there are only special cases where the "use" statement is appropriate.

Even files that only contain functions and modules aren't always
compatible with "use".  For example, <BOSL2/metric_screws.scad> only
contains functions and modules.  Yet, you must "include" it, presumably
because it includes other files.

So, back to my original question: I now know that:

(1) Having multiple "includes" of the same library file is not bad and
there is usually not much of a performance hit.
(2) I don't need to "include" a library in my assembly if that library is
included within a part file that the assembly includes.

Thanks!

Sent from the OpenSCAD mailing list archive http://forum.openscad.org/
at Nabble.com.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

If a library file doesn't have any constants you need, just functions and modules you should be able to use it regardless of other files it includes or uses. The difference you get including it is you would see those includes and uses in your file as well. Generally it is better to encapsulate library files in a used file, so they don't leak implementation details, like what files they include and use and perhaps constants that are for internal use. Also used files are cached and only parsed once. As long as the library files don't define a lot of constants, or a few constants that take a long time to evaluate they work well being used. Hopefully one day the bug in OpenSCAD will be fixed so you can actually store computed results in constants in used files and they will only be computed once. For example I have a module that creates springs as polyhedrons with lots of segments. I also have a module that makes battery contacts for different cells with a tapered spring for the negative ones, that are all the same. I found it impossible to calculate the spring polyhedron once, store it as a constant and reuse it many times. The only file that can have constants that are calculated once is the main top level file and files it includes. On Sun, 18 Apr 2021 at 16:01, LenStruttmann <LenStruttmann@gmail.com> wrote: > Thanks, everyone for this discussion. It has very much helped with my > understanding of "include". > > But, I'm still unclear on the purpose of the "use" statement. I guess > that there are only special cases where the "use" statement is appropriate. > > Even files that only contain functions and modules aren't always > compatible with "use". For example, <BOSL2/metric_screws.scad> only > contains functions and modules. Yet, you must "include" it, presumably > because it includes other files. > > So, back to my original question: I now know that: > > (1) Having multiple "includes" of the same library file is not bad and > there is usually not much of a performance hit. > (2) I don't need to "include" a library in my assembly if that library is > included within a part file that the assembly includes. > > Thanks! > ------------------------------ > Sent from the OpenSCAD mailing list archive <http://forum.openscad.org/> > at Nabble.com. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
L
LenStruttmann
Sun, Apr 18, 2021 6:25 PM

/If a library file doesn't have any constants you need, just functions and
modules you should be able to use it regardless of other files it includes
or uses./

Yes, I believe that is how it should work.  Unfortunately, this is not
always the case.  Here is a simple example:

include <BOSL2/std.scad>;
include <BOSL2/gears.scad>;

bevel_gear();

As far as I can see, gears.scad is composed solely of functions and modules.
Nevertheless, when I change the include to:

use <BOSL2/gears.scad>;

...it fails with 167 warnings.  :-)

I haven't investigated to find out why.

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

/If a library file doesn't have any constants you need, just functions and modules you should be able to use it regardless of other files it includes or uses./ Yes, I believe that is how it should work. Unfortunately, this is not always the case. Here is a simple example: include <BOSL2/std.scad>; include <BOSL2/gears.scad>; bevel_gear(); As far as I can see, gears.scad is composed solely of functions and modules. Nevertheless, when I change the include to: use <BOSL2/gears.scad>; ...it fails with 167 warnings. :-) I haven't investigated to find out why. -- Sent from: http://forum.openscad.org/
NH
nop head
Sun, Apr 18, 2021 7:58 PM

Perhaps bosl is designed to be included so gears expects std to be already
included so doesn't include std itself. That avoids STD being included
multiple times

On Sun, 18 Apr 2021, 19:26 LenStruttmann, LenStruttmann@gmail.com wrote:

If a library file doesn't have any constants you need, just functions and
modules you should be able to use it regardless of other files it includes
or uses.

Yes, I believe that is how it should work.  Unfortunately, this is not
always the case.  Here is a simple example:

include <BOSL2/std.scad>;
include <BOSL2/gears.scad>;

bevel_gear();

As far as I can see, gears.scad is composed solely of functions and
modules. Nevertheless, when I change the include to:

use <BOSL2/gears.scad>;

...it fails with 167 warnings.  :-)

I haven't investigated to find out why.


Sent from the OpenSCAD mailing list archive http://forum.openscad.org/
at Nabble.com.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Perhaps bosl is designed to be included so gears expects std to be already included so doesn't include std itself. That avoids STD being included multiple times On Sun, 18 Apr 2021, 19:26 LenStruttmann, <LenStruttmann@gmail.com> wrote: > *If a library file doesn't have any constants you need, just functions and > modules you should be able to use it regardless of other files it includes > or uses.* > > Yes, I believe that is how it should work. Unfortunately, this is not > always the case. Here is a simple example: > > include <BOSL2/std.scad>; > include <BOSL2/gears.scad>; > > bevel_gear(); > > > As far as I can see, gears.scad is composed solely of functions and > modules. Nevertheless, when I change the include to: > > use <BOSL2/gears.scad>; > > ...it fails with 167 warnings. :-) > > I haven't investigated to find out why. > > > > ------------------------------ > Sent from the OpenSCAD mailing list archive <http://forum.openscad.org/> > at Nabble.com. > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
RD
Revar Desmera
Sun, Apr 18, 2021 8:05 PM

Yes. Because of the re-evaluating variables bug, BOSL2 uses “include“ exclusively, with the core files expected to be included via std.scad

-Revar

On Apr 18, 2021, at 12:58 PM, nop head nop.head@gmail.com wrote:


Perhaps bosl is designed to be included so gears expects std to be already included so doesn't include std itself. That avoids STD being included multiple times

On Sun, 18 Apr 2021, 19:26 LenStruttmann, LenStruttmann@gmail.com wrote:
If a library file doesn't have any constants you need, just functions and modules you should be able to use it regardless of other files it includes or uses.

Yes, I believe that is how it should work.  Unfortunately, this is not always the case.  Here is a simple example:

include <BOSL2/std.scad>;
include <BOSL2/gears.scad>;

bevel_gear();

As far as I can see, gears.scad is composed solely of functions and modules. Nevertheless, when I change the include to:

use <BOSL2/gears.scad>;

...it fails with 167 warnings.  :-)

I haven't investigated to find out why.

Sent from the OpenSCAD mailing list archive at Nabble.com.


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Yes. Because of the re-evaluating variables bug, BOSL2 uses “include“ exclusively, with the core files expected to be included via std.scad -Revar > On Apr 18, 2021, at 12:58 PM, nop head <nop.head@gmail.com> wrote: > >  > Perhaps bosl is designed to be included so gears expects std to be already included so doesn't include std itself. That avoids STD being included multiple times > > > >> On Sun, 18 Apr 2021, 19:26 LenStruttmann, <LenStruttmann@gmail.com> wrote: >> If a library file doesn't have any constants you need, just functions and modules you should be able to use it regardless of other files it includes or uses. >> >> Yes, I believe that is how it should work. Unfortunately, this is not always the case. Here is a simple example: >> >> include <BOSL2/std.scad>; >> include <BOSL2/gears.scad>; >> >> bevel_gear(); >> >> >> As far as I can see, gears.scad is composed solely of functions and modules. Nevertheless, when I change the include to: >> >> use <BOSL2/gears.scad>; >> >> ...it fails with 167 warnings. :-) >> >> I haven't investigated to find out why. >> >> >> >> Sent from the OpenSCAD mailing list archive at Nabble.com. >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org