Uniform function call syntax

Michel Fortin michel.fortin at michelf.com
Thu Oct 8 16:24:56 PDT 2009


On 2009-10-08 18:23:32 -0400, "Nick Sabalausky" <a at a.a> said:

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

There is no vtable in Objective-C, but yes categories will add methods 
to classes just as if they where in the original class. Methods from 
categories are overridable in subclasses and can be seen through 
reflection.

I've proposed previously a similar system for D. The idea was to build 
vtables at runtime, or use a special linker to do the same.

See: http://michelf.com/weblog/2009/some-ideas-for-dynamic-vtables-in-d/
and: http://michelf.com/weblog/2008/vtable-benchmarking/

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list