discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Renaming the new object() function?

HJ
Hugo Jackson
Sat, Dec 27, 2025 1:08 AM

I’ve renamed a few openSCAD functions to make my code more readable (at least to me). First to go was translate()… a forest of those and I can’t see the logic for the syntax.. I use mv() instead. It was a simple task as I’m sure most if not all of you appreciate, just declare a new module or function with the same parameter list and you’re good to go…

eg: module mv(v =  x,y,z) {
	 translate(v);
	}

And I’m good to go.

The new object function has me stumped though, because the documentation doesn’t provide a parameter syntax that I can understand.
Can someone help me out?

How can I accomplish:

function obj(<parameterList>) = object(<parameterList);

Thanks

I’ve renamed a few openSCAD functions to make my code more readable (at least to me). First to go was translate()… a forest of those and I can’t see the logic for the syntax.. I use mv() instead. It was a simple task as I’m sure most if not all of you appreciate, just declare a new module or function with the same parameter list and you’re good to go… eg: module mv(v = x,y,z) { translate(v); } And I’m good to go. The new object function has me stumped though, because the documentation doesn’t provide a parameter syntax that I can understand. Can someone help me out? How can I accomplish: function obj(<parameterList>) = object(<parameterList); Thanks
CC
Cory Cross
Sat, Dec 27, 2025 2:39 AM

You can't.

On December 26, 2025 5:08:58 PM PST, Hugo Jackson via Discuss discuss@lists.openscad.org wrote:

I’ve renamed a few openSCAD functions to make my code more readable (at least to me). First to go was translate()… a forest of those and I can’t see the logic for the syntax.. I use mv() instead. It was a simple task as I’m sure most if not all of you appreciate, just declare a new module or function with the same parameter list and you’re good to go…

eg: module mv(v =  x,y,z) {
	 translate(v);
	}

And I’m good to go.

The new object function has me stumped though, because the documentation doesn’t provide a parameter syntax that I can understand.
Can someone help me out?

How can I accomplish:

function obj(<parameterList>) = object(<parameterList);

Thanks


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

You can't. On December 26, 2025 5:08:58 PM PST, Hugo Jackson via Discuss <discuss@lists.openscad.org> wrote: >I’ve renamed a few openSCAD functions to make my code more readable (at least to me). First to go was translate()… a forest of those and I can’t see the logic for the syntax.. I use mv() instead. It was a simple task as I’m sure most if not all of you appreciate, just declare a new module or function with the same parameter list and you’re good to go… > > eg: module mv(v = x,y,z) { > translate(v); > } > >And I’m good to go. > > >The new object function has me stumped though, because the documentation doesn’t provide a parameter syntax that I can understand. >Can someone help me out? > >How can I accomplish: > > function obj(<parameterList>) = object(<parameterList); > >Thanks >_______________________________________________ >OpenSCAD mailing list >To unsubscribe send an email to discuss-leave@lists.openscad.org
JB
Jordan Brown
Sun, Dec 28, 2025 4:13 AM

On 12/26/2025 5:08 PM, Hugo Jackson via Discuss wrote:

The new object function has me stumped though, because the documentation doesn’t provide a parameter syntax that I can understand.
Can someone help me out?

How can I accomplish:

function obj(<parameterList>) = object(<parameterList);

Simple answer:  you can't.

More complex answer:  you can't replace max(), min(), str(), or echo(),
either, all for basically the same reasons:  there's no way to write an
OpenSCAD routine that accepts an arbitrary list of parameters.

Still more complex answer:  there have been proposals for allowing
variadic routines.  The most obvious is to have some way to retrieve all
of the arguments as a list.  But that doesn't address named arguments,
so another would be to retrieve all of the arguments as an object.  But
that doesn't address argument lists that mix positional and named
arguments, so maybe you offer both mechanisms.  But that doesn't let you
see the ordering relationship between the arguments, or let you process
multiple arguments with the same name (as echo allows), so maybe you
need a still-more-clever (or still-more-primitive, depending on your
point of view) mechanism.

On 12/26/2025 5:08 PM, Hugo Jackson via Discuss wrote: > The new object function has me stumped though, because the documentation doesn’t provide a parameter syntax that I can understand. > Can someone help me out? > > How can I accomplish: > > function obj(<parameterList>) = object(<parameterList); > Simple answer:  you can't. More complex answer:  you can't replace max(), min(), str(), or echo(), either, all for basically the same reasons:  there's no way to write an OpenSCAD routine that accepts an arbitrary list of parameters. Still more complex answer:  there have been proposals for allowing variadic routines.  The most obvious is to have some way to retrieve all of the arguments as a list.  But that doesn't address named arguments, so another would be to retrieve all of the arguments as an object.  But *that* doesn't address argument lists that mix positional and named arguments, so maybe you offer both mechanisms.  But that doesn't let you see the ordering relationship between the arguments, or let you process multiple arguments with the same name (as echo allows), so maybe you need a still-more-clever (or still-more-primitive, depending on your point of view) mechanism.
BC
Bob Carlson
Sun, Dec 28, 2025 6:05 PM

If you haven’t already, take a look at BOSL2. It already has many of these kind of readability improvements, translate => move, up, down, right, left, fwd, back and countless more.

On Dec 27, 2025, at 21:13, Jordan Brown via Discuss discuss@lists.openscad.org wrote:

On 12/26/2025 5:08 PM, Hugo Jackson via Discuss wrote:

The new object function has me stumped though, because the documentation doesn’t provide a parameter syntax that I can understand.
Can someone help me out?

How can I accomplish:

function obj(<parameterList>) = object(<parameterList);

Simple answer:  you can't.

More complex answer:  you can't replace max(), min(), str(), or echo(), either, all for basically the same reasons:  there's no way to write an OpenSCAD routine that accepts an arbitrary list of parameters.

Still more complex answer:  there have been proposals for allowing variadic routines.  The most obvious is to have some way to retrieve all of the arguments as a list.  But that doesn't address named arguments, so another would be to retrieve all of the arguments as an object.  But that doesn't address argument lists that mix positional and named arguments, so maybe you offer both mechanisms.  But that doesn't let you see the ordering relationship between the arguments, or let you process multiple arguments with the same name (as echo allows), so maybe you need a still-more-clever (or still-more-primitive, depending on your point of view) mechanism.


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

If you haven’t already, take a look at BOSL2. It already has many of these kind of readability improvements, translate => move, up, down, right, left, fwd, back and countless more. > On Dec 27, 2025, at 21:13, Jordan Brown via Discuss <discuss@lists.openscad.org> wrote: > > On 12/26/2025 5:08 PM, Hugo Jackson via Discuss wrote: >> The new object function has me stumped though, because the documentation doesn’t provide a parameter syntax that I can understand. >> Can someone help me out? >> >> How can I accomplish: >> >> function obj(<parameterList>) = object(<parameterList); >> > > Simple answer: you can't. > > More complex answer: you can't replace max(), min(), str(), or echo(), either, all for basically the same reasons: there's no way to write an OpenSCAD routine that accepts an arbitrary list of parameters. > > Still more complex answer: there have been proposals for allowing variadic routines. The most obvious is to have some way to retrieve all of the arguments as a list. But that doesn't address named arguments, so another would be to retrieve all of the arguments as an object. But *that* doesn't address argument lists that mix positional and named arguments, so maybe you offer both mechanisms. But that doesn't let you see the ordering relationship between the arguments, or let you process multiple arguments with the same name (as echo allows), so maybe you need a still-more-clever (or still-more-primitive, depending on your point of view) mechanism. > > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org