Nabble removed Mailing-list integration from the Forum.
This killed the Forum. This is now an ARCHIVE.
It is likely Nabble will shutdown in the future.

So basically the Forum is now out of date, we are looking into migrating the history.

OpenSCAD support is now provided by the Mailing List.
See the first pinned post here for instructions on subscribing to the mailing list.

Questions about include statements

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

Questions about include statements

LenStruttmann
Yet more newbie questions: I'm lovin' OpenSCAD and have progressed from single parts, through simple assemblies, and now I am attempting a complex assembly with multiple dependencies and I'm having trouble.  So, I'm stepping back to create an organized structure and a set of best practices.

I develop each part in its own file which contains the part's module, dimensional constants, and functions for computed values. My top level assembly file references all of the part files using include statements and puts it all together.

1. My first question is about include statements:  How do I conditionally "include" library files?

Each part and the assembly needs a common library, for example, metric_screws.scad. As I develop each part, each part file needs to have a "include <metric_screws.scad>;".  

The top level assembly includes metric_screws.scad, which then gets included again as each part file is included.

So, how do I avoid these multiple includes of the same librry from the top-level assembly?  Or, how do I conditionally execute include statements in the part files?

2. When would you use a "use" statement rather than an "include" statement?

Thanks



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

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Questions about include statements

nophead
You can't conditionally include files so I do end up with the same file included over and over again. 

The best I can do is to only put constants I need to make global in my include files and a use of a second file that has all the functions and modules. Used files are cached and only parsed once. For example I have a screws.scad that I include and it uses screw.scad.





On Sat, 17 Apr 2021 at 15:36, LenStruttmann <[hidden email]> wrote:
Yet more newbie questions: I'm lovin' OpenSCAD and have progressed from single parts, through simple assemblies, and now I am attempting a complex assembly with multiple dependencies and I'm having trouble.  So, I'm stepping back to create an organized structure and a set of best practices.

I develop each part in its own file which contains the part's module, dimensional constants, and functions for computed values. My top level assembly file references all of the part files using include statements and puts it all together.

1. My first question is about include statements:  How do I conditionally "include" library files?

Each part and the assembly needs a common library, for example, metric_screws.scad. As I develop each part, each part file needs to have a "include <metric_screws.scad>;".  

The top level assembly includes metric_screws.scad, which then gets included again as each part file is included.

So, how do I avoid these multiple includes of the same librry from the top-level assembly?  Or, how do I conditionally execute include statements in the part files?

2. When would you use a "use" statement rather than an "include" statement?

Thanks



Sent from the OpenSCAD mailing list archive at Nabble.com.
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Questions about include statements

acwest
I usually split up constants into a screws.h which is included, and modules in screws.scad which I 'use' 

On Sat, 17 Apr 2021, 10:46 nop head, <[hidden email]> wrote:
You can't conditionally include files so I do end up with the same file included over and over again. 

The best I can do is to only put constants I need to make global in my include files and a use of a second file that has all the functions and modules. Used files are cached and only parsed once. For example I have a screws.scad that I include and it uses screw.scad.





On Sat, 17 Apr 2021 at 15:36, LenStruttmann <[hidden email]> wrote:
Yet more newbie questions: I'm lovin' OpenSCAD and have progressed from single parts, through simple assemblies, and now I am attempting a complex assembly with multiple dependencies and I'm having trouble.  So, I'm stepping back to create an organized structure and a set of best practices.

I develop each part in its own file which contains the part's module, dimensional constants, and functions for computed values. My top level assembly file references all of the part files using include statements and puts it all together.

1. My first question is about include statements:  How do I conditionally "include" library files?

Each part and the assembly needs a common library, for example, metric_screws.scad. As I develop each part, each part file needs to have a "include <metric_screws.scad>;".  

The top level assembly includes metric_screws.scad, which then gets included again as each part file is included.

So, how do I avoid these multiple includes of the same librry from the top-level assembly?  Or, how do I conditionally execute include statements in the part files?

2. When would you use a "use" statement rather than an "include" statement?

Thanks



Sent from the OpenSCAD mailing list archive at Nabble.com.
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Questions about include statements

LenStruttmann
But, then you are still including screws.h multiple times, right?

I'm kinda surprised that this isn't more of an issue.

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

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Questions about include statements

adrianv
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.  

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.

LenStruttmann wrote
But, then you are still including screws.h multiple times, right?

I'm kinda surprised that this isn't more of an issue.



--
Sent from: http://forum.openscad.org/
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]


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

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Questions about include statements

LenStruttmann

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 at Nabble.com.

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Questions about include statements

nophead
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 <[hidden email]> 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 at Nabble.com.
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Questions about include statements

LenStruttmann
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 at Nabble.com.

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Questions about include statements

nophead
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 <[hidden email]> 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 at Nabble.com.
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Questions about include statements

acwest
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, <[hidden email]> 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 <[hidden email]> 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 at Nabble.com.
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Questions about include statements

adrianv
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, <[hidden email]> 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 <[hidden email]>
> 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 [hidden email]
>>
> _______________________________________________
> OpenSCAD mailing list
> To unsubscribe send an email to [hidden email]
>

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]


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

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Questions about include statements

jon_bondy
In reply to this post by acwest
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
>
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Questions about include statements

caterpillar
This post was updated on .
In reply to this post by LenStruttmann
"include" merges all included .scad into a single source. You may use it to
include a (code) template. Because all definitions (modules/functions) are in a
single source, the latter will overwrite the previous one if they have the same name.
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/
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Questions about include statements

MichaelAtOz'
In reply to this post by nophead

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:[hidden email]]
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 <[hidden email]> 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 at Nabble.com.
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]


Virus-free. www.avg.com

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Questions about include statements

nophead
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 <[hidden email]> 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:[hidden email]]
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 <[hidden email]> 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 at Nabble.com.
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]


Virus-free. www.avg.com
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Questions about include statements

LenStruttmann
In reply to this post by caterpillar
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 at Nabble.com.

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Questions about include statements

nophead
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 <[hidden email]> 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 at Nabble.com.
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Questions about include statements

LenStruttmann
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 [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Questions about include statements

nophead
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, <[hidden email]> 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 [hidden email]

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Questions about include statements

RevarBat
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 <[hidden email]> 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, <[hidden email]> 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 [hidden email]
_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]

_______________________________________________
OpenSCAD mailing list
To unsubscribe send an email to [hidden email]