473,395 Members | 1,584 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Why deprecate function caller access?

Hi,

Sorry if this's been discussed before, I couldn't find it.
As well you know, the ECMAScript standard doesn't include any way to
access a function's caller. This has been available on Mozilla and IE as
a 'caller' property of function objects, and it seems Konqueror/Safari
now have it too. Opera doesn't. And what bothers me is that it is marked
as 'deprecated'.

I've seen people I respect swear by their lives that it is *good* to
have it deprecated. 'Because there are better ways of doing what you
want'. I can't understand this. They keep repeating that even after one
says that what one wants is *precisely* to get a reference to the
caller. I can perfectly well understand that power can be mishandled,
but that is no reason to take power away when there is no other
alternative. If the fear of having javascript's features misused could
be invoked to remove features, one would end up pretty fast with no
javascript at all. Almost anything can be misused, and I see better
candidates for exclusion.

Admittedly the mechanism could be improved - beginning with having a
special variable which would refer to the current function itself and
from which all context information could be derived, and if a special
variable doesn't sound good, then by all means a member of the Function
object - something like Function.current, or Function.getCurrent() -
would be welcome. But what is not welcome at all is the menace of
removal of a basic feature of the language with no alternative at all.
Sorry, but just to say that 'caller isn't needed' is the same as calling
the other person stupid. Of course there might be some uses of 'caller'
which could be solved in a different, better way. Not all of them,
though, and what is gained by removing it other than ego-rubbing?
I should point out that 'goto' (as if it were a comparable case!) has
alternatives. There is nothing you can do with it that you can't do
without. Not so here.

Could anyone explain this to me?
Cheers,
Antonio




--
Posted via a free Usenet account from http://www.teranews.com

Jan 18 '08 #1
7 4382
António Marques wrote:
I've seen people I respect swear by their lives that it is *good* to have
it [the caller property] deprecated. 'Because there are better ways of
doing what you want'. I can't understand this.
ISTM that the statement becomes more understandable when considering the
context in which it was given, that you have not told about. IOW: *What*
is it exactly that you want?
They keep repeating that even after one says that what one wants is
*precisely* to get a reference to the caller.
But *why* do you want that?
I can perfectly well understand that power can be mishandled, but that is
no reason to take power away when there is no other alternative.
I wonder what you think the power would be. With a caller property or a
reference passed as an argument, you will only get a reference to a Function
object (or `null'). You cannot know, without much effort in manually
bookkeeping object references, what that Function object is a method of,
nor, to make matters even more complicated, as the method of which object
it was called.
If the fear of having javascript's features misused could be invoked to
remove features, one would end up pretty fast with no javascript at all.
I don't think possible misuse was the reasoning for the decision, but rather
deemed uselessness and observed missing universal implementation, as
demonstrated by your stating that Opera's script engine lacking it. It
would be reasonable to exclude such a feature from the Specification, as
section 2 of the Specification allows implementations to support properties
that were not specified (among other things). The decision of the
implementors to deprecate that property is an entirely different matter --
why don't you ask *them* about it?
Admittedly the mechanism could be improved - beginning with having a
special variable which would refer to the current function itself
You mean the standardized arguments.callee property?
and from which all context information could be derived,
It would seem that this information is somehow exposed internally, otherwise
Venkman and Firebug could not provide it.
[...] Sorry, but just to say that 'caller isn't needed' is the same as
calling the other person stupid. [rant]
Name at least one example where you deem a caller property to be required
and we can discuss it then. Anything else is just a waste of time.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Jan 19 '08 #2
VK
On Jan 18, 10:15 pm, António Marques <m...@sapo.ptwrote:
Hi,

Sorry if this's been discussed before, I couldn't find it.
As well you know, the ECMAScript standard doesn't include any way to
access a function's caller. This has been available on Mozilla and IE as
a 'caller' property of function objects, and it seems Konqueror/Safari
now have it too. Opera doesn't. And what bothers me is that it is marked
as 'deprecated'.
There are caller[1] (of function), caller[2] (of current instance) and
__caller__ (Netscape proprietary for caller[2]

caller[2] and __caller__ are potentially dangerous as opening a way to
get into execution stack within default security. This way they were
either patched for functionality decrease or removed. caller[1] is
secure but just went under the same security campaign by mistake.

Following is a Brendan Eich comment on Mozilla 0.9 (2001-01-10):

"All traces of a caller property were removed a while ago,
to follow ECMA-262 and to avoid any chance of a security exploit.
The removal seems to me to have been overzealous, because it axed
the caller property of function objects *and* the
much-more-exploitable caller (or __caller__) property of
activation objects.

"Confirming, we should consider restoring the caller property
of function objects for old time's sake (JScript imitated it
faithfully in cloning JS1.1, where it originated)."

See also in depth discussion on the topic at
"Recursive functions and arguments.callee.caller"
http://groups.google.com/group/comp....fd9c1a17c21ca5
Jan 19 '08 #3
You may find the following thread on caller, callee interesting:

http://groups.google.com/group/comp....d9c1a17c21ca5/

Also, I logged a bug report at:
https://bugzilla.mozilla.org/show_bug.cgi?id=332104

Csaba Gabor from Vienna

On Jan 18, 8:15 pm, António Marques <m...@sapo.ptwrote:
Hi,

Sorry if this's been discussed before, I couldn't find it.
As well you know, the ECMAScript standard doesn't include any way to
access a function's caller. This has been available on Mozilla and IE as
a 'caller' property of function objects, and it seems Konqueror/Safari
now have it too. Opera doesn't. And what bothers me is that it is marked
as 'deprecated'.

I've seen people I respect swear by their lives that it is *good* to
have it deprecated. 'Because there are better ways of doing what you
want'. I can't understand this. They keep repeating that even after one
says that what one wants is *precisely* to get a reference to the
caller. I can perfectly well understand that power can be mishandled,
but that is no reason to take power away when there is no other
alternative. If the fear of having javascript's features misused could
be invoked to remove features, one would end up pretty fast with no
javascript at all. Almost anything can be misused, and I see better
candidates for exclusion.

Admittedly the mechanism could be improved - beginning with having a
special variable which would refer to the current function itself and
from which all context information could be derived, and if a special
variable doesn't sound good, then by all means a member of the Function
object - something like Function.current, or Function.getCurrent() -
would be welcome. But what is not welcome at all is the menace of
removal of a basic feature of the language with no alternative at all.
Sorry, but just to say that 'caller isn't needed' is the same as calling
the other person stupid. Of course there might be some uses of 'caller'
which could be solved in a different, better way. Not all of them,
though, and what is gained by removing it other than ego-rubbing?
I should point out that 'goto' (as if it were a comparable case!) has
alternatives. There is nothing you can do with it that you can't do
without. Not so here.

Could anyone explain this to me?
Cheers,
Antonio
Jan 19 '08 #4
On Fri, 18 Jan 2008 at 19:15:40, in comp.lang.javascript, António
Marques wrote:
>Hi,

Sorry if this's been discussed before, I couldn't find it.
As well you know, the ECMAScript standard doesn't include any way to
access a function's caller. This has been available on Mozilla and IE as
a 'caller' property of function objects, and it seems Konqueror/Safari
now have it too. Opera doesn't. And what bothers me is that it is marked
as 'deprecated'.
<snip>

This problem appeared in the early days of computing. Sometimes the code
in a function needs to know something. The solution was ingenious. The
caller supplies 'arguments' that tell the function what it needs to
know. Clever, eh?

John
--
John Harris
Jan 19 '08 #5
John G Harris wrote:
>Sorry if this's been discussed before, I couldn't find it. As well
you know, the ECMAScript standard doesn't include any way to access
a function's caller. This has been available on Mozilla and IE as
a 'caller' property of function objects, and it seems
Konqueror/Safari now have it too. Opera doesn't. And what bothers
me is that it is marked as 'deprecated'.
<snip>

This problem appeared in the early days of computing. Sometimes the
code in a function needs to know something. The solution was
ingenious. The caller supplies 'arguments' that tell the function
what it needs to know. Clever, eh?
My fault, I apologise. I forgot to ask for intelligent opinions only.

--
Posted via a free Usenet account from http://www.teranews.com

Jan 22 '08 #6
Csaba Gabor wrote:
You may find the following thread on caller, callee interesting:

http://groups.google.com/group/comp....d9c1a17c21ca5/

Also, I logged a bug report at:
https://bugzilla.mozilla.org/show_bug.cgi?id=332104
Well, they do say ->
The good news is that ECMA TG1 is busy working on Edition 4, and part
of that (still not a done deal) is stack reflection.
-which is quite interesting. Does anyone have any more info on that?

Thanks,
Antonio

--
Posted via a free Usenet account from http://www.teranews.com

Jan 22 '08 #7
VK wrote:
>As well you know, the ECMAScript standard doesn't include any way
to access a function's caller. This has been available on Mozilla
and IE as a 'caller' property of function objects, and it seems
Konqueror/Safari now have it too. Opera doesn't. And what bothers
me is that it is marked as 'deprecated'.

There are caller[1] (of function), caller[2] (of current instance)
and __caller__ (Netscape proprietary for caller[2]

caller[2] and __caller__ are potentially dangerous as opening a way
to get into execution stack within default security. This way they
were either patched for functionality decrease or removed.
Even if I was refering to caller[1] (''caller' property of function
objects'), I'd be interested in knowing what was so dangerous about
granting access to the activation object in itself anyway that the whole
object had to be locked out.
caller[1] is secure but just went under the same security campaign by
mistake.

Following is a Brendan Eich comment on Mozilla 0.9 (2001-01-10):

"All traces of a caller property were removed a while ago, to follow
ECMA-262 and to avoid any chance of a security exploit. The removal
seems to me to have been overzealous, because it axed the caller
property of function objects *and* the much-more-exploitable caller
(or __caller__) property of activation objects.

"Confirming, we should consider restoring the caller property of
function objects for old time's sake (JScript imitated it faithfully
in cloning JS1.1, where it originated)."
I did endure Netscape 4.72 as my browser since it appeared until Mozilla
reached 1.2 - I think this may have been fixed by then, I don't recall
having had any issues. Certainly Gecko 1.8 has a Function.prototype.caller.
See also in depth discussion on the topic at "Recursive functions and
arguments.callee.caller"
http://groups.google.com/group/comp....wse_frm/thread...
Hey, thanks.

--
Posted via a free Usenet account from http://www.teranews.com

Jan 22 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Thomas Mlynarczyk | last post by:
Hi, I stumbled over a strange behaviour of Mozilla. When I want to access the caller property of a function that was not called from within another function, Mozilla seems to abort the script....
7
by: George Marshall | last post by:
Hi all, my question is what should I do with a pointer to be used inside a function ? The following function should take a pointer to a null terminated array of chars, do something with it, and...
8
by: Ravindranath Gummadidala | last post by:
Hi All: I am trying to understand the C function call mechanism. Please bear with me as I state what I know: "every invocation of a function causes a frame for that function to be pushed on...
4
by: anonymous | last post by:
Thanks your reply. The article I read is from www.hakin9.org/en/attachments/stackoverflow_en.pdf. And you're right. I don't know it very clearly. And that's why I want to understand it; for it's...
16
by: didier.doussaud | last post by:
I have a stange side effect in my project : in my project I need to write "gobal" to use global symbol : .... import math .... def f() : global math # necessary ?????? else next line...
13
by: mitchellpal | last post by:
i am really having a hard time trying to differentiate the two..........i mean.....anyone got a better idea how each occurs?
3
by: Beta What | last post by:
Hello, I have a question about casting a function pointer. Say I want to make a generic module (say some ADT implementation) that requires a function pointer from the 'actual/other modules'...
3
by: william | last post by:
My situation is here: an array of two dimension can only be defined locally within a function(because the caller don't know the exact size ). Then the question is: how should the caller access...
4
by: barcaroller | last post by:
I am trying to adopt a model for calling functions and checking their return values. I'm following Scott Meyer's recommendation of not over-using exceptions because of their potential overhead. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.