I was thinking about the ability to use only those variables which have values known at compile time so in the example above we just substitute [PROPERTY_NAME]
with .0
and compile to the exact same code.
I think we already have the ability to determine those as we can get errors like
non-static expression in library or module
@skilesare, your let-default is really just alternative syntax for switch. Redundancy like that ultimately makes a language harder to learn ā somebody reading somebody elseās code needs to understand all the different syntaxes instead of just one canonical one.
@ZhenyUsenko, just define an accessor function:
func propertyName(tuple : Tuple) { tuple.0 };
But really, if you need to abstract like that, then clearly you shouldnāt be using tuples in the first place, but records.
Understoodā¦I just wish the switch syntax was a bit easierā¦or that we had a : ? style switch for the many places you need to do A or B. It just gets a bit wordy. do?{} is also one of those places that Iāve run in to confused looks. Some of the current syntax is just alien enough that people bounce off it and donāt come back until they really know the language.
let ?x = y defaults ?0;
or
let ?x = do?{y!} defaults ?0;
or
let ?x = switch(y){ case(?val)val; case(null) ?0;};
As far as learning goes, Iād say progression is a natural way to learn a language. In C# people learn if then before switch case. Learning at low complexity helps the user move to high complexity later. Now, most proficient devās donāt need this step up , but if we want the language to be accessible from proficiency = 0, Iād argue that it might be worth considering.
Yesss. Give me that pipe syntactic sugar @claudio!