On 10/9/09 00:23, Nick Sabalausky wrote:
"Jacob Carlborg"<[email protected]>  wrote in message
news:[email protected]...
In the first D conference there was some talk about uniform function call
syntax which allowed a.foo(x) and foo(a, x) to be interchangeable (just as
we have now with arrays), what happened do that? Will it still happen?


Yea, I find not having that to be a painful inconsistancy. Been hoping for
that for a while.

Except for the mentioned advantages in the talk I've found another use for
it. When creating bindings to Objective-C it could be used to simulate
categories which otherwise is quite hard simulate and doesn't scale well.
The only way I found requires that the source is available of the class to
add the methods to.

I poked around in the DMD sources I found that it's really easy to add,
just edit one line.

Can you please post the file, line number, old line, new line, and dmd ver?
Or submit a patch to bugzilla. That could be helpful for anyone who wants to
look into this furthur.

I've submitted a patch to bugzilla: http://d.puremagic.com/issues/show_bug.cgi?id=3382

However there is a problem it don't work for literals like 3.foo(), for
that I think that parser needs to be modified.


For those unfamiliar with Objective-C and categories: "A category allows
you to add methods to an existing class—even to one to which you do not
have the source",
http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocCategories.html#//apple_ref/doc/uid/TP30001163-CH20-SW1


Do you know if that actually affects the class itself (like adds an entry to
the vtable or , or something like that)? If not, that sounds like what C#
calls extension methods, which are just like what D does with arrays (except
that you have to actually declare the function to be an extension method -
which I've been kind of on the fence about as to whether I like that or
not).



Reply via email to