google / tuple.dart

A library providing a tuple data structure
https://pub.dev/packages/tuple
BSD 2-Clause "Simplified" License
194 stars 26 forks source link

Common interface #13

Closed Solido closed 4 years ago

Solido commented 5 years ago

It would it very convenient to have a common interface for tuple : Tuple

So you can store List but add different implementations. Currently I need to strongly type on Tuple2 but some result got more entries.

This interface Tuple can gives you the number of index (arity) and allow access to value by index and an iterator.

Thank you !

alextekartik commented 4 years ago

Indeed it would great to know if a value is Tuple without having to check each type one by one (is Tuple2, is Tuple3...). It could also a share the common toList method they all have:

/// Represents a tuple.
abstract class Tuple {
  /// Creates a [List] containing the items of this [Tuple].
  ///
  /// The elements are in item order. The list is variable-length
  /// if [growable] is true.
  List toList({bool growable = false});
}
Solido commented 4 years ago

Looks like tuple is coming directly to dart and this package will go to sleep.

Le lun. 6 avr. 2020 à 11:52, Alexandre Roux notifications@github.com a écrit :

Indeed it would great to know if a value is Tuple without having to check each type one by one (is Tuple2, is Tuple3...). It could also a share the common toList method they all have:

/// Represents a tuple.abstract class Tuple { /// Creates a [List] containing the items of this [Tuple]. /// /// The elements are in item order. The list is variable-length /// if [growable] is true. List toList({bool growable = false}); }

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dart-lang/tuple/issues/13#issuecomment-609693330, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJ4MWMFYR2MJRSBE3KVNZTRLGQ5RANCNFSM4ITUWV6A .

-- Robbie

alextekartik commented 4 years ago

Thanks for the information @Solido. Is there any place I could look for more information (current status, planned implementation) as I could not find relevant information so far?

Solido commented 4 years ago

HI @alextekartik This is linked to dart Destructuration feature

https://github.com/dart-lang/language/blob/09caf04efbf19b35af2cecce8a7c17afa7868882/working/0546-patterns/goals-and-constraints.md

Solido commented 4 years ago

And https://github.com/dart-lang/language/issues/68