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


Groups > comp.lang.javascript > #8338

Re: defining functions

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail
From "J.R." <groups_jr-1@yahoo.com.br>
Newsgroups comp.lang.javascript
Subject Re: defining functions
Date Mon, 14 Nov 2011 17:00:18 -0200
Organization Aioe.org NNTP Server
Lines 63
Message-ID <j9rog2$du1$1@speranza.aioe.org> (permalink)
References <4eb4a8de$0$28686$a8266bb1@newsreader.readnews.com> <j9499f$opc$1@speranza.aioe.org> <2999732.SPkdTlGXAF@PointedEars.de> <j9pkf6$3b5$1@speranza.aioe.org> <1832768.JWMFFTIkK4@PointedEars.de>
NNTP-Posting-Host edb3lPNLwDIT/BKKc/Xuzw.user.speranza.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-Complaints-To abuse@aioe.org
User-Agent Mozilla/5.0 (Windows NT 6.0; rv:8.0) Gecko/20111105 Thunderbird/8.0
X-Notice Filtered by postfilter v. 0.8.2
Xref x330-a1.tempe.blueboxinc.net comp.lang.javascript:8338

Show key headers only | View raw


On 14/11/2011 16:49, Thomas 'PointedEars' Lahn wrote:
> J.R. wrote:
>
>> On 07/11/2011 10:26, Thomas 'PointedEars' Lahn wrote:
>>>> *And finally, the most important difference IMO lies in the hoisting
>>>                                                               ^^^^^^^^
>>>> behavior*:
>>>     ^^^^^^^^
>>> I beg your pardon?
>>>
>>>> [...] all variables, no matter where in the function body they are
>>>> declared, get hoisted to the top of the function behind the scenes.
>>>
>>> Utter nonsense.
>>
>> No, it is not.
>
> Yes, it is.

Well, I don't agree with you.

>
>>>> The same applies for functions because they are just objects assigned to
>>>> variables.
>>>
>>> That is oversimplifying talk; nothing is "hoisted" here.  What really
>>> happens is that all declarations in source code are specified to happen
>>> before control reaches the first statement of the execution context.
>>> Variable instantiation adds a property to the ES 1 to 3 Variable Object,
>>> with the identifier of the variable or function as name [1].  In ES 5.x,
>>> this is described as Declaration Binding Instantiation, i. e. bindings
>>> added to a VariableEnvironment's Environment Record, instead, but it
>>> follows essentially the same pattern [2].
>>
>> The book's author explains the term "hoisting" on page 15:
>> […]
>
> What you don't seem to get is that I don't care that they define that term
> and I don't care who uses or seconds it.  And neither should you.  It is
> oversimplifying talk, thereby wrong and misleading to use it without the
> accompanying definition.  That said, it is completely unnecessary to invent
> new terms here (but that appears to be a recurring theme nowadays, starting
> with "Ajax").
>
> The Specification's terms of "variable instantiation" or "declaration
> binding instantiation" are clear enough, and by contrast there really is an
> *authority* to which the definitions can be ascribed: the authors of the
> ECMAScript Language Specification, i. e. the Ecma International Technical
> Committee 39.  (That is not to say they are infallible, but *they* *make*
> *the* *standard*.)

This time I must agree with you. Damn it!

 >> If you get a bunch of authors […] that state the same "best
 >> practices" in any programming language, then you can bet who is
 >> wrong or right...
 > Not with javascript. Nonsense propagates like wildfire in this field.
   -- Richard Cornford, comp.lang.javascript, 2011-11-14

Great Richard Cornford, always brilliant!

-- 
Joao Rodrigues (J.R.)

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


Thread

defining functions Denis McMahon <denismfmcmahon@gmail.com> - 2011-11-05 03:09 +0000
  Re: defining functions "Richard Cornford" <Richard@litotes.demon.co.uk> - 2011-11-05 04:35 +0000
    Re: defining functions Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-05 14:46 +0100
  Re: defining functions "J.R." <groups_jr-1@yahoo.com.br> - 2011-11-05 19:19 -0200
    Re: defining functions Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-07 13:26 +0100
      Re: defining functions "J.R." <groups_jr-1@yahoo.com.br> - 2011-11-13 21:39 -0200
        Re: defining functions Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-14 19:49 +0100
          Re: defining functions "J.R." <groups_jr-1@yahoo.com.br> - 2011-11-14 17:00 -0200

csiph-web