On Wed, Jan 29, 2003 at 02:37:04PM -0600, Jonathan Scott Duff wrote:
> On Wed, Jan 29, 2003 at 03:29:57PM -0500, Aaron Sherman wrote:
> > On Wed, 2003-01-29 at 14:54, Jonathan Scott Duff wrote:
> > 
> > > Can someone give me a realish world example of when you would want an
> > > array that can store both undefined values and default values and those
> > > values are different?
> > 
> > my @send_partner_email is default(1);
> > while $websignups.getline {
> >     ($id) = /UserID: (\d+)/;
> >     if /Source: External DB With No Privacy Policy/ {
> >             @send_partner_email[$id] = undef; # No answer given
> >     } elsif /Spam Me: Yes/ {
> >             @send_partner_email[$id] = 1;
> >     } else {
> >             @send_partner_email[$id] = 0;
> >     }
> > }
> > # If you were not in the websignups list, you signed up before privacy
> > # policy, so we spam you (default=1)
> 
> But aren't those values arbitrary?  Couldn't you just have
> easily used -1 instead of undef?  Why would undef be necessary or
> preferred?

Sure, they're arbitrary but undef is is preferred because it indicates
the decision is undefined.  You seem to have snipped this:

> In this case, there's a true "shrug" answer, which is hard to deal with.
> We need to do something later on with the undefined case (no answer was
> given, and no spam warning issued). This sort of logic deferral is
> common to many uses of undefined values (or "NULL") in databases, even
> when columns have defaults that are non-null.

The reference to databases is salient.  There are surely many examples
to be found in SQL books.

-- 
Rick Delaney
[EMAIL PROTECTED]

Reply via email to