-
Notifications
You must be signed in to change notification settings - Fork 62
disallow or define semantics for "default late" values #6455
Comments
So what is the proposal here? If I understand correctly:
Does that solve the problems here and in #4273? |
Or is the proposal to:
|
It's no more than:
I don't see what this issue has to do with leaking of |
The title change to "unsoundness with
The key is "ambiguity", not "unsoundness" |
Because if we're going to fix the unsoundness of |
I feel like #4273 is the most appropriate place for the discussion, then. This is something considerably different. |
(The three issues problems are deeply connected, please note, in the sense that disallowing |
Then how is it that the same change helps solve all of them? |
Ok. If |
Disallowing |
That's not true. The problem described in issue #4273 doesn't at all involve |
Look, if we're going to fight about stupid stuff, I'm just going to make the change that looks right to me. Otherwise, if we're going to discuss the proposed solution that is on the table above, we can discuss that. |
I don't think anyone is fighting about anything. I'm just saying I don't think your proposed changes to fix this issue actually fix #4273. This issue is something different entirely. |
class Foo()
{
shared late Bar bar;
shared void huh() => print(bar.s);
}
class Bar(Foo foo)
{
foo.bar = this;
foo.huh();
shared String s = "";
}
shared void run() => Bar(Foo()); |
Either way, you proposed two changes, not one. Your first change is related to this issue, while your second change is related to #4273. They are different issues. |
But—I'm not sure if you noticed—it's also unsound, because it allows an uninitialized value (a class Foo() {
shared default late Bar bar;
}
class Bar(Foo foo) {
foo.bar = this;
shared String hello = "hello";
}
class Baz() extends Foo() {
shared actual Bar bar => super.bar;
assign bar {
super.bar = bar;
print(bar.hello);
}
} That's why all this stuff is connected. The problem is that We can't really discuss any of these issues in isolation because there's almost no point solving any one of them if we don't solve all of them; the basic unsoundness due to the intersection of these two language features remains. |
Alright, so here's the second rev of my proposal:
That would guarantee that WDYT? My worry is it might be too heavy-handed. |
Honestly I would prefer if uninitialized objects could leak via |
I suppose that once a |
I suppose so too. But the |
I think that both only allowing |
Yeah, we ended up cross-posting. |
This restriction has been on my mind for a very long time, and although I've struggled with initialization issues, I've never been inclined to assign |
I would disallow all leaking of |
I have a complaint 😄: class Element(shared {Element*} children) // can't be final (subtypes: `Div`, `Button`, `Span`, etc.)
{
shared late Element? parent = null;
for(value child in children)
{
child.parent = this;
}
} |
@Zambonifofex right. There's another issue complaining about that, opened by @sadmac7000 I believe. There are also techniques using lazy initializers. |
So I guess I take that back, if we define |
And I guess this is exactly why I have not been inclined to solve #4273 in the 3 years it has been open. There's probably no static-analysis based solution that isn't unacceptably restrictive. This is a reasonable solution involving maintaining a |
Alright, so after reviewing the above discussion, I guess @jvasileff has more or less convinced me that it's worth outlawing |
We know that for:
the specification
= "C's value"
is forC
'sx
, and not a potential refinement ofx
. This can be demonstrated with the following test:We also know that specifications (assignments) made separately from a declaration are polymorphic in nature:
This can also be demonstrated with the
D
test above.However, for
late
values, initialization may be separated from the declaration, introducing an ambiguity for values that are alsodefault
:The backends are inconsistent WRT their treatment of
default late
members.I propose that
default late
be disallowed. Other options may be possible too (I debated them with myself here: jvasileff/ceylon-dart#11), but I'm not sure they would be worth the complexity and possibly surprising results.The text was updated successfully, but these errors were encountered: