Issue #13770 has been updated by duerst (Martin Drst).


matz (Yukihiro Matsumoto) wrote:
> And maybe it's time to relax the limitation for Non-ASCII capital letters to start constant names.

I agree. Here are some pointers for implementation:

The distinction between constants (`tCONSTANT`) and identifiers (`tIDENTIFIER`) is made at `parse.c:7830` using macro `ISUPPER`. Some other uses of `ISUPPER` (but not all of them) seem to be related to this distinction, e.g. the one at `symbol.c:281`.

`ISUPPER` is defined using `rb_isupper` in `include/ruby/ruby.h`, the later being defined inline in the same file, as `'A' <= c && c <= 'Z'`. This would have to be replaced with a call to `ONIGENC_IS_CODE_CTYPE` or so, which would work for legacy encodings. For Unicode-based encodings, where we want to into account titlecase (thanks, Shyouhei!), it may be slightly more complicated.

A question we might want to check for is if there's any code out there that currently uses non-ASCII upper-case variable names.

Another question is whether we might want to have some convention for Japanese, e.g. Katakana for class names. Just thinking out loud (and ducking).


----------------------------------------
Bug #13770: Can't create valid Cyrillic-named class/module
https://bugs.ruby-lang.org/issues/13770#change-65970

* Author: sb (Sergey Borodanov)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
Can't create a valid Cyrillic-named class. If I have a file **技我把.rb**:

~~~ ruby
# Content of 技我把.rb:

class 妙我把

  def 扭把我志快找扼找志抉志忘找抆
    "妤把我志快找, 妙我把!"
  end

end
~~~

and do in **bash**:

~~~
ruby 技我把.rb
~~~

I get the error (**SyntaxError**):

~~~
技我把.rb:1: class/module name must be CONSTANT
~~~

Same error with module creating and same behavior in **irb** (please, see attachment). At the same time Cyrillic-named constants and methods work fine.

It is expected that creating Cyrillic-named class/modules should work without error.

---Files--------------------------------
Screenshot from 2017-07-26 19-08-14.png (64.2 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>