BOSL2 icon indicating copy to clipboard operation
BOSL2 copied to clipboard

Prune undefined values thru struct_set

Open jcorbin opened this issue 1 year ago • 2 comments

Avoid adding [key, undef] pairs to structs.

jcorbin avatar Apr 18 '24 13:04 jcorbin

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

jcorbin avatar Apr 18 '24 19:04 jcorbin

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.

adrianVmariano avatar May 21 '24 19:05 adrianVmariano

This seems abandoned.

revarbat avatar Sep 08 '24 05:09 revarbat