"Jonathan Scott Duff" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Wed, Jan 29, 2003 at 11:32:53AM -0800, Michael Lazzaro wrote:
> >
> > Agreed, it's not pretty.  The fundamental problem is that a primitive
> > like an C<int> simply cannot be undefined... there's no flag for that
> > (which is they're primitive.)
>
> The solution I advocate is to allow even "primitive" types to hold
> undef.  I don't have an implementation, but that's just a detail I'll
> leave to those actually doing the implementation  :-)
>
> > A simple solution is perhaps to say that C<is default> can only be
> > applied to types that can be undef (scalar,ref,Int,Str...) and can't be
> > used on things that have no undefined state (bit,int,str...).

C++ had a design principle: you only pay for what you ask for. From a
different perspective: if you ask for it, then you're willing to pay. So if
you ask for a default on an array of primitive types, then the
implementation assumes that you're willing to pay for it: but only for those
arrays that have defaults.

The fact of the default is a property of the array, not of the elements it
stores. There's no need to add undef values to primitive types. The most
obvious solution (obvious =/=> best) is a boolean (bit) array whose elements
are associated with elements in the data array. Yes, there's a cost, but if
the programmer asks for something, then they pay for it. But the
implementation guys aren't allowed to play bait-and-switch!

Dave.
--
http://dave.whipp.name


Reply via email to