Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #22011 > unrolled thread
| Started by | aljey1972@gmail.com |
|---|---|
| First post | 2013-11-15 00:20 -0800 |
| Last post | 2013-11-19 00:42 +0100 |
| Articles | 10 — 6 participants |
Back to article view | Back to comp.lang.javascript
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: What's wrong with arguments.callee ? aljey1972@gmail.com - 2013-11-15 00:20 -0800
Re: What's wrong with arguments.callee ? Ry Nohryb <jorge@jorgechamorro.com> - 2013-11-15 01:05 -0800
Re: What's wrong with arguments.callee ? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-11-15 06:25 -0800
Re: What's wrong with arguments.callee ? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-15 16:25 +0100
Re: What's wrong with arguments.callee ? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-11-15 09:50 -0800
Re: What's wrong with arguments.callee ? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-11-15 21:15 -0800
Re: What's wrong with arguments.callee ? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2013-11-16 11:31 +0000
Re: What's wrong with arguments.callee ? JJ <duh@nah.meh> - 2013-11-17 01:35 +0700
Re: What's wrong with arguments.callee ? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-11-17 11:34 -0800
Re: What's wrong with arguments.callee ? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-19 00:42 +0100
| From | aljey1972@gmail.com |
|---|---|
| Date | 2013-11-15 00:20 -0800 |
| Subject | Re: What's wrong with arguments.callee ? |
| Message-ID | <46296233-c493-4de4-921e-2dc9c7870622@googlegroups.com> |
I bloody hate this idea, someone really needs to start a petition or smthn to keep arguments.callee
[toc] | [next] | [standalone]
| From | Ry Nohryb <jorge@jorgechamorro.com> |
|---|---|
| Date | 2013-11-15 01:05 -0800 |
| Message-ID | <a522cb30-dd74-40fd-94de-a1081cedcc97@googlegroups.com> |
| In reply to | #22011 |
On Friday, November 15, 2013 9:20:33 AM UTC+1, alje...@gmail.com wrote: > I bloody hate this idea, someone really needs to start a petition or smthn to keep arguments.callee I was having breakfast and said, let's have a look at the good old c.l.j.s., and found this +5 years old thread at the top... for a second I thought I was hallucinating. Yeah, LOL. -- ( Jorge )();
[toc] | [prev] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2013-11-15 06:25 -0800 |
| Message-ID | <1cb35df7-7de2-4139-a31f-100139b5c794@googlegroups.com> |
| In reply to | #22011 |
On Friday, November 15, 2013 2:20:33 AM UTC-6, alje...@gmail.com wrote: > I bloody hate this idea, someone really needs to start a petition or smthn to keep arguments.callee What are you doing that makes you reliant upon it? Have you read any of the history and reasoning on es-discuss yet?
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-11-15 16:25 +0100 |
| Message-ID | <5957377.XgIPmTjdrt@PointedEars.de> |
| In reply to | #22014 |
Michael Haufe (TNO) wrote: > On Friday, November 15, 2013 2:20:33 AM UTC-6, alje...@gmail.com wrote: >> I bloody hate this idea, someone really needs to start a petition or >> smthn to keep arguments.callee > > What are you doing that makes you reliant upon it? > > Have you read any of the history and reasoning on es-discuss yet? I think you are expecting too much of an anonymous Google poster who follows up to a five year old thread without a substantial argument. For that matter, have *you* been reading the thread in which you are posting? It has been pointed out there that there are disadvantages of _not_ using arguments.callee. At least as long as the relevant JScript versions are around. But arguments.callee is not dead, it has just been made forbidden in ES 5 strict mode. That said, since I have not been reading es-discuss either (I do not have the time), I would be grateful, and I expect other readers would, if you could provide (a) relevant URI(s). -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2013-11-15 09:50 -0800 |
| Message-ID | <34f9ce58-665f-47db-a18e-f8c34197b9cf@googlegroups.com> |
| In reply to | #22015 |
On Friday, November 15, 2013 9:25:41 AM UTC-6, Thomas 'PointedEars' Lahn wrote: > > I think you are expecting too much of an anonymous Google poster who > follows up to a five year old thread without a substantial argument. I respond in good faith. I don't care if the poster is anonymous, I'm also attempting to lead the poster to expand on his complaint. > For that matter, have *you* been reading the thread in which you are > posting? It has been pointed out there that there are disadvantages of > _not_ using arguments.callee. At least as long as the relevant JScript > versions are around. But arguments.callee is not dead, it has just been > made forbidden in ES 5 strict mode. The es-discuss threads subsume and duplicate this thread's arguments. In fact I believe at least Jorge participated in them as well. > That said, since I have not been reading es-discuss either (I do not have > the time), I would be grateful, and I expect other readers would, if you > could provide (a) relevant URI(s). Indeed, later today I'll compile and post a list of threads and pull out the main points as summary. (Sadly the ES Wiki is lacking on this topic)
[toc] | [prev] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2013-11-15 21:15 -0800 |
| Message-ID | <07194009-fe3b-40f4-a75b-769d330613ca@googlegroups.com> |
| In reply to | #22017 |
On Friday, November 15, 2013 11:50:06 AM UTC-6, Michael Haufe (TNO) wrote:
> On Friday, November 15, 2013 9:25:41 AM UTC-6, Thomas 'PointedEars' Lahn wrote:
>
> > That said, since I have not been reading es-discuss either (I do not have
> > the time), I would be grateful, and I expect other readers would, if you
> > could provide (a) relevant URI(s).
>
> Indeed, later today I'll compile and post a list of threads and pull out the main points as summary. (Sadly the ES Wiki is lacking on this topic)
The following is a list of urls pointing to what I think are the relevant
points of discussion. While I have attempted to maintain the context while
taking quotes (or paraphrasing/snipping/expanding in [square brackets]),
It is entirely possible some relevant context/detail was missed. Do indeed
read the respective threads for yourself to see who made the individual quotes
and for the full context. Quite a bit has been left out as you'd suspect
The convention below is
<url>
summary comment
Apologies in advance if Google Groups butchers the format slightly. And no,
I have no intention of installing new software or creating a new account
through another service.
<https://mail.mozilla.org/pipermail/es5-discuss/2009-July/002909.html>
"F often passes its "arguments" to G in order to give G access to the
actual arguments it was called with. Just as strict mode protects F against
G thereby modifying F's parameter variables (by not joining), the
arguments.callee poison pill protects F from inadvertently leaking itself to
G."
<https://mail.mozilla.org/pipermail/es5-discuss/2009-July/002911.html>
"[...] F could prevent this leakage by simply deleting the callee property"
<https://mail.mozilla.org/pipermail/es5-discuss/2009-July/002913.html>
"F could likewise prevent G from modifying F's parameter variables by,
for example, passing out 'Array.slice(arguments, 0)' rather than
'arguments'. The point of 'use strict' is to say 'I want the following
code to operate in a somewhat saner and safer language where I don't
have to worry as much about accidental leakage.' Having remembered to
say 'use strict', the programmer should be relieved of saying 'delete
arguments.callee' or 'Array.slice(arguments, 0)'."
<https://mail.mozilla.org/pipermail/es5-discuss/2008-September/001882.html>
"The arguments object itself is often passed in order for function F to
give function G access to the argument list F with which was called.
This seemingly innocent operation should not also inadvertently
provide G with the ability to call F. F might otherwise be
encapsulated within some larger abstraction."
<https://mail.mozilla.org/pipermail/es5-discuss/2008-September/001883.html>
"Hmm, the problem is 'callee' being a property of 'arguments' ?
or the functionality that 'callee' provides ?
IOW, could we have instead a ('standalone') 'callee' property (that
isn't to be innocently passed on) ?"
<https://mail.mozilla.org/pipermail/es5-discuss/2008-September/001884.html>
"...as a property of what?
Any magically bound variable breaks [Tennant's Correspondence]. The expression
callee
should have the same meaning as
(function() { return callee; })()
...and it clearly does not."
<https://mail.mozilla.org/pipermail/es5-discuss/2008-September/001885.html>
[who cares?]
<https://mail.mozilla.org/pipermail/es5-discuss/2008-September/001886.html>
"Just name your function. By itself, this is as convenient -- as well
as more understandable -- as any of the 'conveniences' that have been
proposed to help with this non-problem."
<https://mail.mozilla.org/pipermail/es5-discuss/2008-September/001889.html>
"It's not worth it, especially if you want just
callee (use a named function expression, or bind an outer lexical
name) or caller (stack inspection should be served by a carefully
designed API on the side -- 'mirror' reflection, not an API on
activation objects)."
<https://mail.mozilla.org/pipermail/es-discuss/2011-January/012502.html>
"I can appreciate the security concerns of passing the arguments object
as a parameter to another method, but why not make that the 'red flag'
action rather than nixing 'arguments' entirely?"
<https://mail.mozilla.org/pipermail/es-discuss/2011-January/012506.html>
"IE, prior to IE9, didn't conform to the standard for function
expressions and makes the name 'func' visible in the surrounding
scope. However, if all you want to do if be able to refer to 'func'
within the {...} body and not interfere with any declarations in the
surrounding scope, even for IE <= 8, you can usually accomplish this
by choosing a unique name instead of "func" that is highly unlike to
be used in the surrounding scope."
<https://mail.mozilla.org/pipermail/es-discuss/2011-January/012508.html>
"IE<9 actually creates 2 function objects when parsing NFE; not just leaks
identifier to the enclosing scope. It might seem irrelevant at first, but if
you consider that something like 'var f = function g(){ ... } ' will result
in creation of 2 distinct function objects bound to 'f' and 'g' [...]"
<https://mail.mozilla.org/pipermail/es-discuss/2011-January/012509.html>
"Yes, there is more too it, as [pointed] out. But I think we are at the
point where we are just adding noise to this conversation. [...] A named
function expression with a well chosen name is a very interoperable way
to easily do this. All the other semantic subtleties and implementation
variations in the handling of block nested declarations are not really
all that relevant to straight-forward usage of that pattern."
<https://mail.mozilla.org/pipermail/es-discuss/2009-September/009874.html>
"Using named functions isn't a solution for us because it
would break IE compatibility. [...] Right now I don't see a good solution
for this in strict mode."
<https://mail.mozilla.org/pipermail/es-discuss/2009-September/009878.html>
"But strict mode is not supported in current or downrev IE."
<https://mail.mozilla.org/pipermail/es-discuss/2009-September/009881.html>
"Wouldn't that violate the principle of strict mode? I thought the
idea was that writing code in Harmony could basically boil down to ES3
code if I wanted to. But in this case it wouldn't; the same code
written for Harmony would appear valid ES3 but would fail."
<https://mail.mozilla.org/pipermail/es-discuss/2009-September/009885.html>
"IE fixing bad old named function expression bugs
violates nothing, not ES5 or ES5 strict, and certainly not ES3 which
spec'ed how named function expressions bind their names [...]"
[...]
"You have to test to see that "use strict"; code works the way
you expect in older browsers. If you steer clear of arguments objects
you don't have much to do."
<https://mail.mozilla.org/pipermail/es-discuss/2009-September/009890.html>
"But just to be clear, after all of the discussion here, it appears
that the only way to implement a 'call super' pattern in ES5 (without
resorting to closures [...]) would be to use the
following magic phrase everywhere I want to invoke super:
var IS_ES5_STRICT = /** detect ES5 strict mode somehow */
ClassB = ClassA.extend({
foo: function method() {
(IS_ES5_STRICT ? method : arguments.callee).base.apply(this,
arguments);
}
});
Keep in mind that since I need to know the current function instance,
I can't abstract this code into a function. Everyone will just have
to know this magic phrase to 'call super'."
<https://mail.mozilla.org/pipermail/es-discuss/2009-September/009891.html>
"But why wouldn't you use method always? [...] Agree it's annoying to
have to add six letters of cruft after the function keyword (with space
separator) but once you do that, provided you dodge IE bugs, why do you
need arguments.callee at all?"
<https://mail.mozilla.org/pipermail/es-discuss/2009-September/009908.html>
"If I were a poor woodcutter who couldn't afford his own preprocessing
tools, I would probably just write:
ClassB.foo.base.apply(this, arguments)"
<https://mail.mozilla.org/pipermail/es-discuss/2010-January/010514.html>
"I suggest avoiding super calls. If you really must, then consider a
standard approach that will work consistently across browsers, and in
ES3 and ES5 strict:
ClassB.prototype = {
foo: function() {
ClassA.prototype.foo.call(this);
}
};"
<https://mail.mozilla.org/pipermail/es-discuss/2009-September/009858.html>
"I'm curious, why not just give anonymous functions a default name like
'callee'. Or perhaps have 'callee' defined in a function scope to
represent the function? That seems to be exactly the same as the
above; it just makes it easier for developers. Is there a perf issue
here?"
<https://mail.mozilla.org/pipermail/es-discuss/2009-September/009859.html>
"No, there's simply a backward compatibility problem. Anonymous
functions do not inject any such name on the scope chain (in any
object, new or expected, on the scope chain). Changing the language to
inject callee (even in an ES5 declarative envirnment frame) is not
backward compatible and probably will break some content out there
that uses callee in an outer scope to mean something else."
<https://mail.mozilla.org/pipermail/es-discuss/2009-September/009868.html>
"It seems like the argument against it is security:
if I pass you my arguments object, you now have access to the original
function, which violates the POLA.
Isn't the fact [...] that
arguments.callee can be deleted a mitigating factor here?
Aren't there other fixes that would work as well (such as making
arguments.callee only available lexically) without completely removing the
feature."
<https://mail.mozilla.org/pipermail/es-discuss/2013-March/029187.html>
[in reference to <https://github.com/rwaldron/tc39-notes/blob/master/es6/2013-01/jan-30.md>]
"[...] arrows can't have intrinsic names (contrast with NFEs) so
arguments.callee may be wanted, so arrows should not be strict-only."
<https://mail.mozilla.org/pipermail/es-discuss/2013-March/029188.html>
"I think this is a better argument for introducing a new primitive for
referencing the current function than for resurrecting arguments."
Déjà vu?
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2013-11-16 11:31 +0000 |
| Message-ID | <0.48da816c680c15265a89.20131116113154GMT.87zjp4shud.fsf@bsb.me.uk> |
| In reply to | #22021 |
"Michael Haufe (TNO)" <tno@thenewobjective.com> writes: <snip> > The following is a list of urls pointing to what I think are the relevant > points of discussion. <snip> Thank you for your effort. Very interesting. (The discussion is actually new to me.) -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | JJ <duh@nah.meh> |
|---|---|
| Date | 2013-11-17 01:35 +0700 |
| Message-ID | <ft91jfg53sty$.1a9stwne9lc9w.dlg@40tude.net> |
| In reply to | #22021 |
On Fri, 15 Nov 2013 21:15:16 -0800 (PST), Michael Haufe (TNO) wrote: > "F often passes its "arguments" to G in order to give G access to the > actual arguments it was called with. Just as strict mode protects F against > G thereby modifying F's parameter variables (by not joining), the > arguments.callee poison pill protects F from inadvertently leaking itself to > G." Sorry, I'm not quite good at English and can't understand which part where data is leaked to G. Could you give a simple example code, please?
[toc] | [prev] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2013-11-17 11:34 -0800 |
| Message-ID | <8d52d023-3809-47b3-82c5-6fee6eff3734@googlegroups.com> |
| In reply to | #22023 |
On Saturday, November 16, 2013 12:35:47 PM UTC-6, JJ wrote:
> Sorry, I'm not quite good at English and can't understand which part where
> data is leaked to G. Could you give a simple example code, please?
function f(x,y,z){
console.log([" x:",x," y:",y," z:",z].join(""))
g(arguments);
console.log([" x:",x," y:",y," z:",z].join(""))
}
function g(args){
args[0] = "foo"
args[1] = "bar"
args[2] = args.callee
}
f(1,2,3)
[toc] | [prev] | [next] | [standalone]
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Date | 2013-11-19 00:42 +0100 |
| Message-ID | <5314301.3lsYH2pUt3@PointedEars.de> |
| In reply to | #22030 |
Michael Haufe (TNO) wrote:
> On Saturday, November 16, 2013 12:35:47 PM UTC-6, JJ wrote:
>> Sorry, I'm not quite good at English and can't understand which part
>> where data is leaked to G. Could you give a simple example code, please?
>
> function f(x,y,z){
> console.log([" x:",x," y:",y," z:",z].join(""))
> g(arguments);
> console.log([" x:",x," y:",y," z:",z].join(""))
> }
>
> function g(args){
> args[0] = "foo"
> args[1] = "bar"
> args[2] = args.callee
> }
>
> f(1,2,3)
I think you have misplaced your spaces and semicolons. Anyhow:
function f (x, y, z)
{
"use strict";
/* *x: 1, y: 2, z: 3" */
console.log(["x: ", x, " y: ", y, " z: ", z].join(""));
g(arguments);
/* "x: 1, y: 2, z: 3" */
console.log(["x: ", x, " y: ", y, " z: ", z].join(""));
}
function g (args)
{
args[0] = "foo"
args[1] = "bar"
// args[2] = args.callee
}
f(1, 2, 3);
Therefore, it was _not_ necessary to forbid arguments.callee in strict mode.
--
PointedEars
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web