X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 10 Nov 2014 08:06 AM by  anon
Static method - called by object or as static method?
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:25
New Member


--
10 Nov 2014 08:06 AM
    Hello, I am looking for a way to discover (within the method) if a static method that is called is actually called as a static method or from the object class with which it is associated. I have not come up with a way to determine this. Thanks

    Deleted User



    New Member


    Posts:7
    New Member


    --
    11 Nov 2014 05:19 AM
    Hi Paul, You can just check the implicit self parameter. For regular methods it is set to the reference to the calling object, but in a static call it is set to a NULL object reference. Imanol

    Deleted User



    New Member


    Posts:25
    New Member


    --
    14 Nov 2014 07:35 AM
    Hello, thanks for the reply. Well, isa(self) works to tell if the object has been instantiated. But I was thinking of a case where an object has been instantiated yet a method was called as a static function. So, I was interested in knowing how the function was called. I guess it is more of an academic question, not sure if there is a use for this information. I usually assume that a method called with a parameter is a static, and a method called without a parameter is a not a static ( and checks isa(self) and looks internally for the required data). But I as thinking, this a there a way to tell if the method was called: self->method ; called as object or className->method ; called as static even when the class is instantiated. Like I said, might not be useful info but I was curious.
    You are not authorized to post a reply.