---------- Forwarded message ---------- From: Ciprian Teodorov <ciprian.teodorov@gmail.com> Date: Sat, May 18, 2013 at 10:11 PM Subject: Re: [Pharo-project] [NativeBoost] Allow hierarchy of objects in function definition To: Pharo-project@lists.gforge.inria.fr Hi guys, Here is another idea which I think is nice, without disabling the typechecker or anything: I suppose the LGitObjectExternal is a subclass of NBExternalObject in LGitObjectExternal implement the #git_object_lookup as follows: LGitObjectExternal>primitiveLookupIn: repo id: id type: type <primitive: 'primitiveNativeCall' module: 'NativeBoostPlugin' error: errorCode> ^self call: #(git_return_t git_object_lookup(self, git_repository_ptr repo, git_oid_ptr id, git_otype type)) then all the calls to #primitiveLookupIn:id:type: would succeed in all subclassed of LGitObjectExternal without doing anything special. cheers, ciprian On Sun, May 5, 2013 at 12:14 PM, Max Leske <maxleske@gmail.com> wrote:
I have a wish for NativeBoost (which is probably on your list anyway Igor, just wanted to put it out there): function definitions should be able to understand that I want to accept any object of a hierarchy.
Here's my use case:
self call: #(git_return_t git_object_lookup(LGitCommitExternal * object, git_repository_ptr repo, git_oid_ptr id, git_otype type))
This function takes a pointer to any of LGitCommitExternal, LGitTreeExternal and LGitBlobExternal. The obvious way for me to do this was to create a superclass LGitObjectExternal and use that superclass in the function like so:
self call: #(git_return_t git_object_lookup(LGitObjectExternal * object, git_repository_ptr repo, git_oid_ptr id, git_otype type))
But that gives me an error. So for now I can either use a dummy object (like NBExternalObject) and then convert from that or I have to implement the same function thrice in the different object flavors. Being able to use a superclass would just be awesome!
Cheers, Max
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro -- Dr. Ciprian TEODOROV Ingénieur Développement CAO tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro