Feedback on Migration syntax #4892
Replies: 3 comments 4 replies
-
Hi @ByronBecker, thanks for the feedback! Indeed we don't anticipate to people to write migration functions as lambdas behind Normally the migration function will be neatly tucked away in a different module and will be applied like this: The key point is that parenthetical notes apply to expressions, conveying extra information (modalities). A PR is in development to use parentheticals adding cycles to external/self message sends and to apply timeouts for best effort sends. We will see what other modalities make sense. Regarding the syntax, I think this is quite better than Rust's So please don't stare only on that example in the release note, the common case will be much nicer. |
Beta Was this translation helpful? Give feedback.
-
@ggreif The current placing feels a bit like a decorator. Also, it's strange that there's nothing that explicitly attaches that migration to the actor other than its proximity. It also makes it seems like you could do this:
I guess I find it slightly awkward for the migration syntax to be located outside of the actor. I might just be on an island though here 😅, again - really excited to see this feature come out! |
Beta Was this translation helpful? Give feedback.
-
Actually, I sympathise that re-using () is maybe a bit too subtle and perhaps we should use a more prominent delimiter for so called parentheticals, either (| ... |) or some other variant that sticks out more and is easy to grep for. The reason for placing the annotation at the front of the class is to reflect the lexical scoping - the migration expression doesn't have access to constructor arguments or any fields or methods of the actor body. It also make it easer to delete the annotation and any import without disturbing the rest of the actor/class code. For migration we first had a straw man syntax that places the migration expression after the actor keyword
but that reads oddly with classes and raise the question if the {caller} is bound in exp or not/
On the whole, I think the prefix syntax works a little better. Another option would have been a new The rest of syntax was driven by the desire to harmonise with the cycles/timeout annotations in this PR #4608 I'm not opposed to revising the syntax of parentheticals if there's alot of pushback, but I think having the parenthetical outside of the actor/class makes sense for lexical scoping reasons. |
Beta Was this translation helpful? Give feedback.
-
@crusso @ggreif
I just saw the new migration support, which is very exciting! https://github.com/dfinity/motoko/releases/tag/0.14.0
My high level reaction from just looking at the release notes is that using
()
, for example(with migration = ...)
feels a bit messy. Additionally, I'm not sure how this gets explicitly attached to the persistent actor, other than being directly above itMaybe introducing a migration module type (record), that can be passed/attached to the actor in some way would be helpful?
Right now there isn't anything in the syntax directly connecting the migration keyword to the actor, and I'm curious if this structure is built so that it can evolve over time (i.e. adding in more than just migrations, via
with migration; checks; hooks; ...
).Beta Was this translation helpful? Give feedback.
All reactions