Skip to content

Design consideration: Should all values for a global attribute be global? #77

@chriseppstein

Description

@chriseppstein

The current code for global attributes lets individual values be marked global, but has no syntax for marking an entire attribute with all its values as global.

It's a little tricky because global attributes are often a forward declaration.

I think we should consider the following:

  1. For states, the entire attribute should be marked as global with the syntax @global [state|foo]; and doing so should not create any attribute values (including the universal value).
  2. For states, disallow marking individual values as global.
  3. If block B inherits from block A, marking an attribute as global, makes all inherited values global, but only when accessed through block B, those values from block A, would remain local.
  4. If block B inherits a global attribute from block A, all values it adds to the global attribute should be global.

In other words:

class Attribute {
  private _isGlobal: boolean;
  get isGlobal(): boolean {
    return this._isGlobal || this.base.isGlobal;
  }
  set isGlobal(v: true) {
    this._isGlobal = v;
  }
}
class AttrValue {
  get isGlobal(): boolean {
    return this.attribute.isGlobal;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions