Skip to content

Conversation

henrikt-ma
Copy link
Collaborator

@henrikt-ma henrikt-ma commented Aug 27, 2025

This is a new take on #3245, picking up where it was left with the comment #3245 (comment). (I am revisiting this now because of my ongoing test implementation of delay with event generation.)

I think this solves the issue with an acceptable tradeoff between backwards compatibility and feasibility of actually implementing according to specification:

  • As @MarkusOlssonModelon seems to have suggested in phone meeting, delayTime = 0 is forbidden for time-varying delayTime.
  • In the two argument form delay(u, delayTime), the "new" evaluable variability is used to constrain delayTime, making it possible for tools to determine at translation time whether delayTime has been set to zero, but not forcing tools to evaluate.
  • By allowing delayTime = 0 in the two argument form, we avoid the need to give complicated rules for when it is an error to have delayTime = 0 in guarded expressions such as if tau > 0 then delay(u, tau) else u.
  • In principle, the funky technique of only evaluating delayTime when the value would be zero can be avoided by generating different equation systems for the two cases, and make an initialization time decision of which case to use. (Not expecting any tool to actually do it this way.)

Copy link
Collaborator

@HansOlsson HansOlsson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hans:

  • Should add QoI for run-time check.
  • Would prefer that if parameter delayTime is non-evaluable it is still valid, but does not support delayTime=0.

@henrikt-ma
Copy link
Collaborator Author

Hans:

  • Should add QoI for run-time check.
  • Would prefer that if parameter delayTime is non-evaluable it is still valid, but does not support delayTime=0.

I have updated the text accordingly.

I think it would be good, though, to have a migration path for avoiding semantics depending on whether an expression is evaluable. It could be achieved with two deprecations:

  • Deprecate the two argument form with non-evaluable delayTime.
  • Deprecate allowing delayTime = 0 with the three argument form.

@HansOlsson HansOlsson added this to the 2025-October milestone Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants