Coder Social home page Coder Social logo

Comments (4)

kallentu avatar kallentu commented on May 25, 2024

cc @dart-lang/language-team

I wrote up some potential test cases in this issue. I'm going to start making language tests for the feature.
Let me know if there's something missing or I should test something in particular.

from sdk.

lrhn avatar lrhn commented on May 25, 2024

Multiple _ are allowed in generic type and generic function type parameters.

Not sure how to read this.
It's out talking about parameters of genetic function types, or about type parameters?
That is, does it allow Function<_, _>() as a genetic function with two anonymous type parameters?

(I'm fine with that, but it is outside the "local variables only" constraint that I had understood. But I just checked the spec, and that's what it says. So perfectly fine, just hard to read the phrasing.)

Error to have an occurrence of super._ as a declaration of a formal parameter in a constructor.

Not sure that needs to be an error.

class S {
  final int x, y;
  S(this.x, this.y);
}
class U extends S {
  U(super._ , super._) ;
}

looks perfectly reasonable to me. Only the position matters anyway, the names would only be for documentation or accessing in an initializer list.
If we allow this._, or a forwarding factory constructor of

  factory S.fwd(int _, int _) = S;

(which there is no reason not to allow) then I see no reason to treat super._ differently.

Checked the spec. It disallows super._ because it breaks the current desugaring specification of super parameters.
That's a bad reason for disallowing an otherwise percent good feature, and s good reason for not using desugaring as specification.

I'll suggest changing that, and allowing super._. even if it means treating _ as binding a fresh name, instead of being a non-binding declaration in that case.

Rest looks fine

from sdk.

eernstg avatar eernstg commented on May 25, 2024

Is this one covered?: Every kind of declaration named _ which is specified to be wildcarded is indeed accepted without compile-time errors, and it does not introduce the name _ into the enclosing scope.

The discussion about super._ being an error or not would be taken here: #55661.

from sdk.

kallentu avatar kallentu commented on May 25, 2024

Not sure how to read this.

Yeah, it is about generic type parameters. The examples Bob gave were below. I'll name the tests better than these bullets I wrote, hopefully :)

class T<_> {}
void genericFunction<_>() {}
takeGenericCallback(<_>() => true);

Every kind of declaration named _ which is specified to be wildcarded is indeed accepted without compile-time errors, and it does not introduce the name _ into the enclosing scope.

@eernstg What do you mean by the first part of this line? "Every kind of declaration named _ which is specified to be wildcarded is indeed accepted without compile-time errors". Can you explain this a bit more?

I'll add "it does not introduce the name _ into the enclosing scope " to the list though, thank you.

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.