V2 string

Bill Baxter dnewsgroup at billbaxter.com
Thu Jul 5 22:36:37 PDT 2007


Derek Parnell wrote:
> On Fri, 6 Jul 2007 14:23:43 +1000, Derek Parnell wrote:
> 
>> On Thu, 05 Jul 2007 20:58:11 -0700, Walter Bright wrote:
>>
>>> James Dennett wrote:
>>>> I've found many times when the difference between an empty
>>>> string and no string was important; they generally have
>>>> nothing to do with extending at all.  I'd be interested to
>>>> know why you assert that no such cases exist.
>>> I'd like to know of such cases.
>>   char[] Option;
>>
>>   Option = getOptionFromUser();
>>   if (Option.ptr = 0)
>>   {
>>    Option = DefaultOption;
>>   }
>>
>> However, if the user sets the option to "" then that is what they want and
>> not the default one.
> 
> And if you must nitpick that one can code this a different way then here is
> another example.
> 
> 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.
> 

In databases NULL being different from empty seems to a big deal too.

Anyway googling for "null versus empty" turns up a bevy of hits, so from 
that I think we can presume that the distinction is important to a 
non-empty subset of programmers.

--bb



More information about the Digitalmars-d mailing list