V2 string

Regan Heath regan at netmail.co.nz
Fri Jul 6 01:11:35 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>.

The first argument which I think holds water is that it is trivial to 
represent empty and non existant in C, eg.

char *empty = "";
char *non-existant = NULL;

The other argument is the one made earlier about databases.  In a 
database empty and non-existant are important distinct states a value 
could have.

Currently, D can model these but it worries me that you don't seem to 
think that it's important.  So, perhaps in future you might decide to 
get rid of this, or do so accidently.

Regan



More information about the Digitalmars-d mailing list