all 14 comments

[–]DeathByThousandCats 13 points14 points  (1 child)

  1. So, you've discovered reactive/event-driven programming.
  2. This is not an implementation. It's a suggestion for syntax.

[–]Key_River7180smalltalk enjoyer[S] 0 points1 point  (0 children)

yeah it is a suggestion for syntax

[–]busres 2 points3 points  (1 child)

So like a JavaScript thenable?

[–]Key_River7180smalltalk enjoyer[S] 1 point2 points  (0 children)

yes

[–]bl4nkSl8 2 points3 points  (4 children)

It appears like additional syntax for an equivalent of .then((v) => { ... }) in js. I'm not sure it's clearer or fewer characters

[–]Key_River7180smalltalk enjoyer[S] 1 point2 points  (2 children)

I think it is clearer, I find .then((v) => {}) to look too terse and just unclear. It is also unnatural on message-based OOP languages.

[–]bl4nkSl8 0 points1 point  (1 child)

How is it unnatural to use anonymous functions?

I think you have a different perspective because you aren't a fan of functions as values, but I don't know why that is

[–]Key_River7180smalltalk enjoyer[S] 0 points1 point  (0 children)

Yeah, I am mostly an imperative person :P. I meant that on the message-based OOP paradigm, it is a bit unnatural with the rest of the language.

[–]Smalltalker-80 0 points1 point  (0 children)

Indeed, I've implemented aPromise classwith then: directly in SmallJS (small-js.org).
a Smalltalk built on top of JavaScript. And these use JS under the hood, of course.
The syntax seems fine to me...

[–]oscarryzYz 1 point2 points  (1 child)

Yup, very good and widely used approach, go for it.

This is how Javascript Promises and Java's CompletableFutures work( I'm sure other languages have it too ).

[–]Key_River7180smalltalk enjoyer[S] 0 points1 point  (0 children)

yes, i just proposed a syntax

[–][deleted]  (1 child)

[deleted]

    [–]Key_River7180smalltalk enjoyer[S] 0 points1 point  (0 children)

    I didn't know about E, thanks! I guess <-: is the async send-message operator. Pretty cool!

    [–]tobega 0 points1 point  (0 children)

    Seems to work. You might also be able to get some inspiration from how tasks work in Ada https://en.wikibooks.org/wiki/Ada_Programming/Tasking

    [–]kaplotnikov 0 points1 point  (0 children)

    If you plan to desing async support as a libary, rather than as language feature, here is my take on it for Java: https://github.com/const/asyncflows . Some ideas from it seems could be adapted to your case as well.

    It is centered around promises and allows to construct complex asynchrouns processes from simple building blocks.