discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Namespaces support individual references in PR#6131

CC
Cory Cross
Mon, Sep 1, 2025 10:45 PM

Namespaces have basic functionality for early testers to try out!

You'll need to build from my PR:
https://github.com/openscad/openscad/pull/6131

Current remaining issues:

  • Namespaces defined in a use<> do not work.
  • use<> does not work inside namespaces
  • No top-level assert() or echo() allowed

So namespace bosl2 { include<bosl2/std.scad> } does not yet work. But
you can do:

namespace explicit {
  module cuboid(s) {
    off = is_list(s) ? s[0] : s;
    translate([-off/2,0,0]) cube(s,center=true);
  }
}

namespace implicit {
  favorite = "green";
}

include<BOSL2/std.scad>
using implicit;

color(favorite) right(5) cuboid(5);
explicit::cuboid([8,25,30]);

The tests (serving as further examples) are available in this commit
https://github.com/openscad/openscad/tree/1b5200a10c32c151f02249565d6d77a6dc7421bd/tests/data/scad/namespaces
and are all passing!

-Cory

Namespaces have basic functionality for early testers to try out! You'll need to build from my PR: https://github.com/openscad/openscad/pull/6131 Current remaining issues: * Namespaces defined in a `use<>` do not work. * use<> does not work inside namespaces * No top-level assert() or echo() allowed So `namespace bosl2 { include<bosl2/std.scad> }` does not yet work. But you can do: namespace explicit {   module cuboid(s) {     off = is_list(s) ? s[0] : s;     translate([-off/2,0,0]) cube(s,center=true);   } } namespace implicit {   favorite = "green"; } include<BOSL2/std.scad> using implicit; color(favorite) right(5) cuboid(5); explicit::cuboid([8,25,30]); The tests (serving as further examples) are available in this commit <https://github.com/openscad/openscad/tree/1b5200a10c32c151f02249565d6d77a6dc7421bd/tests/data/scad/namespaces> and are all passing! -Cory