Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-480

Complete handling of undef/nil

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: PUP 3.7.0
    • Component/s: Compiler
    • Labels:
      None
    • Template:
    • Story Points:
      3
    • Sprint:
      Week 2014-6-25 to 2014-7-9

      Description

      A decision needs to be made regarding handling of undef as nil.
      There is agreement that it should be handled as a nil value everywhere except one case; when setting an attribute value.

      Currently setting undef as an attribute value has the meaning "do not set this attribute" (as opposed to "set this attribute to nil") - which has the effect of selecting the default value at the receiving end (the define, or class).

      While this is probably a reasonable default (what users expect), it poses one problem - it is not possible to override a default value with nil. For Arrays, Hashes and String an empty object can be passed, but for numbers this is not possible.

      OPTIONS:

      • attribute assignment of nil == 'do not set'
      • add operator that sets it to nil (e.g. !>, !=>)
      • add operator if/when needed since this corner case is rare
      • attribute assignment of nil == 'assign nil', add operator that means 'do not set' (e.g. ?=>)

      The choice "attribute assignment of nil == 'do not set' and add operator later if this is a problem' seems to be best compromise.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              henrik.lindberg Henrik Lindberg
              QA Contact:
              Kurt Wall Kurt Wall
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Zendesk Support