Sign In/My Account | View Cart  

advertisement

AddThis Social Bookmark Button

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.

Full Threads Oldest First

Showing messages 1 through 6 of 6.

  • Where is the folklore
    2001-08-01 20:54:55  canyonrat [View]

    ObjC hasn't really been used by enough people for long enough to have its folklore published yet. That's OK. The books that capture the spirit and the conventions of any development system are distilled from news groups and mailing lists. You can always go to the source.

    Stroustrup suggests that if you are seriously using any language, you should subscribe to at least two news groups/mailing lists dedicated to it. I think that's good advice.

    For ObjC the best candidates seem to be:
    cocoa-dev@lists.apple.com
    and
    macosx-dev@omnigroup.com

    You can learn a lot just lurking. But do ask questions. The folks are friendly and helpful.
    • Where is the folklore
      2001-08-02 14:21:24  psheldon [View]

      Thank you. I am very curious about these candidates, especially omnigroup's. They were involved in os x translations of the game quake and have uncommented game frameworks.

      I really like the newsgroup thread structure so that I would not appear intrusive and also could choose what to read . Do these have thread structure ?
      From superficially looking at them being e mail addresses I write to, I am sorry that cocoa-dev@lists.apple.com and macosx-dev@omnigroup.com don't seem to have this thread structure.
      Perhaps, however, I write these e mail addresses to join the list ? Yet I might like to see that the lists supply a thread structure.

      Do e mails there work like yahoo e groups and appear on a web page like this forum with threads.

      Do they put my on some sort of local-computer group list for my news reader (newswatcher, incidentally).

      Looking at my isp's group list, I searched objective and found objective c.
      comp.lang.objective-c
      This was the only newswatcher group I found that seemed relevant.
      • cocoa-dev with browser-nomail option
        2001-08-02 21:24:14  psheldon [View]

        In the FAQ about the list that the e mail address, cocoa-dev@lists.apple.com, writes to, Apple indicates you can have a nomail option.
        http://www.lists.apple.com/cgi-bin/mwf/topic_show.pl?id=46
        Apple's list further offers other less intrusive mail options such as receive digest once a day rather than individual mails.
        FAQ also indicated people actually didn't want to use newsservers :
        http://www.lists.apple.com/cgi-bin/mwf/topic_show.pl?id=47

        Apple writes :
        http://www.lists.apple.com/mailman/listinfo/cocoa-dev
        "The archives are not currently searchable. We're working on adding a search engine to the archives, but don't yet have a date that it'll be functional. "
        so the list only has "human memory" now.

        I am ever curious about Apple's knowledge navigation improvements.
      • Where is the folklore
        2001-08-02 20:46:40  canyonrat [View]

        I should have given the web address of those lists. Cocoa-dev is at:
        http://lists.apple.com/mailman/listinfo/cocoa-dev
        macosx-dev is at:
        http://www.omnigroup.com/community/developer/mailinglists/macosx-dev/

        Threading is really done in the reader and it's easier to thread a news group than a mailing lit so many mailers don't thread. I tend to use Entourage because it threads both news groups and mailing lists.

        If you don't have a threading mail program, both of the above lists let you read threads on the web.

        comp.lang.objective-c has some good discussions but it's more oriented to people porting and extending the ObjC language and not just to Mac programmers.
        • thanks, checked omnigroup (nomail?)
          2001-08-02 21:40:48  psheldon [View]

          Interesting that you can have a threading mail program, but more interesting is that the list can observe threads in archives through a browser.
          Since I couldn't find the FAQ, I want to ask confirmation does omnigroup have a nomail option as well?
          • thanks, checked omnigroup (nomail?)
            2001-08-03 07:29:38  canyonrat [View]

            I think you can do this by subscribing and then turning on the "nomail" option. That may disable your ability to send to the list, though.