class extensions
Chris Nicholson-Sauls
ibisbasenji at gmail.com
Thu Aug 30 13:51:20 PDT 2007
Alexander Panek wrote:
> Chris Nicholson-Sauls wrote:
>> I reiterate what I've said about three times now: I watch as D slowly
>> turns into Ruby. :)
> Hehe. They indeed have similarities - maybe not in language theory or
> overall concept, but in innovation. Having (part of) Ruby's
> expressiveness in D would be a very neat thing, as long as it doesn't
> affect other concepts and goals of D.
I'm sure we'll never, ever, see something quite like:
$db.commit @transaction unless @transaction.flag_set? :Simulate
But other than that... ;)
>> (Although I actually like pseudo-members. ColdC has this as well, but
>> by modifying a type-lib object; $String.foo() callable as "abc".foo()
>> for example.)
>
> That's actually possible already in D (D1, even):
>
> //
> import tango.io.Stdout;
>
> void print (char[] s) {
> Stdout(s);
> }
>
> void main () {
> "Hello world!".print(); // omitting () is not possible, though
> }
> //
Oh yes, I know. :) (See Cashew.) But unlike D/1.x, ColdC supports this for all types
(in its own weird way). Right now it only works for arrays, and was originally just a
fluke side-effect that got popular.
It looks like D/2.x is going to open up that Pandora's Box though. Here's hoping it goes
a lot better than the referenced myth.
-- Chris Nicholson-Sauls
More information about the Digitalmars-d
mailing list