BelfrySCAD / BOSL2

The Belfry OpenScad Library, v2.0. An OpenSCAD library of shapes, masks, and manipulators to make working with OpenSCAD easier. BETA
https://github.com/BelfrySCAD/BOSL2/wiki
BSD 2-Clause "Simplified" License
1.01k stars 115 forks source link

Prune undefined values thru struct_set #1418

Closed jcorbin closed 2 months ago

jcorbin commented 7 months ago

Avoid adding [key, undef] pairs to structs.

jcorbin commented 7 months ago

Hmm, but actually: if this is to be done, then setting an already extant key to undef needs to remove; will update soon :tm:

adrianVmariano commented 6 months ago

Two notes. One is that this functionality sort of exists via the _remove_undefined_vals() private function. The second is that there might be a reason for a user to want a key with an undef value. Like maybe you want to define a key as undefined but have it as a key so that a subsequent set operation with grow=false can still succeed. Some of the existing code in rounding.scad actually works this way, but it creates the struct directly so the change wouldn't break it. However, I do not know for sure that the proposed change is safe for the existing code.

We could expose an option for struct_set that skips undefs. But I'm not sure that deleting fields because they are set to undef is the right behavior. This could all become irrelevant if native structures ever see the light of day.

revarbat commented 2 months ago

This seems abandoned.