Re: Obj-C, class methods and instance methods
Re: Obj-C, class methods and instance methods
- Subject: Re: Obj-C, class methods and instance methods
- From: Michael Gersten <email@hidden>
- Date: Fri, 24 May 2002 22:26:07 -0700
>
> |Semantics time: You don't call methods, the runtime invokes methods
>
> |when you send messages. This distinction is subtle but very, very
>
> |important to understanding the gestalt of real object-oriented
>
> |programming. (I wish people here would make it more often, it helps
>
> |to keep things clear.)
>
>
>
> Speaking as one of those people who consistently fail to make this
>
> distinction, I fail to do so because I see no distinction to make.
>
>
Exactly! And OOP does not exist. I can encapsulate data structures and
>
operations in Modula 2. An object is a module, and a message is a
>
procedure call, and that's it. After 25+ years I'm still wondering what
>
all that fuss about Smalltalk, C++, Objective C, Java and other so
>
called object-oriented languages is.
I have to agree with you. I mean, it's not that hard to have a globally accessable data structure of names and values that any part of the code can modify, and is expected to. Heck, it's even called NSDictionary. Make one, put it in a well known place, and don't worry about central routines to update it. Java, ObjC, they're no different than basic.
>
(For the irony impaired: this is irony.)
<Sigh>. I used a basic that supported labels instead of line numbers. I did some ADT programming in basic, and at one point, I had to implement a parameter stack using an array.
Structured programming, ADT programming, recursion, it's all there in the worst languages. Gotos, global datas, lack of encapsulation, it's all there in the best of them.
Heck, even skrit, which wasn't supposed to have any looping, has recursive function calls. Never did find out if they optimized tail recursion or not. (There's a while statement now :-).
Now, if you are still confused about Method vs. Message, etc, consider this:
When you send a message to an object, and there is no method for that message, then it goes to a forwarding method, that can examine the message, the sender (via the stack), and anything else (maybe even the call chain, check and see if the "SECURITY_ON" function was called in the current call chain?). It can treat the entire invocation as arbitrary data. Not all that different than an HTTP server that really reads in a string, processes it arbitrarily (although usually by a convention about '/''s, '?', param=value¶m2=value2, etc), and outputs another string. Or do you consider a URL and the output page to be the same thing?
A URL is a message.
What is eventually done to get the output (not under your control) is the method.
There is a convention that a given class, for a given message, runs a given piece of code, but it doesn't have to. Heck, it could (stupid, but possible) grab a random method from its list of methods and call that.
>
Marco Scheurer
>
Sen:te, Lausanne, Switzerland http://www.sente.ch
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
--
I am a Mac 10-Cocoa/WOF/EOF developer, and I'm available for hire. Please contact me at michael-job @ stb.nccom.com if interested.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.