I have been giving some thought to some syntax changes of late. In particular, I want to get rid of variable assignments in where blocks, I thought this was elegant initially, but it leads to not great looking code IMO. And the reading order is disrupted as you have to jump to the where block and back to see what variables are assigned to.
So this:
write_yaml() ->
yaml.write(file)
where
yaml: new Yaml()
file: file('xxx.yml')
becomes:
write_yaml() ->
yaml = new Yaml(),
file = file('xxx.yaml'),
yaml.write(file)
And where blocks are reserved for private functions only. I am also thinking of getting rid of the requirement for a ',' to separate expressions in a do block, so again:
write_yaml() ->
yaml = new Yaml()
file = file('xxx.yaml')
yaml.write(file)
That's what things would look like at the end. The reasoning is that commas aren't all that useful an aid for reading (just like ';') and they dont have the consistency either as you leave out a comma for the last (or "return") expression.
An alternative to this proposal is to use the "let" keyword for declarations:
write_yaml() ->
let
yaml = new Yaml()
file = file('xxx.yaml')
in
yaml.write(file)
This has the advantage of a nice separation between declaring vars and using them. But otherwise I think it may be a bit too noisy. An alternative may be to inline the let keyword:
write_yaml() ->
let yaml = new Yaml()
let file = file('xxx.yaml')
yaml.write(file)
This might look a bit better in a syntax highlighter. And prevent confusion and "re-assignment", etc.
Any thoughts or feedback?
Dhanji.