A new class -->String

Daniel Keep daniel.keep.lists at gmail.com
Thu Apr 5 07:34:01 PDT 2007



Jari-Matti Mäkelä wrote:
> David B. Held wrote:
>> Jari-Matti Mäkelä wrote:
>>> David B. Held wrote:
>>>> If there were a way to switch between method call and free
>>>> function syntax, then this distinction would become moot (and maybe we
>>>> will get that as well...).
> 
>>> D has that already :)
> 
>> Well, it isn't general:
>>
>> void foo(int x) { int y = x; }
>>
>> unittest
>> {
>>     int z = 5;
>>     z.foo();
>> }
>>
>> test.d(43): Error: no property 'foo' for type 'int'
>> test.d(43): Error: function expected before (), not 1 of type int
> 
> Hm, I wonder if that's a compiler bug. I have not used this feature
> recently, but I recall it used to work. I even have bindings where this
> feature is used to provide an alternative syntax for a wrapper class.
> Now that I tested it, it only seems to work with arrays and AAs anymore.
> But it's still enough to implement those string functions though.

>From what I understand, it's not a feature, it's a bug.  No, I'm
serious: this happens because of a bug in DMD.  The only reason it's
never been fixed is because people actually really, really like that it
works :)

The whole "switch function to member of first arg" thing is only usable,
as you said, on arrays and AAs.  Having it usable in general would be
wicked-nifty-awesome-keen, to mix my colloquialisms. :)

	-- Daniel

-- 
int getRandomNumber()
{
    return 4; // chosen by fair dice roll.
              // guaranteed to be random.
}

http://xkcd.com/

v2sw5+8Yhw5ln4+5pr6OFPma8u6+7Lw4Tm6+7l6+7D
i28a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP  http://hackerkey.com/



More information about the Digitalmars-d mailing list