Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

MGLStyleLayer properties should be null_resettable or nonnull #6126

Closed

Description

@1ec5

As of #6076, all the layout and paint properties on MGLStyleLayer subclasses are marked as nullable, but nil has an implicit meaning that we describe in documentation comments. Relying on documentation to assign a meaning to nil is fragile. Now that #6124 has landed, MGLStyleLayer properties should be either null_resettable or nonnull. null_resettable is pretty rare among Cocoa APIs, but nullable with an implicit meaning assigned to nil is even rarer.

On the plus side, the default behavior with null_resettable is easier to document and intuit, and we could even potentially change many NSNumber- and NSValue-typed properties back to primitive integers and enumerations, depending on how #5970 shakes out. (If we do go back to primitive types, we’ll need to use assign semantics, which precludes null_resettable behavior.)

On the other hand, the SDK will be unable to distinguish between an unset property and one that happens to be the default. Any attempted serialization from MGLStyleLayers to style JSON would be lossy, but it isn’t clear to me that this contrived use case would outweigh the benefits.

/cc @frederoni @incanus @friedbunny @boundsj @jfirebaugh

Activity

  1. added
    iOS
    macOS
    on Aug 23, 2016
  2. added this to the ios-v3.4.0 milestone on Aug 23, 2016
  3. boundsj commented on Aug 24, 2016

    @boundsj
    Contributor

    👍 I'm for using null_resettable and removing the fragile documentation. It is hard for me to imagine that the edge case of needing to distinguish between unset and default will matter very often at the SDK level.

  4. added
    beta blocker
    on Aug 25, 2016
  5. 1ec5 commented on Aug 26, 2016

    @1ec5
    ContributorAuthor

    Also note the affect the nullability qualifiers will have on Swift:

    • nullable means optionals all over the place and therefore lots of question marks or (unsafe) exclamation marks all over client code.
    • null_resettable means implicitly unwrapped optionals all over the place but clean (and safe) client code.
    • nonnull means clean headers and clean client code, at the cost of convenience when resetting properties.
  6. self-assigned this
    on Aug 26, 2016
  7. added 2 commits that reference this issue on Aug 26, 2016
    261d601
    9d368ea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

beta blockeriOSmacOSrefactorruntime styling

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions