Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SpiderMonkey: working with aliases

5 views
Skip to first unread message

Antonidze

unread,
Feb 28, 2006, 12:43:11 AM2/28/06
to dev-tech-...@lists.mozilla.org

I would like to declare alias name for object's property. API function
JS_AliasProperty is declared as deprecated - which function should i use
instead? If using JS_AliasProperty how can i delete early created alias?

Thanks
--
View this message in context: http://www.nabble.com/SpiderMonkey%3A-working-with-aliases-t1197446.html#a3158517
Sent from the Mozilla - JavaScript Engine forum at Nabble.com.

Brendan Eich

unread,
Feb 28, 2006, 2:10:16 AM2/28/06
to Antonidze
Antonidze wrote:
> I would like to declare alias name for object's property. API function
> JS_AliasProperty is declared as deprecated - which function should i use
> instead? If using JS_AliasProperty how can i delete early created alias?

Can you define "alias"? ECMA-262 Edition 3 does not, except arguably
when talking about the arguments object and the formal parameters that
can be set using arguments[0] for formal parameter a in function f(a) {
arguments[0] = 42; return a }, e.g.

Anyway, the API is not going to change, so you can use the deprecated
entry points. But I'm curious to learn more about your use-case.

/be

Antonidze

unread,
Feb 28, 2006, 5:50:36 AM2/28/06
to dev-tech-...@lists.mozilla.org

I treat "alias-to-an-object" as "reference-to-this-object", so performing any
action on alias is the same to performing this action on object itself (and
vice versa). It's very like E262-3's "joined objects" - and is exactly what
is written on JS_AliasProperty description. The problem is - I cannot found
a way to delete alias (created with JS_AliasProperty) without deletion of
aliased object.
--
View this message in context: http://www.nabble.com/SpiderMonkey%3A-working-with-aliases-t1197446.html#a3161513

Brendan Eich

unread,
Feb 28, 2006, 1:47:15 PM2/28/06
to Antonidze, dev-tech-...@lists.mozilla.org
Antonidze wrote:
> I treat "alias-to-an-object" as "reference-to-this-object", so performing any
> action on alias is the same to performing this action on object itself (and
> vice versa). It's very like E262-3's "joined objects" -

It sounds more like plain old reference types (Java or JS), where the
properties that alias the reference could be permanent and readonly. In
that case, you cannot distinguish whether the value storage *that
contains the reference* to the object (which is stored elsewhere) is
shared for the two properties, or is duplicated (but each value slot is
immutable, both always refer to the same object).

So you don't need aliases to take advantage of object's status as a
"reference type". You just need readonly and permanent attributes.

> and is exactly what
> is written on JS_AliasProperty description.

No, joined function objects are something else again.

> The problem is - I cannot found
> a way to delete alias (created with JS_AliasProperty) without deletion of
> aliased object.

You can't delete an object -- objects are garbage collected, delete is a
property removal operator. Again, the property's value is a *reference*
to the object, not the object itself.

/be

Brendan Eich

unread,
Feb 28, 2006, 1:47:15 PM2/28/06
to Antonidze, dev-tech-...@lists.mozilla.org
Antonidze wrote:
> I treat "alias-to-an-object" as "reference-to-this-object", so performing any
> action on alias is the same to performing this action on object itself (and
> vice versa). It's very like E262-3's "joined objects" -

It sounds more like plain old reference types (Java or JS), where the

properties that alias the reference could be permanent and readonly. In
that case, you cannot distinguish whether the value storage *that
contains the reference* to the object (which is stored elsewhere) is
shared for the two properties, or is duplicated (but each value slot is
immutable, both always refer to the same object).

So you don't need aliases to take advantage of object's status as a
"reference type". You just need readonly and permanent attributes.

> and is exactly what


> is written on JS_AliasProperty description.

No, joined function objects are something else again.

> The problem is - I cannot found


> a way to delete alias (created with JS_AliasProperty) without deletion of
> aliased object.

You can't delete an object -- objects are garbage collected, delete is a

Message has been deleted

Antonidze

unread,
Mar 1, 2006, 1:00:14 AM3/1/06
to dev-tech-...@lists.mozilla.org

Brendan, thanks a lot for your help!
--
View this message in context: http://www.nabble.com/SpiderMonkey%3A-working-with-aliases-t1197446.html#a3178083
0 new messages