Top 5

Chris R. Miller lordsauronthegreat at gmail.com
Fri Oct 10 17:36:26 PDT 2008


Robert Fraser wrote:
> Chris R. Miller wrote:
>> Benji Smith wrote:
>>> Chris R. Miller wrote:
>>>> Benji Smith wrote:
>>>>> 4. String processing sucks. Writing code that works transparently 
>>>>> with all three character types and correctly handles all unicode 
>>>>> characters is basically impossible. Or at least it feels 
>>>>> impossible. Trying to support both Phobos and Tango in the same 
>>>>> string-processing routine is a definite no-go. In an ideal world, 
>>>>> string-processing code shouldn't have to be littered with "static 
>>>>> if" all over the place.
>>>>
>>>> How would this be "fixed?"  Hint: don't suggest making strings an 
>>>> object.  We tried that a while back, and it was more or less shot down.
>>>
>>> Well, personally, I'd prefer it if strings were objects.
>>
>> As well for me.  Worked just fine in Java, I don't see why it can't 
>> work here.  Rather, knowing what I know about D and Java, I would tend 
>> to think that a D implementation of a String as an object would be 
>> /more/ powerful than the Java implementation.
>>
>>> But I could accept strings as character arrays if they were actually 
>>> characters arrays.
>>
>> Amen.
> 
> http://www.dprogramming.com/mtext.php
> 
> Nearly as efficient as regular strings & same memory footprint as the 
> type of the lagest character within (i.e. if it contains only ascii, 8 
> bits/char. If it contains things representable in UTF-16, 16 bits a 
> character. If it contains cuneoform, 32 bits per char).

That's all fine and dandy, but the appeal of the Java-String Object is 
that it is ubiquitous.  All the existing code already accepts it as the 
standard.  Even though mtext looks good, it still won't be able to be 
plugged into existing code (unless I'm mistaken, which I would be 
delighted to be).

Perhaps the two object and native strings could coexist?  I know that in 
Objective-C you can create a normal "dumb" C-style string using the 
normal syntax "foo bar is a string", but you can create a beefier 
object-as-a-string (NSString) by using another syntax @"foo bar is an 
NSString".

I'm not directly saying "this is what we should do!" (or even @"this is 
what we should do!") but I'm just throwing the idea out there - maybe 
someone will have a better iteration on the concept?



More information about the Digitalmars-d mailing list