Top-level environment

Discussion in 'Mac Programming' started by mdeh, Oct 29, 2009.

  1. macrumors 6502

    Joined:
    Jan 3, 2009
    #1
    One of the frustrating things, is reading about new things, ( eg blocks and lexical scope) and seeing terms that have no definition.

    Such is this one " Top-level environment" which has plenty of hits on Google, but no where is this defined, that I can find.

    Could one of the "computer-geeks" possibly define this type of environment?

    Thanks
     
  2. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    If you provide a link to the article in question it may help to provide some context for the answer.

    I would assume that top level environment refers to the highest level of Mac OS X (namely the Cocoa layer rather than the lower level Core Services, Core OS and the Kernel layers).
     
  3. thread starter macrumors 6502

    Joined:
    Jan 3, 2009
    #3


    OK..


    HTML:
    http://en.wikipedia.org/wiki/Scope_(programming)

    .
    Scroll down to the heading that says "Static Scoping"
     
  4. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #4
    That seems a rather clunky description to me.

    Static scope basically just means that the scope of a variable or function is worked out at compile time rather than runtime.
     
  5. thread starter macrumors 6502

    Joined:
    Jan 3, 2009
    #5


    Well...I found this that perhaps is clearer???


     
  6. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #6
    I think that terminology is more prevalent in the Scheme world which I have very limited experience with. I doubt you would hear many C or Objective-C programmers talking about "top level environments".

    As with most things in computing terminology changes with the context it is used in.

    Still it was interesting to see that second text, thanks.
     
  7. macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #7
    The most similar concept I can think of would be namespaces in C++, and the use of the scope resolution operator, ::.

    In plain C, while there is definitely scope, as you dive down into deeper nested scope, using a variable name that is defined in a higher scope can be done, but you can no longer access a variable with the same name with a higher scope. There's no way to say you'd like the x with global scope if you have one with, say, the scope of the current for loop.

    -Lee
     
  8. macrumors G4

    Joined:
    May 10, 2004
    #8
    Yes, when I saw "top level environment" I thought it was a thread about Lisp.

    It is the outermost scope in an execution stack.

    C++ namespaces are completely unrelated.
     
  9. macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #9
    Nested namespaces are similar (in concept) are they not?
     
  10. macrumors G4

    Joined:
    May 10, 2004
    #10
    It is a type of scoping, but it's not the same.

    At a point in the execution, you have a dynamic environment and a lexical environment. When navigating the stack with a debugger you can examine the lexical and dynamic variables in the current environments.
     

Share This Page