Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2009-09

ObjC branch

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

dmitry boyarintsev

Hello FPC Developers.

With the recent discussion of "what new fpc feature students can implement" (at lazarus mailling list), I've followed the given link: http://edn.embarcadero.com/article/34324

Do understand things right? Delphi (.net?) class helpers are very close to objective-C categories, for the expection, that helpers can also add additional members and properties. While categories are allowed to add new methods only?

Personally i don't like any kind of .nettism in Pascal. (as well as i don't follow delphi "new features").
But still, if the fp compiler is to "catch up" with newer Delphi, should Obj-C branch use the similiar syntax?!

NSSomeCategory = objcclass for NSObject
end;

imho, the following code looks much better:

NSSomeCategory = objccategory (NSObject)

thanks,
dmitry

Reply by email

Marco van de Voort
to dmitry boyarintsev

In our previous episode, dmitry boyarintsev said:

Show quoted text 5 lines
Do understand things right? Delphi (.net?) class helpers are very close to objective-C categories, for the expection, that helpers can also add additional members and properties. While categories are allowed to add new methods only?

As far as I know, categories really add methods to the object, in dynamical ObjC object style.

Helpers afaik don't "really" add them, since they are only static (class) methods which are added to the scope, if the helper is USESd.

Reply by email

Jonas Maebe
to dmitry boyarintsev: Hello FPC Developers. With the recent discussion of "what new fpc feature students can…
dmitry boyarintsev wrote
Do understand things right? Delphi (.net?) class helpers are very close to objective-C categories, for the expection, that helpers can also add additional members and properties.

Can they really add new fields? (I guess that's what you mean by "members") The page you referenced only talked about methods and properties.

While categories are allowed to add new methods only?

It can also override existing ones.

Show quoted text 5 lines
But still, if the fp compiler is to "catch up" with newer Delphi, should Obj-C branch use the similiar syntax?! NSSomeCategory = objcclass for NSObject end;

I think it would actually be:

NSSomeCategory = objcclass helper for NSObject
end;
imho, the following code looks much better: NSSomeCategory = objccategory (NSObject)

I really don't have a strong opinion. I propose we go with "objccategory" for now, and if support for class helpers is added one day then we can always still allow that syntax for categories (there will be no backwards compatibilities with allowing that).

As Marco mentioned, categories are different though. For example, a category can override a method of a class (and then it does so for every class instance of that type in existence, including derived ones), while a class helper cannot do that. A class helper is indeed just a syntactic extension (as mentioned on the web page, mainly to be used for cleanly implementing some low level language/rtl support).

Jonas

Reply by email