First poll results
From Nemerle Homepage
Contents |
Intro
The first poll was active since Mar 24 2004, until Sep 13 2004. There were 141 votes.
We would like to thank all the people participating in it. It helped us much in making the decisions and gathering opinions about the language. Below we summarize the results and point out some insightful comments. As for the influence of the results on the language -- we have followed all the suggestions.
From the poll description
This poll is here to help us resolve some language design issues.
The operator <- for assignment has the advantage of making assignment (<-) and definition (def x =) distinct. OTOH = is widely used (and well recognized), and it makes choice for +=-like operator obvious. We would need some very good reasons to use := or something different.
The mutable keyword denotes the intent for a mutable variable well, but is considered too long by some people. var is used in Pascal and JScript.
Default immutable fields have the advantage, that only fields that need to be mutable are. There is no way to forget about readonly -- if you forget about mutable you end up with error.
Results
- Preferred assignment operator: = (79) <- (33) := (29)
- What keyword to use for mutable: mutable (71) var (64) other (6)
- Should class fields be immutable by default: immutable (99) mutable (42)
- How well do you know Nemerle: not a bit (53), somewhat (69), quite well (17), very well (2)
We have choosen the options with highest ranks in actual Nemerle syntax, but of course our decisions were based on only on those votes. We still had hard time choosing the right design.
From the current perspective importance of above questions of leveraged by Nemerle's powerful macros. You can just add some syntactic sugar by our own:
macro @<- (target, source) { <[ $target = $source ]> } macro mutable_definition (body) syntax ("var", body) { match (body) { | <[ $(id : name) = $val ]> => <[ mutable $(id : name) = $val ]> | _ => Message.Error ("wrong expression in 'var' declaration") } }
You could also write a macro, which marks all the fields in all classes with mutable, but this would be a little bit harder.
Interesting comments
Anonymous: I like it the way it is now, with your latest 0.1.3 release. For classes, immutability by default is a Good Thing because mutability should be explicit (using the keyword makes you think about *when* and *how* you are going to modify the field).
Marcin 'Qrczak' Kowalczyk: http://merd.sourceforge.net/pixel/language-study/syntax-across-languages/Vrs.html#VrsVrbssgOrDcl
Marijn Ros I program in C# and am used to = as assignment-operator. A different definition-operator would be my choice (as?). I tend to read var in Javascript the same as my in perl, declaring locality. Explicitly declaring fields mutable feels like explicitly declaring them public (as opposed to private), a good idea.
Jacek Suliga I'm too old to change some of my habits (<-). ;-)