Skip to content

Behavior protocols in classes #19

@lars-reimann

Description

@lars-reimann

Is your feature request related to a problem? Please describe.
Not all chains of functions calls and attribute accesses are valid.

Describe the solution you'd like

  • Specify behavior protocols
  • Repetition (0-n or 1-n)
  • Option
  • Alternative
  • Sequence
  • Syntax: protocol { f* g+ h? (i|j) k } - here f to k are references to callables and attributes (meaning reading accesses)
  • Can refer to instance methods and instance attributes the next surrounding class (cannot access anything in outer classes if nested)
  • Only makes sense in classes since it describes the lifecycle of a single instance
  • At most 1 per class
  • Must only be used in stub files (that's a given if it can only be used in classes)

Semantics

  • If a class has a protocol only call sequences that conform exactly to the protocol are allowed. There must be no unmatched call prefix or suffix and nothing unmatched in-between.
  • Protocol can be overridden by subclasses. However, the overriding protocol must conform to the overridden protocol. A class can only specify additionally, when its own methods/attributes can be used.
  • If a class Sub has no own protocol, but a superclass Super has, instances of Sub must adhere to the protocol defined in Super, when using features of Super. Methods defined in Sub, however, can be used freely.
  • If a class has no own protocol and neither of its superclasses does, all features can be mixed freely.

Tasks

  • Scoping (can point to subterms and functions/attributes defined in the class or inherited from a superclass)
  • Validation: referenced functions and attributes must not be static
  • Validation: no duplicate names for subterms
  • Update Prolog converter
  • Creators
  • Accessors
  • Actual validation that calls conform to the protocol

Metadata

Metadata

Assignees

No one assigned

    Labels

    dsl 🗒️Issues regarding the domain specific programming languagewontfixThis will not be worked on

    Type

    No type

    Projects

    Status

    ✔️ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions