Re: Improvements to std.typecons.Nullable

2013-10-10 Thread Andrei Alexandrescu
On 10/9/13 10:07 AM, monarch_dodra wrote: On Wednesday, 9 October 2013 at 16:34:52 UTC, BLM768 wrote: On Wednesday, 9 October 2013 at 06:48:31 UTC, monarch_dodra wrote: OK, so that's two functions already. What about opCmp? What about toHash? Since ordered comparisons make no sense with

Re: Improvements to std.typecons.Nullable

2013-10-10 Thread monarch_dodra
On Thursday, 10 October 2013 at 10:09:23 UTC, Andrei Alexandrescu wrote: I'm confused. I thought Nullable!T == T is well defined to mean true if a value is present and equal to the right-hand side, or false otherwise (the absence of a value is a singularity unequal with all objects). What's

Re: Improvements to std.typecons.Nullable

2013-10-10 Thread Simen Kjaeraas
On 2013-10-10, 13:28, monarch_dodra wrote: On Thursday, 10 October 2013 at 10:09:23 UTC, Andrei Alexandrescu wrote: I'm confused. I thought Nullable!T == T is well defined to mean true if a value is present and equal to the right-hand side, or false otherwise (the absence of a value is a

Re: Improvements to std.typecons.Nullable

2013-10-09 Thread monarch_dodra
On Tuesday, 8 October 2013 at 19:04:33 UTC, BLM768 wrote: I've been working on a project that makes relatively heavy use of nullable values. I've been using std.typecons.Nullable, and it mostly works well, but there are some improvements that could be made to the implementation: * A

Re: Improvements to std.typecons.Nullable

2013-10-09 Thread Paolo Invernizzi
On Wednesday, 9 October 2013 at 06:48:31 UTC, monarch_dodra wrote: On Tuesday, 8 October 2013 at 19:04:33 UTC, BLM768 wrote: I've been working on a project that makes relatively heavy use of nullable values. I've been using std.typecons.Nullable, and it mostly works well, but there are some

Re: Improvements to std.typecons.Nullable

2013-10-09 Thread BLM768
On Wednesday, 9 October 2013 at 06:48:31 UTC, monarch_dodra wrote: OK, so that's two functions already. What about opCmp? What about toHash? Since ordered comparisons make no sense with null values, opCmp would need to throw an exception when working with null values anyway. That's exactly

Re: Improvements to std.typecons.Nullable

2013-10-09 Thread monarch_dodra
On Wednesday, 9 October 2013 at 16:34:52 UTC, BLM768 wrote: On Wednesday, 9 October 2013 at 06:48:31 UTC, monarch_dodra wrote: OK, so that's two functions already. What about opCmp? What about toHash? Since ordered comparisons make no sense with null values, opCmp would need to throw an

Re: Improvements to std.typecons.Nullable

2013-10-09 Thread BLM768
On Wednesday, 9 October 2013 at 17:07:18 UTC, monarch_dodra wrote: That was my point. Writting Nullable!T == T is the exact same thing: Comparison of a value with the absence of a value. It's neither equal nor different, it's an error. Equality comparison is a bit different from properties

Improvements to std.typecons.Nullable

2013-10-08 Thread BLM768
I've been working on a project that makes relatively heavy use of nullable values. I've been using std.typecons.Nullable, and it mostly works well, but there are some improvements that could be made to the implementation: * A toString() method (needed to fix bug #10915) * An opEquals for

Re: Improvements to std.typecons.Nullable

2013-10-08 Thread Brad Anderson
On Tuesday, 8 October 2013 at 19:04:33 UTC, BLM768 wrote: I've been working on a project that makes relatively heavy use of nullable values. I've been using std.typecons.Nullable, and it mostly works well, but there are some improvements that could be made to the implementation: * A

Re: Improvements to std.typecons.Nullable

2013-10-08 Thread BLM768
On Tuesday, 8 October 2013 at 19:20:05 UTC, Brad Anderson wrote: The wiki has a pretty good guide of the overall process: http://wiki.dlang.org/Pull_Requests That answers most of my questions, but it seems a little... informal. I guess the formal review process doesn't really apply to

Re: Improvements to std.typecons.Nullable

2013-10-08 Thread monarch_dodra
On Tuesday, 8 October 2013 at 19:04:33 UTC, BLM768 wrote: I've been working on a project that makes relatively heavy use of nullable values. I've been using std.typecons.Nullable, and it mostly works well, but there are some improvements that could be made to the implementation: * A

Re: Improvements to std.typecons.Nullable

2013-10-08 Thread BLM768
On Tuesday, 8 October 2013 at 20:55:35 UTC, monarch_dodra wrote: Or we could just nuke the alias this. A Nullable!T isn't a T. It's a T handler. alias this allows implicit cast, which should only happen with a is a relation. Using it in a different context (such as nullable) is wrong, and

Re: Improvements to std.typecons.Nullable

2013-10-08 Thread Nick Sabalausky
On Tue, 08 Oct 2013 22:55:34 +0200 monarch_dodra monarchdo...@gmail.com wrote: A Nullable!T isn't a T. It's a T handler. I see that as an (unavoidable) implementation detail. alias this allows implicit cast, which should only happen with a is a relation. Using it in a different context

Re: Improvements to std.typecons.Nullable

2013-10-08 Thread BLM768
On Tuesday, 8 October 2013 at 19:04:33 UTC, BLM768 wrote: * Making isNull() @property Hmm... looks like it's already @property. I guess this happened after the last update to the Phobos docs. I'll still need to fix the other stuff, though.

Re: Improvements to std.typecons.Nullable

2013-10-08 Thread Meta
On Wednesday, 9 October 2013 at 03:42:50 UTC, Nick Sabalausky wrote: Personally, I find Nullable's alias this functionality to be a wonderful convenience. FWIW. Yeah, it's convenient to be able to switch out T with Nullable(T) and have it work without breaking the API... Well, it sort of