Open radeusgd opened 1 month ago
I'm not 100% sure that the current behaviour is wrong, but it looks wrong to me. @kazcw @JaroslavTulach opinions?
This seems inconsistent and is confusing. I think we should require parentheses or whitespace here:
That's how I feel about it too. This syntax appears in the draft language spec. If no one is attached to it, treating this case as an error would simplify the language (and the parser).
Requiring:
type A
B (c = 42+2)
type A
B c=42+2
seems fine to me.
@jdunkerley suggests that:
type A B c = 42+2
should define A.B
function with body of 42+2
, but James is OK with that to be an error.
@jdunkerley suggests that:
type A B c = 42+2
should define
A.B
function with body of42+2
, but James is OK with that to be an error.
Enso syntax was keeping a clear distinction between identifiers starting with lowercase
to be local variables and methods, and Uppercase
to by types and their constructors. We could change that but it feels like it would be a very significant change to the syntax. For example IIRC pattern matching relies on this distinction and without it, it could not know which is a constructor and which is a free binding.
The following code
yields:
I'm not quite sure this is right - it looks like a mixed constructor and method definition.
I imagine what happens is that the
42+2
expression turns out to be the default value forc
argument of the constructor.Indeed,
yields
44
.But it does not seem right - if it were a method
that
42+2
would be the body of the method, not a default argument.This seems inconsistent and is confusing. I think we should require parentheses or whitespace here:
or