[Prototype-core] Status of property 'name' within Class.create(d) functions

2008-06-08 Thread Franck PORCHER

Hello,

I have been trying for days o understand what I have missed.

I have narrowed down the problem to this, where I create a simple class 
'foo' that I extend to assign a private member 'name' set to 'FOO':

var foo = Class.create({});

Object.extend( foo, {  name : 'FOO' } );

Then :

alert(foo.name) 

surprisingly displays

klass 

(instead of FOO)

Samething if I explicitely force the value to 'FOO'

foo.name = 'FOO'

Is there someone in the position to tell me what is going on, and why 
foo's private member 'name' does not hold its value. This does not 
happen if I choose another name for the private member.

This has been most upsetting to me for days now, and I fail to 
understand what I am missing.

So thank you to anyone who would help me understand my mistake if this 
is not a bug.

Franck PORCHER


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype: Core group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Status of property 'name' within Class.create(d) functions

2008-06-08 Thread Jeff Watkins
Off the top of my head, I'd guess you're using FireFox. I know the JS  
engine in FireFox (SpiderMonkey) exposes the name of a function via  
the `name` property, however, I don't know whether that property is  
mutable.

My guess, from the behaviour of your code, is `name` is not a mutable  
property.

On 8 Jun, 2008, at 9:06 PM, Franck PORCHER wrote:


 Hello,

 I have been trying for days o understand what I have missed.

 I have narrowed down the problem to this, where I create a simple  
 class 'foo' that I extend to assign a private member 'name' set to  
 'FOO':
  var foo = Class.create({});
 Object.extend( foo, {  name : 'FOO' } );
 Then :
  alert(foo.name)
 surprisingly displays
  klass
 (instead of FOO)

 Samething if I explicitely force the value to 'FOO'
  foo.name = 'FOO'
 Is there someone in the position to tell me what is going on, and  
 why foo's private member 'name' does not hold its value. This does  
 not happen if I choose another name for the private member.

 This has been most upsetting to me for days now, and I fail to  
 understand what I am missing.

 So thank you to anyone who would help me understand my mistake if  
 this is not a bug.

 Franck PORCHER


 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype: Core group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Status of property 'name' within Class.create(d) functions

2008-06-08 Thread Franck PORCHER
Yes Jeff, I'm using Firefox (Linux  FreeBSD plat-forms).

And peering at the source code, one can see that Class.create() defines 
an explicit klass() function, hence the 'klass' display.

Apparently, this property in not mutable. Something of a pain :-[

I will be reviewing prtotype's Class.create to see if we cannot achieve 
the same result with an anonymous function, for which Firefox JS engine 
*does not* expose anything in the name slot (I already tested this).

Franck

Franck Porcher, Docteur ès Sciences (Paris VI), Informatique théorique

--
SMART Technologies Les solutions intelligentes
--
Société de Services et d'Ingénierie en Informatique
Solutions Open Source Linux  FreeBSD
1995-2008 : Premier fournisseur en Polynésie française

Tél:  (689) 711 911
Email:fporcher(at)smartech(dot)pf
Web:  www(dot)smartech(dot)pf
--
You can analyze the past but you have to design the future.



Jeff Watkins wrote:

 Off the top of my head, I'd guess you're using FireFox. I know the JS 
 engine in FireFox (SpiderMonkey) exposes the name of a function via 
 the `name` property, however, I don't know whether that property is 
 mutable.

 My guess, from the behaviour of your code, is `name` is not a mutable 
 property.

 On 8 Jun, 2008, at 9:06 PM, Franck PORCHER wrote:


 Hello,

 I have been trying for days o understand what I have missed.

 I have narrowed down the problem to this, where I create a simple 
 class 'foo' that I extend to assign a private member 'name' set to 'FOO':

var foo = Class.create({});

Object.extend( foo, {  name : 'FOO' } );

 Then :

alert(foo.name) 

 surprisingly displays

klass 

 (instead of FOO)

 Samething if I explicitely force the value to 'FOO'

foo.name = 'FOO'

 Is there someone in the position to tell me what is going on, and why 
 foo's private member 'name' does not hold its value. This does not 
 happen if I choose another name for the private member.

 This has been most upsetting to me for days now, and I fail to 
 understand what I am missing.

 So thank you to anyone who would help me understand my mistake if 
 this is not a bug.

 Franck PORCHER






 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype: Core group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Status of property 'name' within Class.create(d) functions

2008-06-08 Thread kangax

Yep, it's suppose to be read-only
http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Function:name

On Jun 9, 12:31 am, Jeff Watkins [EMAIL PROTECTED] wrote:
 Off the top of my head, I'd guess you're using FireFox. I know the JS  
 engine in FireFox (SpiderMonkey) exposes the name of a function via  
 the `name` property, however, I don't know whether that property is  
 mutable.

 My guess, from the behaviour of your code, is `name` is not a mutable  
 property.

 On 8 Jun, 2008, at 9:06 PM, Franck PORCHER wrote:



  Hello,

  I have been trying for days o understand what I have missed.

  I have narrowed down the problem to this, where I create a simple  
  class 'foo' that I extend to assign a private member 'name' set to  
  'FOO':
       var foo = Class.create({});
      Object.extend( foo, {  name : 'FOO' } );
  Then :
       alert(foo.name)
  surprisingly displays
       klass
  (instead of FOO)

  Samething if I explicitely force the value to 'FOO'
       foo.name = 'FOO'
  Is there someone in the position to tell me what is going on, and  
  why foo's private member 'name' does not hold its value. This does  
  not happen if I choose another name for the private member.

  This has been most upsetting to me for days now, and I fail to  
  understand what I am missing.

  So thank you to anyone who would help me understand my mistake if  
  this is not a bug.

  Franck PORCHER
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
Prototype: Core group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---