Javascript Namespace

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Evertjan.

    #16
    Re: Javascript Namespace

    Lasse Reichstein Nielsen wrote on 23 jun 2008 in comp.lang.javas cript:
    In Javascript it is a lexical scope.
    Lasse, we are speaking in different worlds.

    You are starting with what the original JS writing fathers or the ECMA
    writers wanted it to be.

    I am starting with what I would like to be a language of just objects
    with it's properties and methods. An intellectual challenge.

    All thsi started in this thread because Pointed put my Ears up on the
    idea,
    that a function must be nothing more or less than a method of an object,
    usually the root object [my wording], and a variable a property of the
    same. [while in fact they all thre are just pointers to those three, and
    only those pointers 'have' scope limitations.]

    The internal implementation, nor the primordial ideas of the writing
    fathers come into play with my idealistic 'scope', where there is no
    place for things like a "lexical" scope [what is that anyway?], and there
    is no place to call anything global which is only the root of all
    objects, as global is about scope, so only about pointers.

    Probably even object hierarchy is only about pointers, I have to think
    that through.

    The present differences of use of object, object.method[function] and
    object.property[variable] would be finished.

    Defaulting would be only a matter of coding ease, not linked to any
    internal substance but to scope limitations.

    Oh what a wonderful objective Pointed pointer world it would be,
    where not only the Ears, but the whole JS is "doing it with" pointers.

    <http://www.audiobookso nline.com/media/1572701439.jpg>

    ;-)

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • Lasse Reichstein Nielsen

      #17
      Re: Javascript Namespace

      "Evertjan." <exjxw.hannivoo rt@interxnl.net writes:
      Lasse Reichstein Nielsen wrote on 23 jun 2008 in comp.lang.javas cript:
      >
      >In Javascript it is a lexical scope.
      >
      Lasse, we are speaking in different worlds.
      >
      You are starting with what the original JS writing fathers or the ECMA
      writers wanted it to be.
      >
      I am starting with what I would like to be a language of just objects
      with it's properties and methods. An intellectual challenge.
      We are indeed speaking about different things, if you are talking
      about a hypothetical language that is similar, but not equivalent, to
      Javascript.
      All thsi started in this thread because Pointed put my Ears up on the
      idea,
      that a function must be nothing more or less than a method of an object,
      usually the root object [my wording], and a variable a property of the
      same. [while in fact they all thre are just pointers to those three, and
      only those pointers 'have' scope limitations.]
      PointedEars merely pointed out that a "global function" was already a
      property of an object.
      Not all functions are, in Javascript.
      Take this expression:

      Code:
      alert( (function(y){return function(x){return y+x};})(24)(18) );
      There are two functions here that are not properties of any object
      at any time. The outer is just an anonymous function. The inner
      is an anonymous function that even leaves its defining scope.

      The internal implementation, nor the primordial ideas of the writing
      fathers come into play with my idealistic 'scope', where there is no
      place for things like a "lexical" scope [what is that anyway?],
      A lexical scope is one where the association between variable declaration
      and variable use is determined by the program syntax. A variable use
      always refer to a variable declaration in a syntactically enclosing
      block/scope.

      Example:
      Code:
      function test(x) {
      var a = function(f,x) { return f(x); }
      return a(function(y){return x;}, 42);
      }
      alert(test(37));
      This alerts 37. The "x" in "return x" refers to the argument of the
      "t" function, even if the function containing the "return x" is
      eventually called in the scope of another declaration of "x".

      Syntactic scope is so natural to most programmers that they don't even
      think of it. However, not all languages have syntactic scope. The
      Common Lisp and Emacs Lisp languages has the "opposite": dynamic scope.
      Example(in elisp):
      Code:
      (let ((test (lambda (x)
      (let ((a (lambda (f x) (funcall f x))))
      (funcall a (lambda (y) x) 37)))))
      (funcall test 42))
      It is equivalent to the above Javascript program, but its result
      is 37.
      and there is no place to call anything global which is only the root
      of all objects
      Root of objects? Objects does not have to form any hierarchy. The
      scope chains might, but if that is what you refer to, do call the
      it "scope".
      , as global is about scope, so only about pointers.
      And I'm not sure what "pointers" mean here either.
      Probably even object hierarchy is only about pointers, I have to think
      that through.
      Objects are referenced through references. Calling them pointers are
      reasonable, although sometimes slightly misleading. But that means that
      any object structure is connected through references, whether hierarchial
      or not.
      The present differences of use of object, object.method[function] and
      object.property[variable] would be finished.
      Is there a difference?

      Personally, I'd much rather that they made the global object unreachable
      through code, so the only way to create new variables is using the
      "var" construction.
      Accessing variables as properties of an object is so ... explicit.
      It exposes what I consider an implementation detail: that an object
      holds the variables. Most other languages do fine without that.

      /L
      --
      Lasse Reichstein Nielsen
      DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      • Lasse Reichstein Nielsen

        #18
        Re: Javascript Namespace

        Lasse Reichstein Nielsen <lrn@hotpop.com writes:
        Example(in elisp):
        (let ((test (lambda (x)
        (let ((a (lambda (f x) (funcall f x))))
        (funcall a (lambda (y) x) 37)))))
        (funcall test 42))
        >
        It is equivalent to the above Javascript program, but its result
        is 37.
        Which is the correct result, when you noticed that I managed to swap
        37 and 42 in the program, compared to the Javascript example.
        Oops.
        The point stands, though :)
        /L
        --
        Lasse Reichstein Nielsen
        DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
        'Faith without judgement merely degrades the spirit divine.'

        Comment

        • Peter Michaux

          #19
          Re: Javascript Namespace

          On Jun 23, 9:51 am, Thomas 'PointedEars' Lahn <PointedE...@we b.de>
          wrote:
          With host objects, all bets are off.[tm]
          <URL:
          http://tess2.uspto.gov/bin/showfield?f=toc &state=t9tfpi.1 .1&p_search=sea rchss&p_L=50&Ba ckReference=&p_ plural=yes&p_s_ PARA1=&p_tagrep l%7E%3A=PARA1%2 4LD&expr=PARA1+ AND+PARA2&p_s_P ARA2=%22With+ho st+objects%2C+a ll+bets+are+off .%22&p_tagrepl% 7E%3A=PARA2%24C OMB&p_op_ALL=AN D&a_default=sea rch&a_search=Su bmit+Query&a_se arch=Submit+Que ry>

          Try for yourself

          <URL: http://tess2.uspto.gov/bin/gate.exe?f=sear chss&state=t9tf pi.1.1>

          Peter

          Comment

          • Thomas 'PointedEars' Lahn

            #20
            Re: Javascript Namespace

            Peter Michaux wrote:
            Thomas 'PointedEars' Lahn wrote:
            >With host objects, all bets are off.[tm]
            >
            <URL:
            http://tess2.uspto.gov/bin/showfield?f=toc &state=t9tfpi.1 .1&p_search=sea rchss&p_L=50&Ba ckReference=&p_ plural=yes&p_s_ PARA1=&p_tagrep l%7E%3A=PARA1%2 4LD&expr=PARA1+ AND+PARA2&p_s_P ARA2=%22With+ho st+objects%2C+a ll+bets+are+off .%22&p_tagrepl% 7E%3A=PARA2%24C OMB&p_op_ALL=AN D&a_default=sea rch&a_search=Su bmit+Query&a_se arch=Submit+Que ry>
            >
            Try for yourself
            No, thanks.

            <http://www.catb.org/~esr/jargon/html/0/TM.html>
            <URL: http://tess2.uspto.gov/bin/gate.exe?f=sear chss&state=t9tf pi.1.1>
            404-compliant.


            PointedEars
            --
            var bugRiddenCrashP ronePieceOfJunk = (
            navigator.userA gent.indexOf('M SIE 5') != -1
            && navigator.userA gent.indexOf('M ac') != -1
            ) // Plone, register_functi on.js:16

            Comment

            • Evertjan.

              #21
              Re: Javascript Namespace

              Lasse Reichstein Nielsen wrote on 24 jun 2008 in comp.lang.javas cript:
              We are indeed speaking about different things, if you are talking
              about a hypothetical language that is similar, but not equivalent, to
              Javascript.
              Not at all, Lasse.

              Your * Javascript is only as axiomatically specified, I presume,
              while my Javascript allows talking about change and improvement.

              * ... idea of ...

              I prefer to discuss mine.

              -
              Evertjan.
              The Netherlands.
              (Please change the x'es to dots in my emailaddress)

              Comment

              Working...