Re: NULL indicator in Variant

2011-10-29 Thread Steve Teale
On Sat, 29 Oct 2011 17:42:54 -0400, Robert Jacques wrote: > > Variant var = 1; > var.mark = true; > > if(var.mark) { > // Do DB NULL stuff > } else { > // Do DB value stuff > } > > But how is that different from this: > > Variant var = 1; > var.nullify; > > if(var.isNull) { > //

Re: NULL indicator in Variant

2011-10-29 Thread Robert Jacques
On Sat, 29 Oct 2011 16:23:11 -0400, Steve Teale wrote: On Fri, 28 Oct 2011 23:50:37 -0400, Robert Jacques wrote: [snip] I read through my answers again, and they seem to me to be perfectly valid responses to your questions. It's just that you are insisting on the use of terms like nullify a

Re: NULL indicator in Variant

2011-10-29 Thread Steve Teale
On Fri, 28 Oct 2011 23:50:37 -0400, Robert Jacques wrote: > On Fri, 28 Oct 2011 10:22:37 -0400, Steve Teale > wrote: >> On Fri, 28 Oct 2011 00:35:45 -0400, Robert Jacques wrote: > > [snip] > >>> Speaking as the one making over variant, let me see if I understand >>> your use case. Similar to ty

Re: NULL indicator in Variant

2011-10-29 Thread simendsjo
On 29.10.2011 04:04, Steven Schveighoffer wrote: I don't like Variant having this behavior when it's only of specific use. Variant is not a database-only type. Here's another idea: struct DBNull(T) { } Where T is the type for the column. i.e.: row.column = DBNull!int; Now, you have your f

Re: NULL indicator in Variant

2011-10-28 Thread Robert Jacques
On Fri, 28 Oct 2011 10:22:37 -0400, Steve Teale wrote: On Fri, 28 Oct 2011 00:35:45 -0400, Robert Jacques wrote: [snip] Speaking as the one making over variant, let me see if I understand your use case. Similar to typecons.Nullable, you want to be able to test any type for isNull and be to

Re: NULL indicator in Variant

2011-10-28 Thread Jonathan M Davis
On Friday, October 28, 2011 19:04 Steven Schveighoffer wrote: > I don't like Variant having this behavior when it's only of specific use. > Variant is not a database-only type. Agreed. Unless such a change has a real use case beyond databases, I do not think that it should be built into Variant.

Re: NULL indicator in Variant

2011-10-28 Thread Steven Schveighoffer
On Thu, 27 Oct 2011 14:06:47 -0400, Steve Teale wrote: On Thu, 27 Oct 2011 13:58:54 -0400, Steven Schveighoffer wrote: On Thu, 27 Oct 2011 13:53:02 -0400, Steve Teale wrote: On Thu, 27 Oct 2011 13:09:43 -0400, Steven Schveighoffer wrote: On Thu, 27 Oct 2011 12:58:57 -0400, Steve Teale

Re: NULL indicator in Variant

2011-10-28 Thread Steve Teale
On Fri, 28 Oct 2011 01:00:28 -0400, Kagamin wrote: > SQL uses `NULL` for all types. Yes, but if you set a particular column value to NULL, it does not wipe away the column's meta-data. > Did you try Algebraic - type-restricted version of Variant? SQL implementations tend to use structure types

Re: NULL indicator in Variant

2011-10-28 Thread Steve Teale
On Fri, 28 Oct 2011 00:35:45 -0400, Robert Jacques wrote: > On Thu, 27 Oct 2011 14:06:47 -0400, Steve Teale > wrote: >> On Thu, 27 Oct 2011 13:58:54 -0400, Steven Schveighoffer wrote: >>> On Thu, 27 Oct 2011 13:53:02 -0400, Steve Teale >>> wrote: On Thu, 27 Oct 2011 13:09:43 -0400, Steven S

Re: NULL indicator in Variant

2011-10-28 Thread Regan Heath
On Fri, 28 Oct 2011 10:23:03 +0100, Regan Heath wrote: On Thu, 27 Oct 2011 19:06:47 +0100, Steve Teale wrote: On Thu, 27 Oct 2011 13:58:54 -0400, Steven Schveighoffer wrote: Why wouldn't you just wrap variant if you want to introduce a nullable variant type? Why does Variant have to be m

Re: NULL indicator in Variant

2011-10-28 Thread Regan Heath
On Thu, 27 Oct 2011 19:06:47 +0100, Steve Teale wrote: On Thu, 27 Oct 2011 13:58:54 -0400, Steven Schveighoffer wrote: Why wouldn't you just wrap variant if you want to introduce a nullable variant type? Why does Variant have to be muddied with requirements for database API? Database null is

Re: NULL indicator in Variant

2011-10-27 Thread Kagamin
Steve Teale Wrote: > > Any reason making a custom NULL type wouldn't work? i.e: > > > > struct NULL {} > > > > Variant var = NULL; > > > > assert(var.type == typeof(NULL)); > > I don't think that is any improvement on hasValue(). It would tell you > the particular value was null, but would no

Re: NULL indicator in Variant

2011-10-27 Thread Robert Jacques
On Thu, 27 Oct 2011 14:06:47 -0400, Steve Teale wrote: On Thu, 27 Oct 2011 13:58:54 -0400, Steven Schveighoffer wrote: On Thu, 27 Oct 2011 13:53:02 -0400, Steve Teale wrote: On Thu, 27 Oct 2011 13:09:43 -0400, Steven Schveighoffer wrote: On Thu, 27 Oct 2011 12:58:57 -0400, Steve Teale wrot

Re: NULL indicator in Variant

2011-10-27 Thread Steve Teale
On Thu, 27 Oct 2011 18:35:19 +, kennytm wrote: > Just store a std.typecons.Nullable!T in the Variant. Mmm - works to some extent, but by the time you'd wrapped it to make the semantics half comprehensible I think it would have been better to simply wrap VariantN to add an extra bool. Steve

Re: NULL indicator in Variant

2011-10-27 Thread kennytm
Steve Teale wrote: > How big a deal would it be to add a NULL indicator to the VariantN struct. > > I use the term NULL as opposed to null deliberately. Variant already > provides the hasValue() method, which can serve as a null indicator. But > in using it as a parameter in database modules, i

Re: NULL indicator in Variant

2011-10-27 Thread Steve Teale
On Thu, 27 Oct 2011 13:58:54 -0400, Steven Schveighoffer wrote: > On Thu, 27 Oct 2011 13:53:02 -0400, Steve Teale > wrote: > >> On Thu, 27 Oct 2011 13:09:43 -0400, Steven Schveighoffer wrote: >> >>> On Thu, 27 Oct 2011 12:58:57 -0400, Steve Teale >>> wrote: >>> On Thu, 27 Oct 2011 16:16:26

Re: NULL indicator in Variant

2011-10-27 Thread Steven Schveighoffer
On Thu, 27 Oct 2011 13:53:02 -0400, Steve Teale wrote: On Thu, 27 Oct 2011 13:09:43 -0400, Steven Schveighoffer wrote: On Thu, 27 Oct 2011 12:58:57 -0400, Steve Teale wrote: On Thu, 27 Oct 2011 16:16:26 +0200, Alex Rønne Petersen wrote: On 27-10-2011 15:50, Steve Teale wrote: Surely

Re: NULL indicator in Variant

2011-10-27 Thread Steve Teale
On Thu, 27 Oct 2011 13:09:43 -0400, Steven Schveighoffer wrote: > On Thu, 27 Oct 2011 12:58:57 -0400, Steve Teale > wrote: > >> On Thu, 27 Oct 2011 16:16:26 +0200, Alex Rønne Petersen wrote: >> >>> On 27-10-2011 15:50, Steve Teale wrote: > > Surely Variant.init should do the trick?

Re: NULL indicator in Variant

2011-10-27 Thread Steven Schveighoffer
On Thu, 27 Oct 2011 12:58:57 -0400, Steve Teale wrote: On Thu, 27 Oct 2011 16:16:26 +0200, Alex Rønne Petersen wrote: On 27-10-2011 15:50, Steve Teale wrote: Surely Variant.init should do the trick? Dmitry, Are you talking about the new std.variant - I don't see 'init' currently. Stev

Re: NULL indicator in Variant

2011-10-27 Thread Steve Teale
On Thu, 27 Oct 2011 16:16:26 +0200, Alex Rønne Petersen wrote: > On 27-10-2011 15:50, Steve Teale wrote: >>> >>> Surely Variant.init should do the trick? >> >> Dmitry, >> >> Are you talking about the new std.variant - I don't see 'init' >> currently. >> >> Steve > > He is probably referring to th

Re: NULL indicator in Variant

2011-10-27 Thread Steve Teale
> Any reason making a custom NULL type wouldn't work? i.e: > > struct NULL {} > > Variant var = NULL; > > assert(var.type == typeof(NULL)); I don't think that is any improvement on hasValue(). It would tell you the particular value was null, but would not tell you what type it was. In a typic

Re: NULL indicator in Variant

2011-10-27 Thread Robert Jacques
On Thu, 27 Oct 2011 10:16:26 -0400, Alex Rønne Petersen wrote: On 27-10-2011 15:50, Steve Teale wrote: Surely Variant.init should do the trick? Dmitry, Are you talking about the new std.variant - I don't see 'init' currently. Steve He is probably referring to the 'init' property on the

Re: NULL indicator in Variant

2011-10-27 Thread Robert Jacques
On Thu, 27 Oct 2011 09:12:26 -0400, Steve Teale wrote: How big a deal would it be to add a NULL indicator to the VariantN struct. I use the term NULL as opposed to null deliberately. Variant already provides the hasValue() method, which can serve as a null indicator. But in using it as a para

Re: NULL indicator in Variant

2011-10-27 Thread Alex Rønne Petersen
On 27-10-2011 15:54, Steve Teale wrote: I'm not sure having three possible states in Variant is a good idea, but maybe I'm not quite following. Doesn't it already carry type information when not set to a value? - Alex Don't believe so. If you haven't set any value, hasValue() will return fal

Re: NULL indicator in Variant

2011-10-27 Thread Alex Rønne Petersen
On 27-10-2011 15:50, Steve Teale wrote: Surely Variant.init should do the trick? Dmitry, Are you talking about the new std.variant - I don't see 'init' currently. Steve He is probably referring to the 'init' property on the *type*, i.e. int.init and so on. - Alex

Re: NULL indicator in Variant

2011-10-27 Thread Steve Teale
> > I'm not sure having three possible states in Variant is a good idea, but > maybe I'm not quite following. > > Doesn't it already carry type information when not set to a value? > > - Alex Don't believe so. If you haven't set any value, hasValue() will return false, so it is kind of null, a

Re: NULL indicator in Variant

2011-10-27 Thread Steve Teale
> > Surely Variant.init should do the trick? Dmitry, Are you talking about the new std.variant - I don't see 'init' currently. Steve

Re: NULL indicator in Variant

2011-10-27 Thread Alex Rønne Petersen
On 27-10-2011 15:12, Steve Teale wrote: How big a deal would it be to add a NULL indicator to the VariantN struct. I use the term NULL as opposed to null deliberately. Variant already provides the hasValue() method, which can serve as a null indicator. But in using it as a parameter in database

Re: NULL indicator in Variant

2011-10-27 Thread Dmitry Olshansky
On 27.10.2011 17:12, Steve Teale wrote: How big a deal would it be to add a NULL indicator to the VariantN struct. I use the term NULL as opposed to null deliberately. Variant already provides the hasValue() method, which can serve as a null indicator. But in using it as a parameter in database

NULL indicator in Variant

2011-10-27 Thread Steve Teale
How big a deal would it be to add a NULL indicator to the VariantN struct. I use the term NULL as opposed to null deliberately. Variant already provides the hasValue() method, which can serve as a null indicator. But in using it as a parameter in database modules, it would be useful to be able