discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

redefining module without errors

AM
Adrian Mariano
Sat, Jun 8, 2024 1:40 PM

Consider yourself corrected.  BOSL2 overrides cube() and cylinder() to add
attachment extensions while retaining complete compatibility, and then also
provides cuboid() and cyl() which are not backwards compatible with cube()
and cyl().  Almost all primitive objects are overridden and actually
there's a request for a feature that will requires overriding all the
transformation primitives as well.

On Sat, Jun 8, 2024 at 9:18 AM larry via Discuss discuss@lists.openscad.org
wrote:

On Sat, 2024-06-08 at 06:34 -0500, Leonard Martin Struttmann via
Discuss wrote:

I, personally, would want this extended warning mode to be ON by
default.  I, too, have spent many hours tracking down why strange
things were happening in my code only to discover that a library that
I was using had a module with the same name as I had.

However, this "feature" can be quite useful.  BOSL2 overrides
primitives such as cube() and cylinder() that work exactly like the
OpenSCAD primitives, while allowing one to position and orient the
created shape.

Corect me if I'm wrong, but BOSL2 does not override cube() and
cylinder(). They provide cuboid() and cyl().

On Sat, Jun 8, 2024 at 6:06 AM Michael Möller via Discuss
discuss@lists.openscad.org wrote:

Well, trying to be constructive here, it might be implemented as a
extended warningmode, off by default. I'm thinking like "lint" in
C, a nitpicking mode.

Unfortunatly that means a syntax extensions or compiler hints
(typically a specially formatted comment fex /!/) that signals
this redefenition is intentional.

If the people who use their spare time to implement such extended
warnings feel this is worthwhile, they could also consider flagging
unused variables and suchlike.

lør. 8. jun. 2024 12.43 skrev Jon Bondy via Discuss
discuss@lists.openscad.org:

I claim this is a serious bug.  I can't tell you how much time I
spent altering a module and seeing nothing change.  I imagine it
is way too late to change, but it would be helpful if there were
SOME utility that allowed one to know that such an over-ride has
occurred, ESPECIALLY  within a single text file.  I cannot see
any use for re-defining a module within a file: that surely would
deserve a warning.
Sigh.
On 6/7/2024 11:32 PM, Leonard Martin Struttmann via Discuss
wrote:

Jon, yes this is correct.  This allows you to override modules
(even OpenSCAD primitives) with your own, enhanced versions.
The BOSL2 library does this a lot. It can be confusing at
times, but it is very powerful.

On Fri, Jun 7, 2024 at 7:58 PM Father Horton via Discuss
discuss@lists.openscad.org wrote:

When it comes to variables, the last definition in the scope
applies. I think the same thing applies here.

On Fri, Jun 7, 2024 at 6:43 PM Jon Bondy via Discuss
discuss@lists.openscad.org wrote:

The following code does not generate any warnings or
errors.  It this correct behavior?  Using version
2024.01.14 (git 158c5b94f)
Jon

module Pot()
cube(10);

module Pot()
cube(20);

Pot();

Virus-free.www.avg.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


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


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


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

Consider yourself corrected. BOSL2 overrides cube() and cylinder() to add attachment extensions while retaining complete compatibility, and then also provides cuboid() and cyl() which are not backwards compatible with cube() and cyl(). Almost all primitive objects are overridden and actually there's a request for a feature that will requires overriding all the transformation primitives as well. On Sat, Jun 8, 2024 at 9:18 AM larry via Discuss <discuss@lists.openscad.org> wrote: > On Sat, 2024-06-08 at 06:34 -0500, Leonard Martin Struttmann via > Discuss wrote: > > I, personally, would want this extended warning mode to be ON by > > default. I, too, have spent many hours tracking down why strange > > things were happening in my code only to discover that a library that > > I was using had a module with the same name as I had. > > > > However, this "feature" can be quite useful. BOSL2 overrides > > primitives such as cube() and cylinder() that work exactly like the > > OpenSCAD primitives, while allowing one to position and orient the > > created shape. > > Corect me if I'm wrong, but BOSL2 does not override cube() and > cylinder(). They provide cuboid() and cyl(). > > > On Sat, Jun 8, 2024 at 6:06 AM Michael Möller via Discuss > > <discuss@lists.openscad.org> wrote: > > > Well, trying to be constructive here, it might be implemented as a > > > extended warningmode, off by default. I'm thinking like "lint" in > > > C, a nitpicking mode. > > > > > > Unfortunatly that means a syntax extensions or compiler hints > > > (typically a specially formatted comment fex /*!*/) that signals > > > this redefenition is intentional. > > > > > > If the people who use their spare time to implement such extended > > > warnings feel this is worthwhile, they could also consider flagging > > > unused variables and suchlike. > > > > > > M² > > > > > > lør. 8. jun. 2024 12.43 skrev Jon Bondy via Discuss > > > <discuss@lists.openscad.org>: > > > > I claim this is a serious bug. I can't tell you how much time I > > > > spent altering a module and seeing nothing change. I imagine it > > > > is way too late to change, but it would be helpful if there were > > > > SOME utility that allowed one to know that such an over-ride has > > > > occurred, ESPECIALLY within a single text file. I cannot see > > > > any use for re-defining a module within a file: that surely would > > > > deserve a warning. > > > > Sigh. > > > > On 6/7/2024 11:32 PM, Leonard Martin Struttmann via Discuss > > > > wrote: > > > > > > > > > Jon, yes this is correct. This allows you to override modules > > > > > (even OpenSCAD primitives) with your own, enhanced versions. > > > > > The BOSL2 library does this a lot. It can be confusing at > > > > > times, but it is very powerful. > > > > > > > > > > On Fri, Jun 7, 2024 at 7:58 PM Father Horton via Discuss > > > > > <discuss@lists.openscad.org> wrote: > > > > > > > > > > > When it comes to variables, the last definition in the scope > > > > > > applies. I think the same thing applies here. > > > > > > > > > > > > On Fri, Jun 7, 2024 at 6:43 PM Jon Bondy via Discuss > > > > > > <discuss@lists.openscad.org> wrote: > > > > > > > > > > > > > The following code does not generate any warnings or > > > > > > > errors. It this correct behavior? Using version > > > > > > > 2024.01.14 (git 158c5b94f) > > > > > > > Jon > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > module Pot() > > > > > > > cube(10); > > > > > > > > > > > > > > module Pot() > > > > > > > cube(20); > > > > > > > > > > > > > > Pot(); > > > > > > > > > > > > > > Virus-free.www.avg.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 > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > 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 > > > _______________________________________________ > > > 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 > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
L
larry
Sat, Jun 8, 2024 4:06 PM

On Sat, 2024-06-08 at 09:40 -0400, Adrian Mariano via Discuss wrote:

Consider yourself corrected.  BOSL2 overrides cube() and cylinder()
to add attachment extensions while retaining complete compatibility,
and then also provides cuboid() and cyl() which are not backwards
compatible with cube() and cyl().  Almost all primitive objects are
overridden and actually there's a request for a feature that will
requires overriding all the transformation primitives as well. 

Thanks Adrian! I did not realize that.

On Sat, Jun 8, 2024 at 9:18 AM larry via Discuss
discuss@lists.openscad.org wrote:

On Sat, 2024-06-08 at 06:34 -0500, Leonard Martin Struttmann via
Discuss wrote:

I, personally, would want this extended warning mode to be ON by
default.  I, too, have spent many hours tracking down why strange
things were happening in my code only to discover that a library
that
I was using had a module with the same name as I had.

However, this "feature" can be quite useful.  BOSL2 overrides
primitives such as cube() and cylinder() that work exactly like
the
OpenSCAD primitives, while allowing one to position and orient
the
created shape.

Corect me if I'm wrong, but BOSL2 does not override cube() and
cylinder(). They provide cuboid() and cyl().

On Sat, Jun 8, 2024 at 6:06 AM Michael Möller via Discuss
discuss@lists.openscad.org wrote:

Well, trying to be constructive here, it might be implemented
as a
extended warningmode, off by default. I'm thinking like "lint"
in
C, a nitpicking mode. 

Unfortunatly that means a syntax extensions or compiler hints
(typically a specially formatted comment fex /!/) that
signals
this redefenition is intentional.

If the people who use their spare time to implement such
extended
warnings feel this is worthwhile, they could also consider
flagging
unused variables and suchlike.

lør. 8. jun. 2024 12.43 skrev Jon Bondy via Discuss
discuss@lists.openscad.org:

I claim this is a serious bug.  I can't tell you how much
time I
spent altering a module and seeing nothing change.  I imagine
it
is way too late to change, but it would be helpful if there
were
SOME utility that allowed one to know that such an over-ride
has
occurred, ESPECIALLY  within a single text file.  I cannot
see
any use for re-defining a module within a file: that surely
would
deserve a warning.
Sigh.
On 6/7/2024 11:32 PM, Leonard Martin Struttmann via Discuss
wrote:
 

Jon, yes this is correct.  This allows you to override
modules
(even OpenSCAD primitives) with your own, enhanced
versions. 
The BOSL2 library does this a lot. It can be confusing at
times, but it is very powerful.
 
On Fri, Jun 7, 2024 at 7:58 PM Father Horton via Discuss
discuss@lists.openscad.org wrote:
 

When it comes to variables, the last definition in the
scope
applies. I think the same thing applies here.
 
On Fri, Jun 7, 2024 at 6:43 PM Jon Bondy via Discuss
discuss@lists.openscad.org wrote:
 

The following code does not generate any warnings or
errors.  It this correct behavior?  Using version
2024.01.14 (git 158c5b94f)
Jon

module Pot()
     cube(10);
     
 module Pot()
     cube(20);
     
 Pot();   

 Virus-free.www.avg.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

 
 


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


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


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

On Sat, 2024-06-08 at 09:40 -0400, Adrian Mariano via Discuss wrote: > Consider yourself corrected.  BOSL2 overrides cube() and cylinder() > to add attachment extensions while retaining complete compatibility, > and then also provides cuboid() and cyl() which are not backwards > compatible with cube() and cyl().  Almost all primitive objects are > overridden and actually there's a request for a feature that will > requires overriding all the transformation primitives as well.  Thanks Adrian! I did not realize that. > On Sat, Jun 8, 2024 at 9:18 AM larry via Discuss > <discuss@lists.openscad.org> wrote: > > On Sat, 2024-06-08 at 06:34 -0500, Leonard Martin Struttmann via > > Discuss wrote: > > > I, personally, would want this extended warning mode to be ON by > > > default.  I, too, have spent many hours tracking down why strange > > > things were happening in my code only to discover that a library > > > that > > > I was using had a module with the same name as I had. > > > > > > However, this "feature" can be quite useful.  BOSL2 overrides > > > primitives such as cube() and cylinder() that work exactly like > > > the > > > OpenSCAD primitives, while allowing one to position and orient > > > the > > > created shape. > > > > Corect me if I'm wrong, but BOSL2 does not override cube() and > > cylinder(). They provide cuboid() and cyl(). > > > > > On Sat, Jun 8, 2024 at 6:06 AM Michael Möller via Discuss > > > <discuss@lists.openscad.org> wrote: > > > > Well, trying to be constructive here, it might be implemented > > > > as a > > > > extended warningmode, off by default. I'm thinking like "lint" > > > > in > > > > C, a nitpicking mode.  > > > > > > > > Unfortunatly that means a syntax extensions or compiler hints > > > > (typically a specially formatted comment fex /*!*/) that > > > > signals > > > > this redefenition is intentional. > > > > > > > > If the people who use their spare time to implement such > > > > extended > > > > warnings feel this is worthwhile, they could also consider > > > > flagging > > > > unused variables and suchlike. > > > > > > > > M² > > > > > > > > lør. 8. jun. 2024 12.43 skrev Jon Bondy via Discuss > > > > <discuss@lists.openscad.org>: > > > > > I claim this is a serious bug.  I can't tell you how much > > > > > time I > > > > > spent altering a module and seeing nothing change.  I imagine > > > > > it > > > > > is way too late to change, but it would be helpful if there > > > > > were > > > > > SOME utility that allowed one to know that such an over-ride > > > > > has > > > > > occurred, ESPECIALLY  within a single text file.  I cannot > > > > > see > > > > > any use for re-defining a module within a file: that surely > > > > > would > > > > > deserve a warning. > > > > > Sigh. > > > > > On 6/7/2024 11:32 PM, Leonard Martin Struttmann via Discuss > > > > > wrote: > > > > >   > > > > > > Jon, yes this is correct.  This allows you to override > > > > > > modules > > > > > > (even OpenSCAD primitives) with your own, enhanced > > > > > > versions.  > > > > > > The BOSL2 library does this a lot. It can be confusing at > > > > > > times, but it is very powerful. > > > > > >   > > > > > > On Fri, Jun 7, 2024 at 7:58 PM Father Horton via Discuss > > > > > > <discuss@lists.openscad.org> wrote: > > > > > >   > > > > > > > When it comes to variables, the last definition in the > > > > > > > scope > > > > > > > applies. I think the same thing applies here. > > > > > > >   > > > > > > > On Fri, Jun 7, 2024 at 6:43 PM Jon Bondy via Discuss > > > > > > > <discuss@lists.openscad.org> wrote: > > > > > > >   > > > > > > > > The following code does not generate any warnings or > > > > > > > > errors.  It this correct behavior?  Using version > > > > > > > > 2024.01.14 (git 158c5b94f) > > > > > > > > Jon > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > module Pot() > > > > > > > >      cube(10); > > > > > > > >       > > > > > > > >  module Pot() > > > > > > > >      cube(20); > > > > > > > >       > > > > > > > >  Pot();    > > > > > > > > > > > > > > > >  Virus-free.www.avg.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 > > > > > > > > > > > > >   > > > > > >   > > > > > > _______________________________________________ > > > > > > 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 > > > > _______________________________________________ > > > > 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 > > _______________________________________________ > > 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