August 14, 2014
Dicebot:

> This is already possible with standard library but the fact that declarations need to be separate makes people not happy.

The unpack() lacks most of the capabilities you expect and want from tuples handling.

Bye,
bearophile
August 14, 2014
This looks really nice.  I'd love to use it for std.concurrency,
but I'm still trying to sort out a way for this to work.
Specifically, it would be nice if there were a way to know from a
tuple's TypeInfo if it matches a pattern.  For example, would
something like this work:

receive( ({1, $} x) { ... do something with tuple x },
              ({2, $} x) ... );

I suppose it might be possible to say whether a tuple is {int,
stuff}, then deserialize it into a variable and compare against
the pattern explicitly?  Though maybe this would end up requiring
me to parse the mangled name of the tuple type?
August 14, 2014
Sean Kelly:

> This looks really nice.  I'd love to use it for std.concurrency,
> but I'm still trying to sort out a way for this to work.
> Specifically, it would be nice if there were a way to know from a tuple's TypeInfo if it matches a pattern.

Elsewhere I have suggested to add to D an optional struct (and tuple) method now named onMatch, similar to the unapply method of Scala language, that is also called by the switch case to perform a basic version of pattern matching.

Bye,
bearophile
August 15, 2014
On 14/08/14 21:12, bearophile wrote:

> Elsewhere I have suggested to add to D an optional struct (and tuple)
> method now named onMatch, similar to the unapply method of Scala
> language, that is also called by the switch case to perform a basic
> version of pattern matching.

It can be implemented as a library function. The syntax won't be as nice looking tough. With AST macros the syntax could probably look good enough.

-- 
/Jacob Carlborg
August 15, 2014
Jacob Carlborg:

> It can be implemented as a library function.

It can't be implemented with a library function. You want to use it in function signatures, foreach, and so on. We have discussed this many times.

Bye,
bearophile
August 15, 2014
On Friday, 29 March 2013 at 08:58:06 UTC, kenji hara wrote:
> http://wiki.dlang.org/DIP32
>
> Kenji Hara

Will it allow for nested tuples? Or tuples containing lambdas?
1 2 3 4 5 6 7
Next ›   Last »