V2 string
Bruno Medeiros
brunodomedeiros+spam at com.gmail
Sat Jul 7 12:51:37 PDT 2007
Walter Bright wrote:
> Derek Parnell wrote:
>> Let's say that there is this library routine, which is closed source
>> and I
>> don't have access to its source, that accepts a string as its argument.
>> Further more, if that passed string is null the routine uses a default
>> value - whatever that is because I don't know it. Now in my code I
>> call it
>> with ...
>>
>> SomeFunc(""); -- Use an empty string to do its magic
>> SomeFunc(null); -- But this time, use the default value
>>
>> Remember, I have no control over the SomeFunc routine's implementation.
>
> Of course, if a function is documented to behave that way, and you have
> no control over it, you must adhere to its documentation.
>
> There are other ways to do default arguments. I suspect we could argue
> about it like we could argue about tab stops, and never reach any sort
> of resolution <g>.
Uh, unlike tab stops, I think it is widely recognized by the developer
community that it is useful to have a distinction between *valid* and
*invalid* values of something.
Why is there a NAN for floats (and in D NAN is the default value for
floats) ? What if NAN was equal to zero? Didn't you yourself, Walter,
said once that if there was a way to have an actual invalid value for
ints (without sacrificing precision) you would like to have that, and
you would place it as the default value for int, instead of -1 (which is
a valid int)?
So why shouldn't arrays (who are already reference types) have a value
that means "invalid array", especially if we can get that for free
(unlike ints)?
--
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d
mailing list