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


Groups > comp.lang.javascript > #8336

Re: defining functions

Message-ID <1832768.JWMFFTIkK4@PointedEars.de> (permalink)
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Organization PointedEars Software (PES)
Date 2011-11-14 19:49 +0100
Subject Re: defining functions
Newsgroups comp.lang.javascript
References <4eb4a8de$0$28686$a8266bb1@newsreader.readnews.com> <j9499f$opc$1@speranza.aioe.org> <2999732.SPkdTlGXAF@PointedEars.de> <j9pkf6$3b5$1@speranza.aioe.org>
Followup-To comp.lang.javascript

Followups directed to: comp.lang.javascript

Show all headers | View raw


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.

>>> 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*.)

>>> I'd strongly suggest that you purchase and read this book carefully.
>>
>> I strongly suggest that you stop believing blindly in what book authors
>> (anyone, really) say and start thinking for yourself.  /Sapere aude!/
> 
> I stand my point: this is an excellent book, although there are some
> minor errors / typos in it the same way it happens to other excellent /
> good books. And praising a book / author has nothing to do with blind
> faith.

Trying to propagate their misconceptions as being the absolute truth instead 
has.


PointedEars
-- 
> 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

Back to comp.lang.javascript | Previous | NextPrevious in thread | Next 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