Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #30388

Re: Can somebody explain this code

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Can somebody explain this code
Date 2016-05-04 05:51 +0200
Organization PointedEars Software (PES)
Message-ID <3332181.Nmlc57RfOh@PointedEars.de> (permalink)
References (2 earlier) <nd1sgj$esr$1@dont-email.me> <3457976.2eFHA4iNFV@PointedEars.de> <nd9ipa$7r2$1@dont-email.me> <2497856.AOaF6Xk2y9@PointedEars.de> <nd9q0f$2h4$1@dont-email.me>

Show all headers | View raw


Aleksandro wrote:

> On 27/03/16 20:07, Thomas 'PointedEars' Lahn wrote:
>> Aleksandro wrote:
>>> On 27/03/16 17:44, Thomas 'PointedEars' Lahn wrote:
>>>> Aleksandro wrote:
>>>>> On 24/03/16 16:30, Thomas 'PointedEars' Lahn wrote:
>>>>>>   var myFunc;
>>>>>>   myFunc = function () { alert("This is my anonymous function"); };
>>>>>>
>>>>>> (In that case, “myFunc” is assigned the “undefined” value first.)
>>>>> Would the VM actually assign undefined first? I doubt it.
>>>> On what grounds?
>>> Well, there's a thing called optimization... you know...
>> Although successive lines, they are not necessarily processed so.
> 
> But they might.

I am not convinced.

There are at least four points that you are overlooking here:

1. It was an *example* demonstrating functional equivalence of lines of
   source code.

2. myFunc = function () { alert("This is my anonymous function"); };
   var myFunc;
   
   is equivalent to the previous code, too.

3. There can be source code between declaration and assignment, and in the 
   assignment, referring to the variable.  The value of the variable has to
   be the “undefined” value then.

4. There is not only one virtual machine.  It need not even *be* a *virtual*
   machine; for example, Google V8 JIT-compiles source code directly into 
   machine code.

   <https://developers.google.com/v8/design>

Taking unnecessary risks based on wild guesses and wishful thinking is the 
mark of a wannabe.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Can somebody explain this code "Tony Johansson" <johansson.andersson@telia.com> - 2016-03-23 22:51 +0100
  Re: Can somebody explain this code Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-24 20:30 +0100
    Re: Can somebody explain this code Aleksandro <aleksandro@gmx.com> - 2016-03-24 20:19 -0300
      Re: Can somebody explain this code Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-27 22:44 +0200
        Re: Can somebody explain this code Aleksandro <aleksandro@gmx.com> - 2016-03-27 18:22 -0300
          Re: Can somebody explain this code Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-03-28 01:07 +0200
            Re: Can somebody explain this code Aleksandro <aleksandro@gmx.com> - 2016-03-27 20:26 -0300
              Re: Can somebody explain this code Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-05-04 05:51 +0200
                Re: Can somebody explain this code "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-05-04 08:55 +0200
                Re: Can somebody explain this code Aleksandro <aleksandro@gmx.com> - 2016-05-07 13:02 -0300

csiph-web