advertisement

Article:
  Memory Management in Objective-C
Subject:   Object Semantics
Date:   2001-07-31 10:42:35
From:   psheldon
Response to: Object Semantics

I am enjoying Cocoa introduced to me by Mike Beam. I thank you for your responses to my question.

To show kindness and gratitude, I think I should stick my neck out actively responding to your responses and try to tell how they helped me focus.


I shall give you three prefatory examples :
Once I knew a computer science major who constantly asked the question is this a pass by reference or pass by value. It seemed to him a fundamental question that would clarify his understanding of code. What was the meaning or semantics of that old equal sign.
In optical holography I saw two images called equal if they had transmission fields that were proportional. Once I knew there was a semantics to the symbol equal that was held in the "folklore of the subject", things became a whole lot easier to read and write.
Maple allows assignment of expressions to variables and has complex rules of whether to take final evaluations or intermediate evaluations for procedures that I yet need to learn to use profitably. Not that I don't think this complexity useful, rather I don't yet know how to be useful with it.


Some more introductory remarks to try to tell that I am coming from somewhere safe:
When you have gotten to the point of thinking in a language, things aren't explicitly written down in any publication or textbook, but rather in this "folklore of the subject". The guys who write the insides of a language or compiler know stuff users don't and probably in a folklorish sort of way. They are not ready to share this, either because it will scare off users or just because it hasn't gotten "that perfect" yet.
The semantic debates between language and compiler designers might, in fact, be blessedly hidden. Nonetheless, these debates happened. The big boys argued, each thought he won and the lesser of us might hide in one big boys house or the others. Whether the hiders or the big boys have ahold of the greater truth might be questioned. One can learn a lot playing a game for a little while rather than merely practicing running things into the ground with high level debate. There are also more choices of how to be than these two; I can choose to believe this.


My search for threads to make things coherent :


You (CanyonRat) mentioned "pointer semantics" which told me the words in that formal presentation that I wanted. That was very reassuring.


So, I sherlock 2 searched those words and sped read a bunch of threads :
http://www.rt.mipt.ru/docs/oop/chap12/study.htm
and reassuringly found my question, "What does it mean to say a programming language uses pointer semantics for assignment? ", a study question for a text on general object oriented programming.


Then, I sherlock 2'd again :
http://vip.cs.utsa.edu/classes/cs4773s97/classes/cs4773.topic20.html
"There are three possible interpretations of assignment
...
Pointer semantics: Assignment changes the reference of the left side to be the right side.
Also called pointer assignment
The two variables not only have the same value but also refer to the same object. "

All that reassures me from this statement is that the meaning (semantics) of the equal sign in an assignment varies in different languages.


Now, from my thread experience, I attempt to stretch my imagination (do the homework, pay my dues) to try to see pointer semantics might mean equal sign semantics (meaning).


Suppose there were a language that only passed or assigned by pointer semantics, then the compiler might look to see if a parameter were already a pointer or autoconvert to a pointer for assignments within a method (I believe what you call "behind the scenes conversion from myType to myType*."). I saw some debate in these threads about whether autoconversion was a good thing or could have you pointing to something that wasn't there and this was debate about language design involving tradeoffs of release pools vs other ways of freeing memory (beyond my caliber). That it was debated indicated that it was considered.
Thence, I believe, you write "You just have to accept that ObjC is an OO language that uses pointer semantics and move on". Indeed, I don't wish to debate semantics or which language is best I am not of that caliber. I want to get just a "feel" of the axioms of Cocoa, but can't demand axiomatic definition or be pleased if someone gave it to me (I probably would get confused). Right now I can want to go on and code and dirty my hands. Indeed, as Justin Armstrong wrote, "...spend a while looking at it, ObjC takes some getting used to, but is in fact entirely sensible!" (well I'm not sensible, yet, and wish I could get more sensible as painlessly as possible).
;-)


I am sorry that I don't have the axiomatic base or feel to write tersely as you do. For example, your "All these languages are dealing with the same question: "How do I return an object from a method that will remain valid when the method goes out of scope?"" Languages are candidate solutions to my question, oh boy. Have I asked a question whose answer is beyond my caliber to appreciate?
I think somewhere in the book objective C is a caveat that there is no EBNF or grammar representation for objective C yet, it's in the "folklore" we are sharing now and you guys are sharing a more distilled version than I.


Thank you, I feel a little wiser but am still hungry as I am not entirely sensible, yet.
;-)
I have learned that when I do homework things always get more confused before they get simpler. I don't know whether I should have done homework in open forum because of this, yet I felt I should aknowledge response publically and gratefully.
I hope you see I am human and don't bite.
Maybe someone will be able to say the threads I found above in a more distilled fashion than I did and I shall be happier.


1 to 1 of 1
  1. Where is the folklore
    2001-08-01 20:54:55  canyonrat [View]

    • Where is the folklore
      2001-08-02 14:21:24  psheldon [View]

      • cocoa-dev with browser-nomail option
        2001-08-02 21:24:14  psheldon [View]

      • Where is the folklore
        2001-08-02 20:46:40  canyonrat [View]

        • thanks, checked omnigroup (nomail?)
          2001-08-02 21:40:48  psheldon [View]

          • thanks, checked omnigroup (nomail?)
            2001-08-03 07:29:38  canyonrat [View]

1 to 1 of 1