Uniform function call syntax

Jacob Carlborg doob at me.com
Thu Oct 8 13:09:27 PDT 2009


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?

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. 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


/Jacob Carlborg



More information about the Digitalmars-d mailing list