boschresearch / blech

Blech is a language for developing reactive, real-time critical embedded software.
Apache License 2.0
72 stars 5 forks source link

Allow explicit singleton declaration of external vars #53

Open frameworklabs opened 3 years ago

frameworklabs commented 3 years ago

Is your feature request related to a problem? Please describe. extern vars are implicitly declared as singletons to prevent the hosting activity to be called concurrently which could otherwise result in write-write conflicts on that variable. It might be interesting to declare extern vars explicitly too, in order to assign them to an additional custom singleton domain as it is possible with other implicit or explicit singletons like extern function, function or activity.

Describe the solution you'd like This is an example of how external variables would be explicitly assigned to a custom singleton in order to prevent dimmDown() to be called concurrently with the SettingsController activity:

singleton LCD

extern singleton [LCD] function dimmDown ()

activity SettingsController ()
  extern singleton [LCD] var brightness: nat8
  ...
end

Describe alternatives you've considered Alternatively, the hosting activity of the external var (SettingsController in the above example) could be assigned explicitly to the additional singleton domain (LCD). This is possible today and has the same effect but might not be as self documentary as the proposed solution. Also, there is no reason why extern var should be handled differently than other implicit or explicit singleton sources.