From 073c902a31936c2b53d89245662fb272c9670169 Mon Sep 17 00:00:00 2001 From: JJ Date: Thu, 9 May 2024 18:00:01 -0700 Subject: std: sweeping changes. - replace interfaces with classes - replace : with then and do - solidify memory management as rust-style ownership - replace unsafe blocks with safe/unsafe attributes - add magic and copy attributes - switch Coerce impl from from to to --- std/async.pk | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'std/async.pk') diff --git a/std/async.pk b/std/async.pk index 7c76076..f2ae3e0 100644 --- a/std/async.pk +++ b/std/async.pk @@ -1,5 +1,6 @@ ## std.async: Zig-style colourless async/await. ## Future types, the async macro, and the await function. +# reference: https://kristoff.it/blog/zig-colorblind-async-await/ ## A standard Future type. Opaque. pub type Future[T] = struct @@ -7,6 +8,9 @@ pub type Future[T] = struct ## The `async` macro transforms any function call into ## an asynchronous call returning a Future of some type. +## +## This does not "just work". Compiler magic is necessary to package up +## *any* block into something independently callable. pub macro async[T](call: T): Future[T] = ... @@ -14,6 +18,6 @@ pub macro async[T](call: T): Future[T] = pub func await[T](self: Future[T]): T = ... -examples: +examples std.net.connect() print 1.async.await -- cgit v1.2.3-70-g09d2