Open sanderr opened 8 months ago
what if allocation is part of the for body?
I can tell you it most certainly is, this is the only way to not have the allocated attributes set to null
on the constructed object (as the api requires a default value defined in the model for these read-only attributes). The alternative to setting these attribute in the constructor call is to call the allocator plugin everywhere we need it, but this looks a lot less clean (imo).
With partial compile, indexes are not a suitable guard for the primary invariant check. Instead, I believe plugins / allocation is used, which is exactly what we're trying to postpone here.
This makes me think that the way forward is maybe simply to make it easier for the developer to check these index constraints with plugins. I think it would be possible to have such plugins with a generic implementation, looking up the relevant index in the model, and making all the required checks based on the service attributes (not the service instance). Such plugin could then be called as the condition of an if
in which the instance would be constructed.
Use case
Force lsm top-level instance creation to finish (breadth-first) before continuing execution. The main motivation is to not trigger side effects (e.g. allocation) until all instances are constructed. This allows us to guarantee that no side effects will happen if e.g. an instance fails to construct because of an index collision.
Other potential benefits could be to avoid list freezes unitl all instances are unwrapped etc.
Ideas
(brainstorm-grade)
Atomic for
A new type of statement for a non-gradual, atomic for loop:
Open questions/issues:
execute_direct
its blocks?immediate keyword
Add an
immediate
(/urgent
/ ...) keyword that signifies that a statement should get priority. This would allow for a two-layered execution: the compiler guarantees that no non-urgent statements (with some well-defined exceptions) will be executed until the urgent ones have finished execution.Alternatively, the keyword could be part of an entity definition.
Open questions/issues