in reply to Re: Re: my, my, my
in thread my, my, my

Doesn't Perl 5 allow Unicode in sub names, just as in any variable name?

Those are math symbols, not "letters", so it won't match \W and would not be legal in identifiers, as things stand now.

But I can certainly see the use for non-letter names of one character (similar to today's punctuation-mark names), as that will open up the math operators and other symbols.

Replies are listed 'Best First'.
Re: Re: Re: Re: my, my, my
by theorbtwo (Prior) on Nov 17, 2002 at 06:07 UTC

    There's already example code out there with σ as an operator-sub, in exgisis 1, IIRC, so that will almost certianly work. I suspect the rule will end up being different for op-subs.

    And I'm fairly certian that p5 allows arb. unicode var. names, but not subnames, but I don't quite recall... I'd test, but I'm not at home.


    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

      Unicode sub names are fine.

      But, I discovered something else: my doesn't work right. With strict, I get an error that "global $α requires explicit package name" on the line that declares it lexical!

      Without strict, it compiles, and the other code shows that it is indeed lexical.

      #use strict; use warnings; use utf8; my $α= 5; my $Φ= 4; sub Φ { return $Φ; } package XX; $main::Φ= 33.33333; package main; print Φ;
      —John

      Be sure to view as UTF-8 in your browser.

      Cross reference: Unicode source code problem in 5.6.1.

        Here's a twist. Under perl 5.8.0, compiled for cygwin, you program works fine if and only if use strict; is present.

        On the other hand, if use strict is commented out, I get this bizarre error:

        "my" variable $strict::VERSION can't be in a package at lib/strict.pm +line 93, near "$strict::VERSION " Compilation failed in require at lib/utf8_heavy.pl line 2. BEGIN failed--compilation aborted at lib/utf8_heavy.pl line 2. Compilation failed in require at lib/utf8.pm line 17.