futurescript
futurescript copied to clipboard
Function guard clauses similar to elixirscript
Would be pretty simple reusing tailored also used by elixirscript
greet: guard({age: age}) when kid?(age) -> "just a kid"
greet: guard(_) -> "regular person"
The when would just become the first line in the function and do an early return if not passed
const tailored = require('tailored');
const _ = tailored.wildcard();
const $ = tailored.parameter();
let fact = tailored.defmatch(
tailored.clause([0], () => 1),
tailored.clause([$], (n) => n * fact(n - 1))
);
let response = fact(0); //1
response = fact(10); //3628800
Would also be nice with an easier way to operate with Map Set and Symbol
I'd suggest these improvements
# assigning a Map
%{a: 2, b: 3}
# assigning a set
&{a: 1, b: 4}
Assigning and referencing a symbol
:a: 2
z = :a
b: {:a: 2 :b: 3} or {:a => 2 :b => 3}
# Object.assign (get rid of << and >> for indentation, are they ever useful?)
Object.assign(a, b, c)
a << b << c
Alternative to 'wait (similar to yield or await in async/await)
personId <- findPerson 8
a <- getAds personId
Just some idea ;)