# New Ticket Created by  Autrijus Tang 
# Please include the string:  [perl #39792]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=39792 >


Currently :immediate in PIR serves two purposes: Running loadlib for  
type lookups, and for initializing
PMC constants that cannot be expressed in .const syntax.  Note that  
both are independent of environment.

I propose a new pragma, .loadlib, that implements the first need.

The .const syntax can be extended to express structured constants,  
perhaps in a restricted set of
semantics that allows only PMC initialization and give it explicit  
names, instead of the current
dubious use of a subroutine name as a constant PMC name.

The win here is that 3rd-party tools, as well as humans, can see hich  
libs a .pir is loading, and
which constants it's playing with, _without_ running Parrot  
instructions that can rm-rf the hard disk.

If this proposal is accepted, we can convert existing :immediate uses  
to use it.  We can then leave
:immediate alone with clear wording saying "deprecated, use .loadlib  
and .const -- if you think you
have a legitimate use to it, let us know, and we can un-deprecate  
it", instead of removing it outright.

The reason for deprecation is that unlike Perl 5, where BEGIN and  
INIT are often run in the same
process, Parrot has a much better design that makes .pbc platform- 
independent.  In that case, any
runtime-environment-dependent code in :immediate will be referring to  
the _COMPILING_
instance, not the _RUNNING_ instance, and the mistake of writing  
BEGIN when one should be
writing INIT (that is, :immediate instead of :init) is costly.

The drawbacks of the current :immediate implementation include:

- Nobody has a use of PIR :immediate for any unbounded (i.e.  
interacting-with-environment) evaluation
- As an intermediate language, the languages targeting it should  
handle BEGIN in that level, not PIR level
- It destroys the assumption of the same .pir compiling to the  
same .pasm
- There is no way to "merely assemble" .pir into .pbc without the  
potential of rm -rf.
- It makes writing a transformer/analyzer for full .pir impossible in  
other languages

Thanks,
Audrey

Attachment: PGP.sig
Description: PGP signature

Reply via email to