[27790] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 9154 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 14 00:05:49 2006

Date: Thu, 13 Apr 2006 21:05:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 13 Apr 2006     Volume: 10 Number: 9154

Today's topics:
    Re: tr/// broken? <nospam-abuse@ilyaz.org>
    Re: XS progamming question <nospam-abuse@ilyaz.org>
    Re: XS progamming question <nospam-abuse@ilyaz.org>
    Re: XS progamming question <nospam-abuse@ilyaz.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 14 Apr 2006 02:48:06 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: tr/// broken?
Message-Id: <e1n2h6$20h7$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Dr.Ruud
<rvtol+news@isolution.nl>], who wrote in article <e1lpgl.1fk.1@news.isolution.nl>:
> In a Perl context, 'utf8' is commonly read as the proper subset of
> 'UTF-8' currently used by Perl.

utf8 is a proper SUPERSET of UTF-8.  The former is not restricted to
any particular range of non-negative integers; the current
implementation goes 0..0xFFFFFFFFFFFFFFFF (i.e., maximal range of
native unsigned integers currently used in Perl), and there are "free"
bits to extend it to, e.g., 128bit - if Perl is used on architecture
with sizeof(UV) = 128bits.

UTF-8 is "legally" restricted to 0..0x1FFFFF, although technically, it
can cover up to, IIRC, 0..0x1FFFFFFF.

Hope this helps,
Ilya


------------------------------

Date: Fri, 14 Apr 2006 02:38:28 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: XS progamming question
Message-Id: <e1n1v4$20bt$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Ferry Bolhar
<bol@adv.magwien.gv.at>], who wrote in article <1144917943.448921@proxy.dienste.wien.at>:
> But what happens with this code:

Here is what the compiler translates it too:

> mysub();

This is a shortcut for

  *mysub{CODE}->();

*mysub is calculated at compile time, the rest is postponed to
execution time (i.e., opcodes to calculate {CODE} and ->() are placed
into the compiled tree).

> sub mysub {
>  print "This is mysub!");
> }

This is more or less equivalent to

  BEGIN {
    *mysub = sub {print "This is mysub!");}
  }

In other words, *mysub{CODE} is populated by the subroutine reference.

> mysub();

Same as above.

Now compilation ended, and the compile tree contains code for

  *mysub{CODE}->();
  *mysub{CODE}->();

The code in the tree is executed.  At the moment of execution the CODE
slot is defined, so you get no errors.

> BTW: is there a difference when saying
> 
> package foo;
> 
> $var = 1;
> sub bar {...};
> 
> vs.
> 
> $foo::var = 1;
> sub foo::bar {...};

Yes.  The "content of sub" is compiled in a different package.  The
second code is equivalent to

    package foo;

    $var = 1;
    sub bar {
      package main;
      ...
    };


> IIUC 'package' is just a compiler directive (like 'use', 'my' and 'our'),
> never appearing in an OP tree?

There is a notion of "current package" during execution (relevant to,
at least, eval"" and caller() [what else?]).  So it IS stored in the
compile tree.

Hope this helps,
Ilya


------------------------------

Date: Fri, 14 Apr 2006 02:40:50 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: XS progamming question
Message-Id: <e1n23i$20c3$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Ferry Bolhar
<bol@adv.magwien.gv.at>], who wrote in article <1144918383.68376@proxy.dienste.wien.at>:

> How subs are compiled? I guess the OP tree is generated, a CV is
> made whose START/ROOT entries will point to the first sub OP,
> and a stash entry is made (unless for anonymous sub's)?

I can find no contradiction to your description.

> > E.g., if a module contains only subroutines, "package" declarations,
> > and "1;" at the end, the only thing which is executed is this "1;".

> Unless it was included with 'use' and has an "import()" sub, right?

No.  import() is executed by the "caller"/"use()r".

Hope this helps,
Ilya


------------------------------

Date: Fri, 14 Apr 2006 03:18:40 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: XS progamming question
Message-Id: <e1n4ag$212j$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to

<robic0>], who wrote in article <7j3u32pr72bm0tpb6t54c1aha2q0jakf2g@4ax.com>:
> >  *mysub{CODE}->();

> Is this '*' used here a 'glob'?

Yes.

> Can you explain in detail just what a glob is?

You do not want to know.  Just avoid them at any cost; they are just
remnants of object-less Perl4.

Hope this helps,
Ilya


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 9154
***************************************


home help back first fref pref prev next nref lref last post