-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
One thing I miss about dynamic programming is the ability to do
if(...) {
myvar = tryGettingSomething();
}
if(myvar) {...
And I think the static typing requirement of
var Type myvar? = nothing;
before you write your code hurts readability...
Maybe in a static world var declarations could be applied to earlier scopes with ^?
if ... {
^var myvar = tryGettingSomething();
}
if myvar exists {...
this also ensures you can get type inference, and it would be neat if it could catch places like this:
if ... {
^var myvar = tryGettingSomething();
} else {
^var myvar = tryGettingSomethingElse();
}
and automatically know that the variable isn't optional. Current wake strategy would be to do
var myvar = ({ ->
if ... {
return tryGettingSomething();
} else {
return tryGettingSomethingElse();
}
})();
Have to be careful about closures and this strategy...But also nicely usable.
setCallbackOne({ v ->
^var myvar = v;
});
setCallbackTwo({ ->
if myvar exists {...