Coder Social home page Coder Social logo

Comments (2)

lrhn avatar lrhn commented on June 23, 2024 4

From a language perspective, those names are not names of declarations, which is what we'd traditionally allow identifiers to refer to.

That means that while ({int value}) has the identifier value in there, the identifier doesn't become part of any scope. "Referring" to it is somewhat spurious, since writing the link [value] doesn't have any scope where [value] resolves to ... well, anything.

So whatever we do here must be designed from the ground up, the language gives no help.

We could introduce a "documentation scope" which contains the same names as the declaration/parameter scope plus the names of all named record fields.
The biggest question is what happens on a conflict:

  • If the record field name has the same name as a parameter, which wins? (The parameter!)
  • If the record field name has the same name as the method itself, which wins? (...uhm...)
  • If the record field name has the same name as a surrounding top-level declaration or import, which wins? (Possibly the record field... but that's a breaking change of resolution of existing identifiers.)
  • If there are two record fields with the same name, which one wins? (Neither!)

Start with:

int foo = 42;
class Foo {
  /// Something about [foo].
  ({int foo}) foo(({String foo, int bar}) foo, (int foo, int bar) v2) => 
      (foo: foo.bar);
}

and decide what needs to change before [foo] can refer to a record field name.
(Today it refers to the positional parameter named foo, since it's resolved in the parameter scope.)

(It's also a question what it would mean to refer to a record type field name. Will "go to declaration" work? I probably can, if there is a unique resolution. What will be shown when hoovering over the reference?)

from sdk.

bwilkerson avatar bwilkerson commented on June 23, 2024

Given the ambiguities inherent in the feature, and the limited value that I currently believe it would add for users (in part because of those ambiguities), I'm comfortable saying that we won't implement such a feature at this time.

from sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.