Spec#, nullables and more

spir denis.spir at gmail.com
Sat Nov 6 00:12:30 PDT 2010


On Fri, 05 Nov 2010 23:13:44 -0600
Rainer Deyke <rainerd at eldwood.com> wrote:

> On 11/5/2010 17:41, Walter Bright wrote:
> > In other words, I create an array that I mean to fill in later, because
> > I don't have meaningful data for it in advance.
> 
> That's a faulty idiom.  A data structure that exists but contains no
> valid data is a bug waiting to happen - no, it /is/ a bug, even if it
> does not yet manifest as incorrect observable behavior.  (Or at best,
> it's an unsafe optimization technique that should be wrapped up in an
> encapsulating function.)

You may be right as for local variables. But think at elements of structured data. It constantly happens that one needs to define fields that have no meaningful value at startup, maybe even never will on some instances. (Even more in static languages, indeed.) What placeholder can we feed the struct with? Isn't this precisely the hole .init is intended to fill?
What do you think?

Denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com



More information about the Digitalmars-d mailing list