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


Groups > comp.lang.javascript > #26798

Re: Definition of a script in JavaScript

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Definition of a script in JavaScript
Date 2015-02-04 21:30 +0100
Organization PointedEars Software (PES)
Message-ID <1461461.3dWKjPQk9Z@PointedEars.de> (permalink)
References <JavaScript-20150204202621@ram.dialup.fu-berlin.de>

Show all headers | View raw


Stefan Ram wrote:

>   I want to use JavaScript® - not ECMAScript, so my reference is
>   the Mozilla Developer Network (MDN).

Since (Mozilla) JavaScript® is an implementation of ECMAScript, you should 
use both ECMA-262-5.1 (ECMAScript Language Specification, 5.1 Edition), and 
the current Edition 6 working draft, and MDN as reference material.  Because 
you are considering Mozilla JavaScript in an HTML context, you should also 
use the HTML5 specification.

Since MDN is largely based on a community wiki, where MDN content 
contradicts normative references the latter are correct.  It would be 
appreciated then if you either correct the error in MDN or notify someone 
who can do that in your place, for example me.

>   I wanted to know what a script is. For example, In HTML5 we use:
> 
>       <script src="javascript.js"></script>
> 
>   Now, let's look at »javascript.js«, assume that it contains:
> 
> lo, world" );
> 
>   This would be a syntax error, ok?

Yes, because in HTML5 the default value for the “type” attribute of the 
“script” element is "text/javascript":

<http://www.w3.org/TR/html5/scripting-1.html#attr-script-type>

And – the cause may be surprising to some – in a conforming implementation 
of ECMAScript a double-quote character (<">) is not allowed to be part of an 
identifier.

>   So, there must be some syntax rule (grammar rule) for what
>   one can write into a script and what not.

Yes.

>   I am trying to find this grammar rule. So far, I only found
>   this in the MDN:
> 
>       »The HTML <script> element is used to embed or reference an
>       executable script within an HTML or XHTML document.«
>       ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
>   But were is the definition of »executable script«?
>   Where is the grammar rule for »executable script«?

<http://www.w3.org/TR/2014/REC-html5-20141028/scripting-1.html#the-script-element> p.

<http://www.w3.org/TR/2014/REC-html5-20141028/scripting-1.html#scriptingLanguages> pp.

>   For example, the language C defines what a »translation-unit«
>   (aka »C source file«) is as follows:

C is not a scripting language.

>   Where does the MDN give the syntax for what one can write
>   in the file »javascript.js«?

It does not.  Although it would be agreeable to have a Mozilla JavaScript 
grammar, apparently the ECMAScript grammar in combination with the 
JavaScript Reference have sufficed for a sufficient number of software 
developers to date.

-- 
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 | Next | Find similar | Unroll thread


Thread

Re: Definition of a script in JavaScript Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-04 21:30 +0100

csiph-web