Lasse Reichstein Nielsen wrote:
> Thomas 'PointedEars' Lahn <> writes:
>> Jukka K. Korpela wrote:
>>> 12.8.2011 22:01, CqN on cr-48@devChan-13.0.782.43 wrote:
>>>> In the following code:
>>>>
>>>> function t(){
>>>>
>>>> var d = new Date (string)
>>>> var t = d.getTime();
>>>>
>>>> ...
>>>>
>>>> delete (d); //IS THIS IMPLCITE by the scope rules of js ???
>>>> Essentially redundant?
>>>> }
>>>
>>> It is a no-operation,
>>
>> No, it is not.
>
> In this case, it is. The state before and after is the same.
That is not the definition of a no-operation.
> Obviosuly, that's assuming that the code isn't strict-mode code.
A `delete' operation checks its operand and can throw an exception even when
not in strict mode. A no-operation on the other hand does nothing at all.
>>> and raises a SyntaxError exception in strict mode.
>> Which is additional proof that it is _not_ a no-operation.
>
> If "it" refers to the delete operator in general, agree.
> If "it" refers to the actual use above, disagree.
Your problem. It takes a non-zero number of steps for the `delete'
operation here. If it was a no-operation, the number of steps were zero.
>>> (On Firefox in non-strict mode, it causes a warning.
>>
>> _In JavaScript_, not "on Firefox".
>
> Why not "on Firefox" (ok, "in Firefox" would be better, but let's not
> be pedantic[1]).
>
> It is Firefox that decides to show a warning in the console.
> The Mozilla JavaScript specification has no notion of warnings.
There is no "Mozilla JavaScript specification" – you made that up. Warnings
are a feature of the SpiderMonkey JavaScript script engine embedded in e.g.
Firefox (and compatible implementations, like Rhino and Narcissus); the
error console of Firefox (among other Firefox extensions, like Firebug, and
Mozilla-based browsers) only employs them.
<https://developer.mozilla.org/en/SpiderMonkey/JSAPI_Reference>
> See, e.g.,
>
https://developer.mozilla.org/en/Jav...Special/delete
> It's quite possible to have a JavaScript implementation that doesn't
> show a warning.
You are confusing browsers with ECMAScript implementations, JavaScript with
ECMAScript, and JavaScript with other ECMAScript implementations.
>>> The delete operator deletes a property of an object. When the operand is
>>> an unqualified variable, as here, it has no effect.
>>
>> (What do you consider to be a qualified variable, then?)
>>
>> The `delete' operator deletes properties of native objects that do not
>> have the `[[DontDelete]]' attribute (in ES5, properties that do have the
>> [[Configurable]] attribute). Identifiers that are declared as variables
>> [[are properties of the Variable Object of the execution context they are
>> declard in and have the `DontDelete' attribute (in ES5, they are
>> References to an Environment Record binding, respectively).
>
> .. unless the variable was declared in eval code, in which case it can
> be deleted.
Unless the eval code is strict code in which case there is nothing to
delete, but the `delete' operation does not throw an exception and it
evaluates to `true'. Which might be a Chromium 13.0.782.107 V8 (presumably
3.3.10.17) bug; but I am not sure if I understand ES5, section 11.4.1, steps
2 and 3 correctly.
Source code:
eval("'use strict'; var x = 42;");
/* throws ReferenceError when uncommented */
// x;
/* true in said Chromium version, no SyntaxError */
delete x;
/* throws ReferenceError */
x;
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16