Skip to content

Add new() syntax to events #3825

@TorkelE

Description

@TorkelE

With the latest version of MTK we now have the prev() syntax to designate in events which values are from before the triggering of the event (and which are from after the event). I.e.

(X ~ 2.0) => [X ~ pre(X) + 1.0]

designates an event where, once X reaches the value 2.0, 1.0 unit for X is added.

I think it would be nice to support a syntax where one can rather designate which values are from the updated system, i.e. so that one can write:

(X ~ 2.0) => [new(X) ~ X + 1.0]

Advantages include:

  • The same syntax is used for the condition and affect part. I.e. right now the pre() is implied across all conditions. While this is implicitly obvious, it is still nice to have a syntax be consistent across the entire event.
  • In the vast majority of cases (at least that I can imagine), there is only a single symbolic variable for the post-event system (and this is typically isolated on the lhs). However, multiple pre-event symbolic variables are not that plausible. The syntax new(X) ~ ... simply feels a bit cleaner than X ~ pre(X + Xup + ...).

Considerations:

  • Practically, an event declared using the new notation could directly (and internally) be converted to one using the pre notation (but just flipping all variables).
  • Events using both new and pre should probably be disallowed.
  • This doesn't actually add any new functionality, and only offers some syntax improvement, so it is relatively low priority.

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