Open MichaelRFairhurst opened 9 years ago
I think mutable/immutable was planned on 'var' and 'def', or 'var' and 'the'. Why not solve this more syntactically than a new keyword?
var(getEntities()); // mutable var Entity[] def("Hello World"); // immutable var Text
this just leaves the question of how useful this is vs how dangerous it is.
It did occur to me that this would make for some nice DSLs.
def wockito();
def projectRoot(".")
def default(Project)Builder();
def default(File)Structure();
Build.my(Files);
Might be interesting to let loose!
Dangerous idea to be sure, but, just like we can say
and the compiler knows that that returns
Entity[]
to make the varEntity
automatically, we should be able to writewhich creates a var named
Entity[]
automatically.Gets pretty dangerous/cool, things like
Syntax is an issue, though, as the token stream
|var|Num|...
could end as
or
var Num + 5;
Probably needs to be a different keyword, like
also need to consider how this would interact with the proposed immutable variable declarations