develooper Front page | perl.perl6.language | Postings from March 2005

How could import constants from other modules?

Thread Next
From:
song10
Date:
March 18, 2005 01:13
Subject:
How could import constants from other modules?
Message ID:
20050318073838.2034.qmail@web17102.mail.tpe.yahoo.com
hi, all

is there any way to import constants from other modules without
specifying scope everytime?
such like this:

module A;
use constant { PI => 3.14, VER => 1.1 }
...

####

module B;
my $var = A::PI; # this way is fine when A is 'short' or rare

#### imagination

module C;
use constant tag { PI => 3.14, VER => 1.1 }
...

####

module D;
use constant C::tag;
my $var = PI; # forgive my laziness

is it a good idea to have header files and include pragma?
(sometimes, a big module file is also a headache. having this
feature, we could split it up.)

song10


_______________________________________________________________________
Yahoo!奇摩電子信箱
免費容量250MB,信件在多也不怕
http://tw.promo.yahoo.com/mail_new/index.html

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About