syntax for assigning to an array

V

VK

Now try this:
Evidently the interpreter thinks that new Array(a,b,c) and [a,b,c] are
all different creatures: on the eval block it gives "illegal left-hand
side assignment".
Now comment the try-catch with eval and uncomment the second try-catch
with the direct assignment. The "illegal left-hand side assignment" is
still here, but now it is a syntax error, not a run-time one anymore.
No code is executed, you have to look the error console for the
message. So I don't care what is written in JavaScript1.7 changes, but
the real thought of the author of these changes should be close to
what I said and quoted again at the top of this message.

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<script>
var a,b,c;
try {
[a,b,c] = [1,2,3];
window.alert(a);
}
catch(e) {
window.alert('[a,b,c] '+e.message);
}

try {
eval("new Array(a,b,c) = new Array(1,2,3)");
window.alert(a);
}
catch(e) {
window.alert('new Array '+e.message);
}

//try {
// new Array(a,b,c) = new Array(1,2,3);
// window.alert(a);
//}
//catch(e) {
// window.alert('new Array '+e.message);
//}
</script>
</head>
<body>
</body>
</html>
 
T

Thomas 'PointedEars' Lahn

VK said:
http://developer.mozilla.org/en/docs/New_in_JavaScript_1.7#Using_JavaScript_1.7

"In order to use some of the new features of JavaScript 1.7, you need
to specify that you wish to use JavaScript 1.7. In HTML or XUL code,
use:
<script type="application/javascript;version=1.7"/>
"

Uhm... Did we use this type? I see that not but 1.7 is still in all
its "beauty"

[rant]

If you had any clue what you are writing about, you would have known that
it is not necessarily to declare the language version for that particular
feature as it does not use a new keyword. Unsurprisingly, the above
resource documents this.


PointedEars
 
T

Thomas 'PointedEars' Lahn

VK said:
Now try this:
Evidently the interpreter thinks that new Array(a,b,c) and [a,b,c] are
all different creatures: on the eval block it gives "illegal left-hand
side assignment".

They *are* "all different creatures" here. The left-hand-side of a
destructuring assignment is not an Array object literal.
Now comment the try-catch with eval and uncomment the second try-catch
with the direct assignment. The "illegal left-hand side assignment" is
still here, but now it is a syntax error, not a run-time one anymore.

A syntax error is a type of runtime error. Again you are only demonstrating
that you have no clue at all what you are writing about. Why don't you save
everybody the trouble and stop posting here until you got a minimum clue?


PointedEars
 
T

Thomas 'PointedEars' Lahn

VK said:
In PHP, if a function returns an array it's fairly common to capture
its return values like this:

<?php
list($foo, $bar, $baz) = some_function_that_return_an_array();
?>

In Javascript, would the equivalent (acceptable) code be this?

[foo, bar, baz] = some_function_that_return_an_array();

[args] in JavaScript is an implicit Array constructor call.

In this case it is not, but rather a list.
Constructor call cannot be left-hand side of the assignment,

It is not an implicit constructor call there.

Probably someone already told you that you have no clue what you are writing
about.
Evidently some of Gecko JavaScript engine developers came from Perl/
PHP grounds

It is much more likely that this feature was borrowed from Python. Brendan
Eich explicitly referred to implementing features in JavaScript like they
are in Python in his blog. That also includes Array comprehensions which
have also been introduced with JavaScript 1.7.
so it just added a feature he used so do to not be
bothered with language/standards differences.

The usual utter VK nonsense.


PointedEars
 
T

Thomas 'PointedEars' Lahn

slebetman said:
Not a "totally different language" per se. Javascript 1.7 only updates
Javascript to include most of the features of the latest ECMAScript spec.

Not quite. JavaScript 1.7 came first.
This is actually fully valid ECMAScript 4.

I would welcome that, though.
[...] AFAIK the only two languages based on ECMAScript that have been
updated to include ECMAScript 4 features are Javascript 1.7 and
Actionscript 3 (Flash/Flex, though Actionscript3 doesn't support array
destructuring).

JScript .NET is based on Netscape's first ES4 proposal.


PointedEars
 
V

VK

They *are* "all different creatures" here. The left-hand-side of a
destructuring assignment is not an Array object literal. ....
A syntax error is a type of runtime error.

Poitless... Your knowledge is just low to have a reasonable
conversation.
 
T

Thomas 'PointedEars' Lahn

Thomas said:
VK said:
Now comment the try-catch with eval and uncomment the second try-catch
with the direct assignment. The "illegal left-hand side assignment" is
still here, but now it is a syntax error, not a run-time one anymore.

A syntax error is a type of runtime error. [...]

Please ignore that, it's nonsense. (A syntax error is a parsing error which
prevents execution.)


PointedEars
 
T

Thomas 'PointedEars' Lahn

VK said:
Poitless... Your knowledge is just low to have a reasonable
conversation.

I stand corrected (by myself) for my second statement. I stand by my first
statement, though. Your quoting it and referring to it also as nonsense
shows again who lacks the basic knowledge here. Not everything that looks
like an Array object literal is parsed as such.


PointedEars
 
V

VK

Thomas 'PointedEars' Lahn said:
They *are* "all different creatures" here. The left-hand-side of a
destructuring assignment is not an Array object literal.

They are not *any more* the same things in JavaScript1.7 as they were
for the last 10 years by all official specs? and now some anonymous
author broke it for its convenience, and the other called it
"destructuring assignment" and the job is done... That is my point:
the *core* of the language - any language, not just JavaScript - is
not some external interface to play with. It is a very serious deal.
It still can be changed to meet burning evident modern demands, but it
is definitely not something to silently and anonymously break and then
comment in one paragraph of text in some corporate wiki. Once there
were discussion here over non-standard upon ECMA 3ed ed. handling of
function-expressions. Now anyone is entitled to break the core of the
language as long as it's named beautifully?
 
T

Thomas 'PointedEars' Lahn

VK said:
Thomas 'PointedEars' Lahn said:
They *are* "all different creatures" here. The left-hand-side of a
destructuring assignment is not an Array object literal.

They are not *any more* the same things in JavaScript1.7 as they were
for the last 10 years by all official specs? and now some anonymous
author broke it for its convenience, [rant]

How stupid are you anyway?

,-[ECMAScript Ed. 1 to 3 Final]
|
| 2 Conformance
|
| [...]
| A conforming implementation of ECMAScript is permitted to support
| program [...] syntax not described in this specification.

http://developer.mozilla.org/presentations/xtech2006/javascript/


PointedEars
 
V

VK

,-[ECMAScript Ed. 1 to 3 Final]
|
| 2 Conformance
|
| [...]
| A conforming implementation of ECMAScript is permitted to support
| program [...] syntax not described in this specification.

http://developer.mozilla.org/presentations/xtech2006/javascript/

Faked contract quoting, Sir: up to 5 year in jail + up to $100,000
fine + up to 100% of caused financial losses == life long out of
business :) :-|

http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
2 Conformance
"A conforming implementation of ECMAScript is permitted to support
program and regular expression syntax not described in this
specification. In particular, a conforming implementation of
ECMAScript is permitted to support program syntax that makes use of
the "future reserved words" listed in 7.5.3 of this specification."
 
T

Thomas 'PointedEars' Lahn

VK said:
,-[ECMAScript Ed. 1 to 3 Final]
|
| 2 Conformance
|
| [...]
| A conforming implementation of ECMAScript is permitted to support
| program [...] syntax not described in this specification.

http://developer.mozilla.org/presentations/xtech2006/javascript/

Faked contract quoting, Sir: up to 5 year in jail + up to $100,000
fine + up to 100% of caused financial losses == life long out of
business :) :-|

I could write now that you are not making any sense, but this is a *news*group.
http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
2 Conformance
"A conforming implementation of ECMAScript is permitted to support
program and regular expression syntax not described in this
specification. [...]

Thanks for answering my rhetorical question.


PointedEars
 
V

VK

VK said:
,-[ECMAScript Ed. 1 to 3 Final]
|
| 2 Conformance
|
| [...]
| A conforming implementation of ECMAScript is permitted to support
| program [...] syntax not described in this specification.
http://developer.mozilla.org/presentations/xtech2006/javascript/
Faked contract quoting, Sir: up to 5 year in jail + up to $100,000
fine + up to 100% of caused financial losses == life long out of
business :) :-|

I could write now that you are not making any sense, but this is a *news*group.

So what deep sense are you putting into "A conforming implementation
of ECMAScript is permitted to support program and regular expression
syntax not described in this specification." ?
As if say "@#$%^ ==== )(*&^%" could be a valid ECMAScript-compliant
statement as long as it's named somewhere some nicely, like "de-
restructuring mutable thingies" or something? Before reading and
trying to interpret really difficult matters like language specs one
need to get a feeling first what the programming is and what a
programming language is. You are not on this stage yet.
 
T

Thomas 'PointedEars' Lahn

VK said:
VK said:
On Nov 30, 1:14 am, Thomas 'PointedEars' Lahn <[email protected]>
wrote:
,-[ECMAScript Ed. 1 to 3 Final]
|
| 2 Conformance
|
| [...]
| A conforming implementation of ECMAScript is permitted to support
| program [...] syntax not described in this specification.
http://developer.mozilla.org/presentations/xtech2006/javascript/
Faked contract quoting, Sir: up to 5 year in jail + up to $100,000
fine + up to 100% of caused financial losses == life long out of
business :) :-|
I could write now that you are not making any sense, but this is a *news*group.

So what deep sense are you putting into "A conforming implementation
of ECMAScript is permitted to support program and regular expression
syntax not described in this specification." ?

That which is most obvious to anyone but you: A destructuring assignment
is "program syntax that is not described in [the ECMAScript] specification."
JavaScript 1.7 "is permitted to support" that while being "a conforming
implementation of ECMAScript". So all your ranting that JavaScript 1.7
would break anything or that it would violate any standard is completely
baseless, of course.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top