4 ms·
Code sample: Actor model with explicit synchronicity and access scoping: actor Counter { var value = 0; public func inc() : async Nat { value
by tlack 6y ago
Code sample:
Actor model with explicit synchronicity and access scoping:
actor Counter {
var value = 0;
public func inc() : async Nat {
value += 1;
return value;
};
}
Types and specificity:
type Tree<T> = {
#leaf : T;
#branch : {left : Tree<T>; right : Tree<T>};
};
func iterTree<T>(tree : Tree<T>, f : T -> ()) {
switch (tree) {
case (#leaf(x)) { f(x) };
case (#branch{left; right}) {
iterTree<T>(left, f);
iterTree<T>(right, f);
};
}
}
Source: https://sdk.dfinity.org/docs/language-guide/motoko.html https://sdk.dfinity.org/docs/language-guide/motoko.html
Not to my taste personally.
- smabie 6y agoLooks like Scala, but uglier.
- anentropic 6y agoan impressive feat in itself
- DarkWiiPlayer 6y agoToo many curly braces, too many abbreviations, and worst of all, templates with <>-syntax. You couldn't build an uglier language if you tried.
- jdonaldson 6y agoAsync is difficult to get right without proper generics and type parameterization support in the syntax. Brackets help collapse expressions to single lines, or expand them as needed. I like having that flexiblity.
- thecupisblue 6y agoPretty interesting. Basically your code is an eternal continuation, which is quite a nice persistance style (e.g. used by our universe, works pretty good). The code looks relatively nice and clean, except the hashsigns. Compiler seems simple and Candid will help quite a lot with interop and speed up the development. Think I will enjoy trying this once its available
- johnisgood 6y agoThe last snippet looks Rust-y.