Higher level built-in strings

Rory McGuire rmcguire at neonova.co.za
Tue Jul 20 07:51:57 PDT 2010


On Tue, 20 Jul 2010 16:08:06 +0200, Jesse Phillips  
<jesse.k.phillips at gmail.com> wrote:

> But then you can't overload operators.
>
> On Tue, Jul 20, 2010 at 12:54 AM, Rory McGuire <rmcguire at neonova.co.za>  
> wrote:
>> On Tue, 20 Jul 2010 01:51:51 +0200, Jesse Phillips
>> <jessekphillips+d at gmail.com> wrote:
>>
>>> What about:
>>>
>>> struct String {
>>>        string items;
>>>        alias items this;
>>> }
>>>
>>> And add the needed functions you wish to have in string and it will  
>>> still
>>> work in existing functions that operate on immutable(char)[]
>>
>> You shouldn't need to do that:
>>
>> string strstr(string haystack, string needle);
>>
>> can be used as:
>>
>> string s;
>> s.strstr("needle");
>>
>> so you can add "methods" to a string or whatever just by defining  
>> functions.
>>
>> -Rory
>>
>
>
>

such as?


More information about the Digitalmars-d mailing list