I'm not sure how I want variables to be declared. I could use var to hint to initiate a variable declaration as with some languages, thus avoiding the most-vexing-parse issue in C++, but this seems like an awkward solution. If I did it like in C++ or Go, there would need to be a way to distinguish between a new identifier shadowing an existing one vs an identifier being a variable that holds the type of the new variable (maybe).
Here are some examples that I am thinking through:
type identifier //1: C++/Java style
identifier type //2: Go style
var identifier type //3: JavaScript-esque, kind of unusual in Stardust
`identifier` type //4
type `identifier` //5
`identifier`(type) //6: functional syntax (kind of does the impossible for functions though)
type(`identifier`) //7: functional syntax (again, kind of does the impossible)
//others?
There is also the question about initialization - all of the above would use default initialization. For value initialization, I am considering declaration := value, but it's different when passing multiple parameters.
type identifier (params, ...) //1A: C++ style
type identifier : (params, ...) //1B
identifier type(params, ...) //2A: might be ambiguous if a type doubles as a function (e.g. chain types)
identifier type:(params, ...) //2B
//1/2 are pretty similar to 4/5
//Not sure about the rest
I'm not sure how I want variables to be declared. I could use
var
to hint to initiate a variable declaration as with some languages, thus avoiding the most-vexing-parse issue in C++, but this seems like an awkward solution. If I did it like in C++ or Go, there would need to be a way to distinguish between a new identifier shadowing an existing one vs an identifier being a variable that holds the type of the new variable (maybe).Here are some examples that I am thinking through:
There is also the question about initialization - all of the above would use default initialization. For value initialization, I am considering
declaration := value
, but it's different when passing multiple parameters.