Currently, constructor expressions require the new keyword. The main reason for this is that we can't parse generic type expressions in a value expression context, so new is needed to explicitly tell the parser to expect a type expression.
It would be good to support construction without needing new. new is often associated with OOP object construction, but some of the values new constructs in ghūl are not objects (e.g., structs, union variants). While new does highlight that construction is special compared to a regular method call, you could argue that (...) already signals an arbitrary amount of work could happen, including object construction and side effects: new on top of (...) doesn't add any further information.
Once we have a solution for #883 we will be able to recognize constructor expressions without needing them to be preceded by new
To support bootstrapping and until ghul-test and the runtime library are updated to remove use of new, we will need to support constructor expressions with and without new.
Currently, constructor expressions require the
new
keyword. The main reason for this is that we can't parse generic type expressions in a value expression context, sonew
is needed to explicitly tell the parser to expect a type expression.It would be good to support construction without needing
new
.new
is often associated with OOP object construction, but some of the valuesnew
constructs in ghūl are not objects (e.g., structs, union variants). Whilenew
does highlight that construction is special compared to a regular method call, you could argue that(...)
already signals an arbitrary amount of work could happen, including object construction and side effects:new
on top of(...)
doesn't add any further information.Once we have a solution for #883 we will be able to recognize constructor expressions without needing them to be preceded by
new
To support bootstrapping and until
ghul-test
and the runtime library are updated to remove use ofnew
, we will need to support constructor expressions with and withoutnew
.