question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

disallow or define semantics for "default late" values

See original GitHub issue

We know that for:

class C() {
    shared default String x = "C's value";
}

the specification = "C's value" is for C’s x, and not a potential refinement of x. This can be demonstrated with the following test:

class D() extends C() {
    shared actual variable String x = "D's value";
    shared void test() {
        assert (super.x == "C's value");
    }
}

We also know that specifications (assignments) made separately from a declaration are polymorphic in nature:

class C() {
    shared default variable String x = "C's value";
    shared void update() {
        x = "newValue"; // C's x may still be "C's value"!
    }
}

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 also default:

class C() {
    shared default late String x;
    shared void initialize() {
        x = "C's value"; // Are we initializing C's x, or possibly assigning to
                         // a refinement of x? What if the refinement is or is not
                         // itself late or variable? What if we also mark C.x
                         // variable?

        print(x);        // This would certainly refer to a refinement
    }
}

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: https://github.com/jvasileff/ceylon-dart/issues/11), but I’m not sure they would be worth the complexity and possibly surprising results.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:30 (30 by maintainers)

github_iconTop GitHub Comments

2reactions
gavinkingcommented, Sep 2, 2017

Alright, so after reviewing the above discussion, I guess @jvasileff has more or less convinced me that it’s worth outlawing default late even independently of #4273. So I’ve done that. I’ll close this issue and reopen the ancient issue #4273.

0reactions
gavinkingcommented, Sep 2, 2017

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 $$isFullyInitialized$$ member for any classes which leak their this reference. But it gets a little hairy to implement in the face of inheritance.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Defaults in Semantics and Pragmatics
'Default' can mean many different things in theories of meaning. It is so not only because of the multiplicity of approaches and dimensions ......
Read more >
Allow "default" / "override" semantics for task variables ...
I propose we deal with this by replacing the documented priority order with a documented evaluation order, placing the environment first, ...
Read more >
Java Semantic Values (Bison 3.8.1) - GNU.org
By default, the semantic stack is declared to have Object members, which means that the class types you specify can be of any...
Read more >
Accessibility in Compose - Android Developers
Key Term: Semantics properties are used to inform accessibility services about the information shown in UI elements. This document describes various situations ...
Read more >
Language Guide | Protocol Buffers - Google Developers
Defining A Message Type; Scalar Value Types; Optional Fields And Default Values; Enumerations; Using Other Message Types; Nested Types; Updating A Message ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found