Git Product home page Git Product logo

Comments (12)

alextekartik avatar alextekartik commented on May 5, 2024 2

I like the extension idea, but maybe not in this package (why not in core or meta). I have to add pedantic as a regular dependency just for some unawaited calls (that I sometimes remove to use ignore comment instead to avoid this dependency). I'd rather have this package without code so I can use it as a dev_dependency.

from pedantic.

davidmorgan avatar davidmorgan commented on May 5, 2024 1

Agreed, that's why we tried to move unawaited to package:meta, but we failed.

The extension might have better luck.

from pedantic.

lrhn avatar lrhn commented on May 5, 2024 1

I can also not see any issues with adding this to package:meta (and the recommending it over unawaited from package:pedantic). That said, I also saw no issue with moving the unawaited future top package meta to begin with.

There should not be any conflict unless someone already defined another extension on Future with name unawaited (unlikely) and you need to use both of them in the same library (compounding the unlikeliness) and you are not willing to invoke them explicitly.

Are we allowed to ignore FutureOr now. I can see that unawaited takes a Future? as argument. Not sure why accepting one union type and not the other, so should it take FutureOr? as well?

An alternative name could be .ignore (but that should probably also catch and ignore errors).

from pedantic.

davidmorgan avatar davidmorgan commented on May 5, 2024

I like it--and it doesn't pollute the top level namespace like the current unawaited.

But we've learned to be very careful with changes to this package :/ as so much depends on it. I think if we add such an extension it would break someone who already has the same extension?

from pedantic.

a14n avatar a14n commented on May 5, 2024

I think if we add such an extension it would break someone who already has the same extension?

It should be ok as long as no other extension defines a unawaited member on Future.

//---------- pedantic.dart
extension FutureExt<T> on Future<T> {
  void get unawaited {}
}

//---------- a.dart
extension FutureExt<T> on Future<T> {
  void get a {}
}

//-----------  main.dart
import 'a.dart';
import 'pedantic.dart';

main() {
  var future = Future<void>.value();
  future.unawaited; // OK - extension from pedantic.dart
  future.a; // OK - extension from a.dart
  future.b; // extension from current lib
}

extension FutureExt<T> on Future<T> {
  void get b {}
  // void unawaited() {}  // error if this unawaited is also defined hehe
}

void unawaited() {} // OK 

@lrhn : do you see a potential breaking issue about this addition?

from pedantic.

davidmorgan avatar davidmorgan commented on May 5, 2024

That is much like what broke when we tried moving unawaited to package:meta; package:test had defined its own unawaited, and so we broke package:test and most of the world.

We don't have a good way to check for such breakage in important packages.

from pedantic.

a14n avatar a14n commented on May 5, 2024

no, no breakage if an unawaited member is defined in main.dart (I updated the above code). The breakage only occurs if unawaited is also defined in an extension of Future (that is really more unlikely)

from pedantic.

davidmorgan avatar davidmorgan commented on May 5, 2024

Right. I mean someone might define the exact same extension, for exactly the same reason :)

I can search google3 code, nobody has done it there yet :) so we're probably safe on core packages.

from pedantic.

a14n avatar a14n commented on May 5, 2024

@davidmorgan feel free to move this issue to the appropriate issue tracker if it can land in meta.

from pedantic.

a14n avatar a14n commented on May 5, 2024

I can also create a PR on meta!

from pedantic.

davidmorgan avatar davidmorgan commented on May 5, 2024

:D please go ahead with a PR/issue for package:meta, let's keep this one here too since it relates to effectively deprecating the code part of this package.

from pedantic.

a14n avatar a14n commented on May 5, 2024

PR submitted at dart-lang/sdk#45284

from pedantic.

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.