discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

redefining a module()

JB
Jon Bondy
Wed, Jun 10, 2026 2:44 PM

I accidentally created two modules with the same name in the same file. 
This caused recursion errors, but my question is why would such a
redefinition not cause a compile-time error?

Jon

--
This email has been checked for viruses by AVG antivirus software.
www.avg.com

I accidentally created two modules with the same name in the same file.  This caused recursion errors, but my question is why would such a redefinition not cause a compile-time error? Jon -- This email has been checked for viruses by AVG antivirus software. www.avg.com
AM
Adrian Mariano
Wed, Jun 10, 2026 5:09 PM

Because in the openscad language a later module definition replaces the
earlier one without an error. Arbitrary choice of the devs like many other
features. Bosl2 actually makes use of this to extend existing modules to
make them behave consistently with certain extensions.

On Wed, Jun 10, 2026 at 10:45 Jon Bondy via Discuss <
discuss@lists.openscad.org> wrote:

I accidentally created two modules with the same name in the same file.
This caused recursion errors, but my question is why would such a
redefinition not cause a compile-time error?

Jon

--
This email has been checked for viruses by AVG antivirus software.
www.avg.com


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

Because in the openscad language a later module definition replaces the earlier one without an error. Arbitrary choice of the devs like many other features. Bosl2 actually makes use of this to extend existing modules to make them behave consistently with certain extensions. On Wed, Jun 10, 2026 at 10:45 Jon Bondy via Discuss < discuss@lists.openscad.org> wrote: > I accidentally created two modules with the same name in the same file. > This caused recursion errors, but my question is why would such a > redefinition not cause a compile-time error? > > Jon > > > -- > This email has been checked for viruses by AVG antivirus software. > www.avg.com > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org
JB
Jon Bondy
Wed, Jun 10, 2026 6:38 PM

What a horror.

On 6/10/2026 1:09 PM, Adrian Mariano via Discuss wrote:

Because in the openscad language a later module definition replaces
the earlier one without an error. Arbitrary choice of the devs like
many other features. Bosl2 actually makes use of this to extend
existing modules to make them behave consistently with certain extensions.

On Wed, Jun 10, 2026 at 10:45 Jon Bondy via Discuss
discuss@lists.openscad.org wrote:

 I accidentally created two modules with the same name in the same
 file.
 This caused recursion errors, but my question is why would such a
 redefinition not cause a compile-time error?

 Jon


 -- 
 This email has been checked for viruses by AVG antivirus software.
 www.avg.com
 <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=-Njh9P7H_O7ERhzRgNCxSBtoK1mhCNysx4Q8YZxubbnyjReoUhGcjGqWV0Q2EDt8&s=Liw8SQJ2wduNEviL2OQwhzRzCnIHMYFL8BUFyISPOK0&e=>
 _______________________________________________
 OpenSCAD mailing list
 To unsubscribe send an email to discuss-leave@lists.openscad.org

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

What a horror. On 6/10/2026 1:09 PM, Adrian Mariano via Discuss wrote: > Because in the openscad language a later module definition replaces > the earlier one without an error. Arbitrary choice of the devs like > many other features. Bosl2 actually makes use of this to extend > existing modules to make them behave consistently with certain extensions. > > On Wed, Jun 10, 2026 at 10:45 Jon Bondy via Discuss > <discuss@lists.openscad.org> wrote: > > I accidentally created two modules with the same name in the same > file. > This caused recursion errors, but my question is why would such a > redefinition not cause a compile-time error? > > Jon > > > -- > This email has been checked for viruses by AVG antivirus software. > www.avg.com > <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=-Njh9P7H_O7ERhzRgNCxSBtoK1mhCNysx4Q8YZxubbnyjReoUhGcjGqWV0Q2EDt8&s=Liw8SQJ2wduNEviL2OQwhzRzCnIHMYFL8BUFyISPOK0&e=> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org
LD
lee.deraud@roadrunner.com
Wed, Jun 10, 2026 7:44 PM

No more so than method overloading/overriding in C++/Java/etc.

From: Jon Bondy via Discuss discuss@lists.openscad.org
Sent: Wednesday, June 10, 2026 11:39 AM
To: OpenSCAD general discussion Mailing-list discuss@lists.openscad.org
Cc: Jon Bondy jon@jonbondy.com
Subject: [OpenSCAD] Re: redefining a module()

What a horror.

On 6/10/2026 1:09 PM, Adrian Mariano via Discuss wrote:

Because in the openscad language a later module definition replaces the earlier one without an error. Arbitrary choice of the devs like many other features. Bosl2 actually makes use of this to extend existing modules to make them behave consistently with certain extensions.

On Wed, Jun 10, 2026 at 10:45 Jon Bondy via Discuss <discuss@lists.openscad.org mailto:discuss@lists.openscad.org > wrote:

I accidentally created two modules with the same name in the same file.
This caused recursion errors, but my question is why would such a
redefinition not cause a compile-time error?

Jon

--
This email has been checked for viruses by AVG antivirus software.
www.avg.com https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=-Njh9P7H_O7ERhzRgNCxSBtoK1mhCNysx4Q8YZxubbnyjReoUhGcjGqWV0Q2EDt8&s=Liw8SQJ2wduNEviL2OQwhzRzCnIHMYFL8BUFyISPOK0&e=


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


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org mailto: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. http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient www.avg.com

No more so than method overloading/overriding in C++/Java/etc. From: Jon Bondy via Discuss <discuss@lists.openscad.org> Sent: Wednesday, June 10, 2026 11:39 AM To: OpenSCAD general discussion Mailing-list <discuss@lists.openscad.org> Cc: Jon Bondy <jon@jonbondy.com> Subject: [OpenSCAD] Re: redefining a module() What a horror. On 6/10/2026 1:09 PM, Adrian Mariano via Discuss wrote: Because in the openscad language a later module definition replaces the earlier one without an error. Arbitrary choice of the devs like many other features. Bosl2 actually makes use of this to extend existing modules to make them behave consistently with certain extensions. On Wed, Jun 10, 2026 at 10:45 Jon Bondy via Discuss <discuss@lists.openscad.org <mailto:discuss@lists.openscad.org> > wrote: I accidentally created two modules with the same name in the same file. This caused recursion errors, but my question is why would such a redefinition not cause a compile-time error? Jon -- This email has been checked for viruses by AVG antivirus software. www.avg.com <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=-Njh9P7H_O7ERhzRgNCxSBtoK1mhCNysx4Q8YZxubbnyjReoUhGcjGqWV0Q2EDt8&s=Liw8SQJ2wduNEviL2OQwhzRzCnIHMYFL8BUFyISPOK0&e=> _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto:discuss-leave@lists.openscad.org> _______________________________________________ OpenSCAD mailing list To unsubscribe send an email to discuss-leave@lists.openscad.org <mailto: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. <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> www.avg.com
JB
Jon Bondy
Wed, Jun 10, 2026 8:28 PM

I can understand method overloading, but I would hope the syntax made it
clear that it was intentional, not just a brain fart.

I cannot understand how discarding code (the original module) without a
whimper is good or useful, but I defer to Adrian that this is a feature.

Personally, I would LOVE an option to produce a warning message any time
I accidentally re-used ANY name in my code: "variable", function,
module.  In other's code, I don't care.

I imagine I will hear little support for my position.

Jon

On 6/10/2026 3:44 PM, Lee DeRaud via Discuss wrote:

No more so than method overloading/overriding in C++/Java/etc.

*From:*Jon Bondy via Discuss discuss@lists.openscad.org
Sent: Wednesday, June 10, 2026 11:39 AM
To: OpenSCAD general discussion Mailing-list
discuss@lists.openscad.org
Cc: Jon Bondy jon@jonbondy.com
Subject: [OpenSCAD] Re: redefining a module()

What a horror.

On 6/10/2026 1:09 PM, Adrian Mariano via Discuss wrote:

 Because in the openscad language a later module definition
 replaces the earlier one without an error. Arbitrary choice of the
 devs like many other features. Bosl2 actually makes use of this to
 extend existing modules to make them behave consistently with
 certain extensions.

 On Wed, Jun 10, 2026 at 10:45 Jon Bondy via Discuss
 <discuss@lists.openscad.org> wrote:

     I accidentally created two modules with the same name in the
     same file.
     This caused recursion errors, but my question is why would such a
     redefinition not cause a compile-time error?

     Jon


     -- 
     This email has been checked for viruses by AVG antivirus software.
     www.avg.com
     <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=-Njh9P7H_O7ERhzRgNCxSBtoK1mhCNysx4Q8YZxubbnyjReoUhGcjGqWV0Q2EDt8&s=Liw8SQJ2wduNEviL2OQwhzRzCnIHMYFL8BUFyISPOK0&e=>
     _______________________________________________
     OpenSCAD mailing list
     To unsubscribe send an email to discuss-leave@lists.openscad.org



 _______________________________________________

 OpenSCAD mailing list

 To unsubscribe send an email todiscuss-leave@lists.openscad.org

https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com_email-2Dsignature-3Futm-5Fmedium-3Demail-26utm-5Fsource-3Dlink-26utm-5Fcampaign-3Dsig-2Demail-26utm-5Fcontent-3Demailclient&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=5vtBx2AGDvPwVflOMHyWJuCuJGqpIFZo4sykyM5PpOZLxFeNYYCerKzEM91SiGPj&s=8sKI-JKHSZ0ywkpSMNlP9g_bv2rbB9TDHychGGySetQ&e=

Virus-free.www.avg.com
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com_email-2Dsignature-3Futm-5Fmedium-3Demail-26utm-5Fsource-3Dlink-26utm-5Fcampaign-3Dsig-2Demail-26utm-5Fcontent-3Demailclient&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=5vtBx2AGDvPwVflOMHyWJuCuJGqpIFZo4sykyM5PpOZLxFeNYYCerKzEM91SiGPj&s=8sKI-JKHSZ0ywkpSMNlP9g_bv2rbB9TDHychGGySetQ&e=


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

I can understand method overloading, but I would hope the syntax made it clear that it was intentional, not just a brain fart. I cannot understand how discarding code (the original module) without a whimper is good or useful, but I defer to Adrian that this is a feature. Personally, I would LOVE an option to produce a warning message any time I accidentally re-used ANY name in my code: "variable", function, module.  In other's code, I don't care. I imagine I will hear little support for my position. Jon On 6/10/2026 3:44 PM, Lee DeRaud via Discuss wrote: > > No more so than method overloading/overriding in C++/Java/etc. > > *From:*Jon Bondy via Discuss <discuss@lists.openscad.org> > *Sent:* Wednesday, June 10, 2026 11:39 AM > *To:* OpenSCAD general discussion Mailing-list > <discuss@lists.openscad.org> > *Cc:* Jon Bondy <jon@jonbondy.com> > *Subject:* [OpenSCAD] Re: redefining a module() > > What a horror. > > On 6/10/2026 1:09 PM, Adrian Mariano via Discuss wrote: > > Because in the openscad language a later module definition > replaces the earlier one without an error. Arbitrary choice of the > devs like many other features. Bosl2 actually makes use of this to > extend existing modules to make them behave consistently with > certain extensions. > > On Wed, Jun 10, 2026 at 10:45 Jon Bondy via Discuss > <discuss@lists.openscad.org> wrote: > > I accidentally created two modules with the same name in the > same file. > This caused recursion errors, but my question is why would such a > redefinition not cause a compile-time error? > > Jon > > > -- > This email has been checked for viruses by AVG antivirus software. > www.avg.com > <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=-Njh9P7H_O7ERhzRgNCxSBtoK1mhCNysx4Q8YZxubbnyjReoUhGcjGqWV0Q2EDt8&s=Liw8SQJ2wduNEviL2OQwhzRzCnIHMYFL8BUFyISPOK0&e=> > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org > > > > _______________________________________________ > > OpenSCAD mailing list > > To unsubscribe send an email todiscuss-leave@lists.openscad.org > > <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com_email-2Dsignature-3Futm-5Fmedium-3Demail-26utm-5Fsource-3Dlink-26utm-5Fcampaign-3Dsig-2Demail-26utm-5Fcontent-3Demailclient&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=5vtBx2AGDvPwVflOMHyWJuCuJGqpIFZo4sykyM5PpOZLxFeNYYCerKzEM91SiGPj&s=8sKI-JKHSZ0ywkpSMNlP9g_bv2rbB9TDHychGGySetQ&e=> > > > > Virus-free.www.avg.com > <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com_email-2Dsignature-3Futm-5Fmedium-3Demail-26utm-5Fsource-3Dlink-26utm-5Fcampaign-3Dsig-2Demail-26utm-5Fcontent-3Demailclient&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=5vtBx2AGDvPwVflOMHyWJuCuJGqpIFZo4sykyM5PpOZLxFeNYYCerKzEM91SiGPj&s=8sKI-JKHSZ0ywkpSMNlP9g_bv2rbB9TDHychGGySetQ&e=> > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org
GB
Glenn Butcher
Wed, Jun 10, 2026 9:08 PM

Just one more rule about using OpenSCAD.  There are no laws of physics
governing how programming languages should work, and in this case the
override rule serves BOSL2.  It's what keeps me from using BOSL2 (right
now, subject to change), but that's my personal angst, no one else's.

Glenn Butcher
Former compiler design teacher.

On 6/10/2026 12:38 PM, Jon Bondy via Discuss wrote:

What a horror.

On 6/10/2026 1:09 PM, Adrian Mariano via Discuss wrote:

Because in the openscad language a later module definition replaces
the earlier one without an error. Arbitrary choice of the devs like
many other features. Bosl2 actually makes use of this to extend
existing modules to make them behave consistently with certain
extensions.

On Wed, Jun 10, 2026 at 10:45 Jon Bondy via Discuss
discuss@lists.openscad.org wrote:

 I accidentally created two modules with the same name in the same
 file.
 This caused recursion errors, but my question is why would such a
 redefinition not cause a compile-time error?

 Jon


 -- 
 This email has been checked for viruses by AVG antivirus software.
 www.avg.com
 <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=-Njh9P7H_O7ERhzRgNCxSBtoK1mhCNysx4Q8YZxubbnyjReoUhGcjGqWV0Q2EDt8&s=Liw8SQJ2wduNEviL2OQwhzRzCnIHMYFL8BUFyISPOK0&e=>
 _______________________________________________
 OpenSCAD mailing list
 To unsubscribe send an email to discuss-leave@lists.openscad.org

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

Just one more rule about using OpenSCAD.  There are no laws of physics governing how programming languages should work, and in this case the override rule serves BOSL2.  It's what keeps me from using BOSL2 (right now, subject to change), but that's my personal angst, no one else's. Glenn Butcher Former compiler design teacher. On 6/10/2026 12:38 PM, Jon Bondy via Discuss wrote: > > What a horror. > > > On 6/10/2026 1:09 PM, Adrian Mariano via Discuss wrote: >> Because in the openscad language a later module definition replaces >> the earlier one without an error. Arbitrary choice of the devs like >> many other features. Bosl2 actually makes use of this to extend >> existing modules to make them behave consistently with certain >> extensions. >> >> On Wed, Jun 10, 2026 at 10:45 Jon Bondy via Discuss >> <discuss@lists.openscad.org> wrote: >> >> I accidentally created two modules with the same name in the same >> file. >> This caused recursion errors, but my question is why would such a >> redefinition not cause a compile-time error? >> >> Jon >> >> >> -- >> This email has been checked for viruses by AVG antivirus software. >> www.avg.com >> <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=-Njh9P7H_O7ERhzRgNCxSBtoK1mhCNysx4Q8YZxubbnyjReoUhGcjGqWV0Q2EDt8&s=Liw8SQJ2wduNEviL2OQwhzRzCnIHMYFL8BUFyISPOK0&e=> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email to discuss-leave@lists.openscad.org >> >> >> _______________________________________________ >> OpenSCAD mailing list >> To unsubscribe send an email todiscuss-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> > > > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2> > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email todiscuss-leave@lists.openscad.org
CC
Cory Cross
Wed, Jun 10, 2026 9:20 PM

On 6/10/26 1:28 PM, Jon Bondy via Discuss wrote:

I cannot understand how discarding code (the original module) without
a whimper is good or useful, but I defer to Adrian that this is a feature.

It was added as a quick hack to allow overwriting a variable definition
by passing in new assignment values on the command line. Unfortunately
that hacky implementation had a side effect on the semantics of the
language and make it quite unusual.

Cory

On 6/10/26 1:28 PM, Jon Bondy via Discuss wrote: > I cannot understand how discarding code (the original module) without > a whimper is good or useful, but I defer to Adrian that this is a feature. It was added as a quick hack to allow overwriting a variable definition by passing in new assignment values on the command line. Unfortunately that hacky implementation had a side effect on the semantics of the language and make it quite unusual. Cory
AM
Adrian Mariano
Wed, Jun 10, 2026 9:32 PM

I wouldn't call it a feature exactly.  It's more like we figured out a hack
to make use of a questionable design choice in a postive, feature-like
way.

Lee compares it to method overloading, but actually it was rather tricky to
make it work.  In BOSL2 our goal is to provide some feature extensions for
consistency, so that users can still use cube() or translate() and all the
BOSL2 features work properly.  (The alternative is basically to tell BOSL2
users they should never use any of a list of 11 builtins).  We intend for
this to be transparent---you should not be able to tell that we have
replaced the built-ins.  All code that ran before should still run and
produce the same result.  In order to do that, we need to replace cube()
with a new module but still be able to call the old cube(), which requires
"using" a library that defines things like _cube() that call the original
cube().  This is messy, complex, and not obvious.  It would be much better
if there was a simple way to redefine a module while still being able to
access the previous definition.

We have taken care to make sure that cube() does the same thing as before,
but there's nothing to keep a library from being more sloppy about a
redefinition, or even nefariously redefining cube() to make cubes that are
1 unit too small, so in that respect, this is a dangerous feature, though a
cleaner redefinition feature wouldn't prevent this sort of thing.

On Wed, Jun 10, 2026 at 4:44 PM Jon Bondy via Discuss <
discuss@lists.openscad.org> wrote:

I can understand method overloading, but I would hope the syntax made it
clear that it was intentional, not just a brain fart.

I cannot understand how discarding code (the original module) without a
whimper is good or useful, but I defer to Adrian that this is a feature.

Personally, I would LOVE an option to produce a warning message any time I
accidentally re-used ANY name in my code: "variable", function, module.  In
other's code, I don't care.

I imagine I will hear little support for my position.

Jon

On 6/10/2026 3:44 PM, Lee DeRaud via Discuss wrote:

No more so than method overloading/overriding in C++/Java/etc.

From: Jon Bondy via Discuss discuss@lists.openscad.org
discuss@lists.openscad.org
Sent: Wednesday, June 10, 2026 11:39 AM
To: OpenSCAD general discussion Mailing-list
discuss@lists.openscad.org discuss@lists.openscad.org
Cc: Jon Bondy jon@jonbondy.com jon@jonbondy.com
Subject: [OpenSCAD] Re: redefining a module()

What a horror.

On 6/10/2026 1:09 PM, Adrian Mariano via Discuss wrote:

Because in the openscad language a later module definition replaces the
earlier one without an error. Arbitrary choice of the devs like many other
features. Bosl2 actually makes use of this to extend existing modules to
make them behave consistently with certain extensions.

On Wed, Jun 10, 2026 at 10:45 Jon Bondy via Discuss <
discuss@lists.openscad.org> wrote:

I accidentally created two modules with the same name in the same file.
This caused recursion errors, but my question is why would such a
redefinition not cause a compile-time error?

Jon

--
This email has been checked for viruses by AVG antivirus software.
www.avg.com
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=-Njh9P7H_O7ERhzRgNCxSBtoK1mhCNysx4Q8YZxubbnyjReoUhGcjGqWV0Q2EDt8&s=Liw8SQJ2wduNEviL2OQwhzRzCnIHMYFL8BUFyISPOK0&e=


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

https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com_email-2Dsignature-3Futm-5Fmedium-3Demail-26utm-5Fsource-3Dlink-26utm-5Fcampaign-3Dsig-2Demail-26utm-5Fcontent-3Demailclient&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=5vtBx2AGDvPwVflOMHyWJuCuJGqpIFZo4sykyM5PpOZLxFeNYYCerKzEM91SiGPj&s=8sKI-JKHSZ0ywkpSMNlP9g_bv2rbB9TDHychGGySetQ&e=

Virus-free.www.avg.com
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com_email-2Dsignature-3Futm-5Fmedium-3Demail-26utm-5Fsource-3Dlink-26utm-5Fcampaign-3Dsig-2Demail-26utm-5Fcontent-3Demailclient&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=5vtBx2AGDvPwVflOMHyWJuCuJGqpIFZo4sykyM5PpOZLxFeNYYCerKzEM91SiGPj&s=8sKI-JKHSZ0ywkpSMNlP9g_bv2rbB9TDHychGGySetQ&e=


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

I wouldn't call it a feature exactly. It's more like we figured out a hack to make use of a questionable design choice in a postive, feature-like way. Lee compares it to method overloading, but actually it was rather tricky to make it work. In BOSL2 our goal is to provide some feature extensions for consistency, so that users can still use cube() or translate() and all the BOSL2 features work properly. (The alternative is basically to tell BOSL2 users they should never use any of a list of 11 builtins). We intend for this to be transparent---you should not be able to tell that we have replaced the built-ins. All code that ran before should still run and produce the same result. In order to do that, we need to replace cube() with a new module but still be able to call the old cube(), which requires "using" a library that defines things like _cube() that call the original cube(). This is messy, complex, and not obvious. It would be much better if there was a simple way to redefine a module while still being able to access the previous definition. We have taken care to make sure that cube() does the same thing as before, but there's nothing to keep a library from being more sloppy about a redefinition, or even nefariously redefining cube() to make cubes that are 1 unit too small, so in that respect, this is a dangerous feature, though a cleaner redefinition feature wouldn't prevent this sort of thing. On Wed, Jun 10, 2026 at 4:44 PM Jon Bondy via Discuss < discuss@lists.openscad.org> wrote: > I can understand method overloading, but I would hope the syntax made it > clear that it was intentional, not just a brain fart. > > I cannot understand how discarding code (the original module) without a > whimper is good or useful, but I defer to Adrian that this is a feature. > > Personally, I would LOVE an option to produce a warning message any time I > accidentally re-used ANY name in my code: "variable", function, module. In > other's code, I don't care. > > I imagine I will hear little support for my position. > > Jon > > > On 6/10/2026 3:44 PM, Lee DeRaud via Discuss wrote: > > No more so than method overloading/overriding in C++/Java/etc. > > > > *From:* Jon Bondy via Discuss <discuss@lists.openscad.org> > <discuss@lists.openscad.org> > *Sent:* Wednesday, June 10, 2026 11:39 AM > *To:* OpenSCAD general discussion Mailing-list > <discuss@lists.openscad.org> <discuss@lists.openscad.org> > *Cc:* Jon Bondy <jon@jonbondy.com> <jon@jonbondy.com> > *Subject:* [OpenSCAD] Re: redefining a module() > > > > What a horror. > > > > On 6/10/2026 1:09 PM, Adrian Mariano via Discuss wrote: > > Because in the openscad language a later module definition replaces the > earlier one without an error. Arbitrary choice of the devs like many other > features. Bosl2 actually makes use of this to extend existing modules to > make them behave consistently with certain extensions. > > > > On Wed, Jun 10, 2026 at 10:45 Jon Bondy via Discuss < > discuss@lists.openscad.org> wrote: > > I accidentally created two modules with the same name in the same file. > This caused recursion errors, but my question is why would such a > redefinition not cause a compile-time error? > > Jon > > > -- > This email has been checked for viruses by AVG antivirus software. > www.avg.com > <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=-Njh9P7H_O7ERhzRgNCxSBtoK1mhCNysx4Q8YZxubbnyjReoUhGcjGqWV0Q2EDt8&s=Liw8SQJ2wduNEviL2OQwhzRzCnIHMYFL8BUFyISPOK0&e=> > _______________________________________________ > 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 > > > > > <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com_email-2Dsignature-3Futm-5Fmedium-3Demail-26utm-5Fsource-3Dlink-26utm-5Fcampaign-3Dsig-2Demail-26utm-5Fcontent-3Demailclient&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=5vtBx2AGDvPwVflOMHyWJuCuJGqpIFZo4sykyM5PpOZLxFeNYYCerKzEM91SiGPj&s=8sKI-JKHSZ0ywkpSMNlP9g_bv2rbB9TDHychGGySetQ&e=> > > Virus-free.www.avg.com > <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.avg.com_email-2Dsignature-3Futm-5Fmedium-3Demail-26utm-5Fsource-3Dlink-26utm-5Fcampaign-3Dsig-2Demail-26utm-5Fcontent-3Demailclient&d=DwMFaQ&c=euGZstcaTDllvimEN8b7jXrwqOf-v5A_CdpgnVfiiMM&r=AsrE-c7ZR7B2Kyr3qgfvvppkCEBVsNmwEMndcrRSuOI&m=5vtBx2AGDvPwVflOMHyWJuCuJGqpIFZo4sykyM5PpOZLxFeNYYCerKzEM91SiGPj&s=8sKI-JKHSZ0ywkpSMNlP9g_bv2rbB9TDHychGGySetQ&e=> > > > > _______________________________________________ > 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
JB
Jordan Brown
Thu, Jun 11, 2026 1:07 AM

[ Sigh.  I came to rely on a Thunderbird add-in that lets you set rules
for automatically selecting an appropriate address to send from, and
over the last few years TB upgrades have broken that add-in several
times.  Those typing habits are difficult to overcome. Thunderbird is
the worst mail client ever, except for all of the others. ]

On 6/10/2026 11:38 AM, Jon Bondy via Discuss wrote:

What a horror.

It's definitely a power tool with sharp edges and few safety features. 
I think it could have more safety features, to make it more difficult
to shoot yourself in the foot.

Adrian says:

a cleaner redefinition feature wouldn't prevent this sort of thing.  

But a cleaner feature could prevent accidentally overriding a
previously-defined module or function.  Indeed, an intentional but
poor-quality override would still be a problem.  Another concern is that
the next version of OpenSCAD might include new features for the core
module/function that conflict with the features added by the override.

Cory says:

It was added as a quick hack to allow overwriting a variable
definition by passing in new assignment values on the command line.

That explains variable overriding.  It doesn't explain module/function
overriding.

[ Sigh.  I came to rely on a Thunderbird add-in that lets you set rules for automatically selecting an appropriate address to send from, and over the last few years TB upgrades have broken that add-in several times.  Those typing habits are difficult to overcome. Thunderbird is the worst mail client ever, except for all of the others. ] On 6/10/2026 11:38 AM, Jon Bondy via Discuss wrote: > > What a horror. > It's definitely a power tool with sharp edges and few safety features.  I think it could have *more* safety features, to make it more difficult to shoot yourself in the foot. Adrian says: > a cleaner redefinition feature wouldn't prevent this sort of thing.   But a cleaner feature could prevent *accidentally* overriding a previously-defined module or function.  Indeed, an intentional but poor-quality override would still be a problem.  Another concern is that the next version of OpenSCAD might include new features for the core module/function that conflict with the features added by the override. Cory says: > It was added as a quick hack to allow overwriting a variable > definition by passing in new assignment values on the command line. That explains variable overriding.  It doesn't explain module/function overriding.
AM
Adrian Mariano
Thu, Jun 11, 2026 2:47 AM

Yeah, it's true that a special override feature would not be accidentally
activated.  At least the way we've done it, I don't think new features
could conflict with our override, but if they involve new parameters, the
override wouldn't support them simply because it wouldn't accept them and
pass them on to the original module, so it would cease to be transparent.
Too bad there's no way to gather all the parameters of a module and pass
them to a child module.

On Wed, Jun 10, 2026 at 9:08 PM Jordan Brown via Discuss <
discuss@lists.openscad.org> wrote:

[ Sigh.  I came to rely on a Thunderbird add-in that lets you set rules
for automatically selecting an appropriate address to send from, and over
the last few years TB upgrades have broken that add-in several times.
Those typing habits are difficult to overcome. Thunderbird is the worst
mail client ever, except for all of the others. ]

On 6/10/2026 11:38 AM, Jon Bondy via Discuss wrote:

What a horror.

It's definitely a power tool with sharp edges and few safety features.  I
think it could have more safety features, to make it more difficult to
shoot yourself in the foot.

Adrian says:

a cleaner redefinition feature wouldn't prevent this sort of thing.

But a cleaner feature could prevent accidentally overriding a
previously-defined module or function.  Indeed, an intentional but
poor-quality override would still be a problem.  Another concern is that
the next version of OpenSCAD might include new features for the core
module/function that conflict with the features added by the override.

Cory says:

It was added as a quick hack to allow overwriting a variable definition by
passing in new assignment values on the command line.

That explains variable overriding.  It doesn't explain module/function
overriding.


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

Yeah, it's true that a special override feature would not be accidentally activated. At least the way we've done it, I don't think new features could *conflict* with our override, but if they involve new parameters, the override wouldn't support them simply because it wouldn't accept them and pass them on to the original module, so it would cease to be transparent. Too bad there's no way to gather all the parameters of a module and pass them to a child module. On Wed, Jun 10, 2026 at 9:08 PM Jordan Brown via Discuss < discuss@lists.openscad.org> wrote: > [ Sigh. I came to rely on a Thunderbird add-in that lets you set rules > for automatically selecting an appropriate address to send from, and over > the last few years TB upgrades have broken that add-in several times. > Those typing habits are difficult to overcome. Thunderbird is the worst > mail client ever, except for all of the others. ] > > On 6/10/2026 11:38 AM, Jon Bondy via Discuss wrote: > > What a horror. > > It's definitely a power tool with sharp edges and few safety features. I > think it could have *more* safety features, to make it more difficult to > shoot yourself in the foot. > > Adrian says: > > a cleaner redefinition feature wouldn't prevent this sort of thing. > > > But a cleaner feature could prevent *accidentally* overriding a > previously-defined module or function. Indeed, an intentional but > poor-quality override would still be a problem. Another concern is that > the next version of OpenSCAD might include new features for the core > module/function that conflict with the features added by the override. > > Cory says: > > It was added as a quick hack to allow overwriting a variable definition by > passing in new assignment values on the command line. > > > That explains variable overriding. It doesn't explain module/function > overriding. > > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org