Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.9
    • Component/s: Parser
    • Labels:
      None
    • Environment:
      All
    • Number of attachments :
      0

      Description

      Allow a way to specify class macros in a clean way.
      Currently we've no way to specify a macro that affect a class. This lead to using AstAttrbiutes on classes.
      When the class has several such attributes, it starts to get unsightly.

      The issue rose when discussing class' contracts, btw. The proposed syntax is macros for the method contract, but there is no good way to specify a class contract without using an attribute (when you specify method's class with macros, that is not consistent).

      I suggest a way to specify a macro on a class, similar to the way you can on methods. Considerring the possible confusion with properties, it would be nice to prefix them with @, so the following code is possible:

      class MyClass:

      @disposable #macro with no body, behave just like an attribute, with better syntax

      @invariant: #macro with body,
      var != null
      count > 0

        Issue Links

          Activity

          Hide
          Rodrigo B. de Oliveira added a comment -

          I'm currently considering demanding either a type or an initializer for a field. That way, the syntax for macros could be the same for types.

          Show
          Rodrigo B. de Oliveira added a comment - I'm currently considering demanding either a type or an initializer for a field. That way, the syntax for macros could be the same for types.
          Hide
          Ayende Rahien added a comment -

          That make a lot of sense, there are rare cases for object fields on an class, so that is a low impact change.

          Show
          Ayende Rahien added a comment - That make a lot of sense, there are rare cases for object fields on an class, so that is a low impact change.
          Hide
          Rodrigo B. de Oliveira added a comment -

          Implemented in revision 3194.

          Show
          Rodrigo B. de Oliveira added a comment - Implemented in revision 3194.
          Hide
          Rodrigo B. de Oliveira added a comment -

          Remaining issues documented separately.

          Show
          Rodrigo B. de Oliveira added a comment - Remaining issues documented separately.

            People

            • Assignee:
              Rodrigo B. de Oliveira
              Reporter:
              Ayende Rahien
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: