-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: parenthetical syntax for message sends (cycles
, timeout
etc.)
#4608
base: master
Are you sure you want to change the base?
Conversation
cycles
etc.
Notes:
translates too something like:
|
instead call into the new `@coerce_cont`.
69b026a
to
463f12a
Compare
when there is a closure. The first component is the parenthetical record and the second is the closure environment for the call.
object base { | ||
public func cycles() {} | ||
}; | ||
await (base with) async (); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this is kinda ugly.
I wonder if
(with object-combination) would work in the parser...
(with base)
(with cycles = 100l, ...)
(with base with cycles = 100).
Probably not because of punning...
wording fixes Co-authored-by: Claudio Russo <[email protected]>
Co-authored-by: Claudio Russo <[email protected]>
Co-authored-by: Claudio Russo <[email protected]>
wording in warnings Co-authored-by: Claudio Russo <[email protected]>
let cycles, clean_cycles = | ||
if T.(sub par.note.note_typ (Obj (Object, [T.cycles_fld]))) | ||
then [fun parV -> dotE parV T.cycles_lab T.nat |> assignVarE "@cycles" |> expD], [] | ||
else [], [natE Mo_values.Numerics.Nat.zero |> assignVarE "@cycles" |> expD] in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
else [], [natE Mo_values.Numerics.Nat.zero |> assignVarE "@cycles" |> expD] in | |
else [], [] in |
If you did this, wouldn't the old mechanism still work if you only apply at timeout but don't mention cycles?
Then the Changelog doesn't have to say the approaches can't be mixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you say, a prior Cycles.add
would continue to work. Ah, you are worried about codebase migration, where folks want to add (with timeout)
but are hesitant to check for the presence of Cycles.add
(and remove it in favour of cycles =
) in front of the call?
8a957ac
to
a40febf
Compare
* Added support for sending `cycles` and setting a `timeout` in parentheticals. | ||
This is an **experimental feature**, with new syntax, and now also allowing best-effort | ||
message sends. The legacy call `Cycles.add<system>` is still supported, but the | ||
two approaches cannot be mixed (#4608). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment in desugar.ml and how to make them coexist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would coexistence be important? If the user attaches a parenthetical, why not go all the way?
b3e320f
to
fe40ca4
Compare
44a6146
to
ee4c2ad
Compare
This PR introduces new syntax (parenthetical notes) for
async
-valued calls andasync
self-sends. Two attributes are recognised therein:cycles : Nat
andtimeout : Nat32
. The type-checker enforces these types (when attributes present) and warns on unknown ones. Having atimeout
attribute present will make the message send a bounded-wait one (also called best-effort) according to the new replica semantics. Specifyingcycles
works like the (soon to be deprecated)Cycles.add<system>
, but one has to decide which to use (eitherCycles.add
or a parenthetical) since there is no mix-and-match.This now happens in the desugarer by assigning to variables (ICCallPrim
(and friends) should carry the fragment to set theSystemCyclesAddPrim
while the call is being set up towards the replica.@cycles
and@timeout
).Parentheticals
(with cycles = 42_000_000) Actor.call(param)
(with timeout = 10)
ic0.call_with_best_effort_response : (timeout_seconds : i32) -> ()
(with receiveMax = 50_000)
(to limit the response size)(with resend = { tries = 5; delay = 3 })
whenSYS_UNKNOWN
reject response (like UnixEINTR
, but saves cycles by not re-encoding the arguments)call_cycles_add128_up_to
ic#1158(with memoryLimit = 1G) ActorClass(<args>)
func() : async () = (with) async { ... }
— document this!TODOs:
Changelog.md
cycles : Nat
for canister sends (self and raw sends too)timeout : Nat32
for best-effortasync
blocksICCallPrim
, see topICCallRawPrim
, not directly annotatable (desisting for now, but see feat: passing cycles tocall_raw
#4868)FIXME
s,TODO
sICCallPrim
should have a non-option
setupmotoko-base
, see chore: mention#system_unknown
motoko-base#686git grep system_fatal
and amend#system_unknown
(with cycles) async
orasync (with cycles)
— decided: keep as prefix!Cycles.add
still works(with cycles) (func () -> async () {})()
direct application(with cycles) (system Lib.Class)(...)()
async*
(and call)