Skip to content

Allow fallback method of storing properties for "forbidden" names #579

@dgkf

Description

@dgkf

I'm not sure if I've just had bad luck or if these forbidden properties names are just so useful that they pop up frequently, but this has been a prickly part of S7 for me in a couple different projects now. I've only tried to use S7 in earnest in two packages and both have butted heads with this constraint in different ways.

I'm referring to these forbidden property names.

Just to illustrate a couple cases where this has come up in my exploration so far, I've encountered this during:

  • implementing the debug adapter protocol, which has classes that have names fields. I'm trying to be faithful to the protocol, but I need to have a special case for this one field because this is a forbidden property name.
  • implementing a specialized version of a function that does return type checking, I store the return type as a class property, but again hit this constraint. Here I have more control over the naming convention, but was surprised to see that there are these limits.

I'd like to propose a couple alternative designs

  1. The simplest solution would be to store properties in a attr(obj, "properties") list to avoid any constraints on the names. However, I assume that this was consciously avoided because of the extra lookup.
  2. If a list is undesirable, perhaps introducing it only as a backup option for these specific elements so that nearly all properties remain surface-level attributes, but a few select forbidden names get relegated to an internal list. During property getting and setting, there would be branching logic based on whether the property name is forbidden or not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions