Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined ID within obj_accessor() has carve-out #10

Open
1 of 3 tasks
jon-gilbert opened this issue May 22, 2023 · 1 comment
Open
1 of 3 tasks

undefined ID within obj_accessor() has carve-out #10

jon-gilbert opened this issue May 22, 2023 · 1 comment

Comments

@jon-gilbert
Copy link
Owner

jon-gilbert commented May 22, 2023

https://github.com/jon-gilbert/openscad_objects/blob/main/object_common_functions.scad#L781-L783

        : (!_defined(id))
            ? default
            : _first([obj[id], default, toc_default, undef]);

It's not clear under what conditions an undefined id here would be supportable.

There is a specific test for this case:
https://github.com/jon-gilbert/openscad_objects/blob/main/tests/test_03_object.scad#L194-L196

    // test to see if we can successfully get back nothing with an undefined object
    o6 = undef;
    assert( obj_accessor(o6, "string", default="default") == "default" );

...but no indication WHY. It may have been a consistency thing (all values callable via obj_accessor(), even when there's no actual object), or a precursor based on default values, but I can't imagine this being used in either of these ways.

  • revert this behavior - it is already disabled from within issue-9
  • make sure nothing else depends on this behavior within 507
  • remove this behavior
@jon-gilbert
Copy link
Owner Author

Ah. Found at least one case where that's used directly:

function arm_length(arm) = sum([ strut_length(arm_strut1(arm), default=0), strut_length(arm_strut2(arm), default=0) ]);

(from 507common's arm.scad).

In this case, there is no easy way to know if the Arm object has strut1 and strut2 defined when calculating the full arm length. So it leverages the "empty object" behavior here as a shortcut and depends on the default argument to be returned, if the Arm strut2 attribute isn't set to a Strut object.

Practically speaking, estimating the correction time within 507 would be difficult. I'm going to re-implement this behavior .... somehow? ... and leave this issue open until this can be confidently purged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant