develooper Front page | perl.perl6.language | Postings from August 2001

Source/Program metadata from within a program

Thread Next
From:
Bryan C . Warnock
Date:
August 30, 2001 21:48
Subject:
Source/Program metadata from within a program
Message ID:
01083100450300.01104@wakko.idiocity.nut
Many of Perl 5's global variables are becoming properties of various Perl 6 
entities - $. and $/ for input filehandles, for instance.

There is still a large subset of global information that describes the 
program itself - some of which has been called for removal (or at least 
burial within some module) - plus more information that we *could* access, 
because we would be carrying it around.

The former being runtime information like..
$] $0 $$ $< $> $( $) $^C $^D $^H $^M $^O $^S $^T $^V $^W $^X

Will this remain global?  Will we have an introspective module that we can 
use to access this information?

In either case, there is some more information that we may or may not have, 
that it would be nice to be able to have access to....  I will refrain from 
naming them, as noone ever likes how I name things....

Knowledge of the complete (relative) path to each component of a perl 
program, as it was loaded.  For example, within Foo.pm as 
/usr/lib/perl6/Foo_v1_by_whomever/Foo.pm (from the @INC lookup).  'perl 
../foo' as '../foo', regardless of what games I play with $0.  If we're 
going to have multiple versions of modules, I would like to be able to 
report specifically which one it really is.  If we could realpath() it, 
that'd be even better, but that's not for the builtins.  File scoped.
Most likely, you'll want access to the rest of the module's metadata, too.
(If you specified wildcards, for instance.)

Knowledge of whether a file was the perl program invoked, or if it were 
included from another file.  For example, running 'perl foo' would have a 
true value for the file 'foo', but a false value for Foo.pm, which it may 
'do', 'use', or 'require'.  File scoped.

Access to the source code.  We're going to be carrying it around, unless we 
strip it.  We might as well put it to good use within error messages and the 
like.  If an error points me to foo:356, I want my DIE handler to dump the 
code surrounding that.  Useful for when I'm on a server, far from the source 
code I didn't deploy with the compiled exectuables.  This would more or less 
be how a remote debug would have to work anyway.

Compilation time.  For each of my compilation units, I would like to know 
when it was compiled.  Compilation unit scoped. 

-- 
Bryan C. Warnock
bwarnock@capita.com

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