From: Tomas Matousek Date: 2010-04-13T10:10:53+09:00 Subject: [ruby-core:29488] Re: Invalid names --_000_4B342496A3EFEB48839E10BB4BF5964C5420E955TK5EX14MBXC131r_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Any thoughts? From: Tomas Matousek [mailto:Tomas.Matousek@microsoft.com] Sent: Friday, April 09, 2010 11:45 AM To: ruby-core@ruby-lang.org Subject: [ruby-core:29396] Invalid names I wonder what your opinions are on using invalid method names in define_met= hod. Ruby allows it today and some frameworks (e.g. shoulda) depend on it. On the other hand some frameworks depend on method names returned by method= s, instance_methods, etc. being correct method names. The pattern methods.e= ach { |m| eval("def #{m}(...) ...") } is used quite frequently. Methods that define other members - instance variables (instance_variable_s= et), class variables (class_variable_set), constants (const_set) - don't ac= cept invalid names. A NameError is raised. Shouldn't define_method also raise NameError if the argument is not a valid= method name and the code that depends on this behavior be fixed? Or, if co= nsidered useful, shouldn't arbitrary names be allowed for constants, instan= ce variables and class variables as well? Tomas --_000_4B342496A3EFEB48839E10BB4BF5964C5420E955TK5EX14MBXC131r_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Any thoughts?

 

From: Tomas Matousek [mailto:Tomas.Matousek@microsoft.com]
<= b>Sent: Friday, April 09, 2010 11:45 AM
To: ruby-core@ruby-la= ng.org
Subject: [ruby-core:29396] Invalid names
=

 

I wonder what your opinions are on using invalid method names in define= _method.

 

Ruby allows it today and some frameworks (e.g. shoulda) depend= on it.

On the other hand some framewor= ks depend on method names returned by methods, instance_methods, etc. being= correct method names. The pattern methods.each { |m| eval(“def #{m}(= …) …”) } is used quite frequently.

 

Methods that define= other members - instance variables (instance_variable_set), class variable= s (class_variable_set), constants (const_set) - don’t accept invalid = names. A NameError is raised.

Shouldn&#= 8217;t define_method also raise NameError if the argument is not a valid me= thod name and the code that depends on this behavior be fixed? Or, if consi= dered useful, shouldn’t arbitrary names be allowed for constants, ins= tance variables and class variables as well?

 

Tomas

= --_000_4B342496A3EFEB48839E10BB4BF5964C5420E955TK5EX14MBXC131r_--