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

A Python example first:

$ python
 >>> import sys
 >>> print sys.maxint
2147483647
 >>> help(sys)
...

I'd like to have a similar[1] capability inside Parrot. The general plan 
was already discussed, when "make install" came up first.

1) We have F<runtime/parrot/include/config.fpmc>, which is a frozen 
image of the config hash generated by F<config_lib.pasm>. Creating the 
frozen image needs already parrot (a possibly already existing parrot or 
miniparrot in the long run). But locating this file needs the library or 
include path, with resides in this file. We got a typical hen and egg 
problem.

2) instead of creating e.g. src/revision.c (and possibly other similar 
files), we create a C-readable representation of the frozen config hash 
and re-link with that file: src/parrot_config.c. Now we have parrot$EXE 
with the config inside.

3) "make install" creates src/parrot_config_install.c and links that 
into parrot_install$EXE, which during installation becomes 
.../bin/parrot$EXE. With this step we get rid of the problem with 
runtime vs build directory library usage.

4) at program start the frozen config string gets thawed and we populate 
appropriate namespaces[2] with hash entries. Language folks and our 
fearless leader may please define the term appropriate :)

5) along with bringing the config online, some cleanup and renaming 
wouldn't harm e.g. "iv" vs "opcode_t", "intvalsize" vs "intsize" vs 
"opcode_t_size" ...

6) the config information could be available as attributes of the 
respective namespace:

   ns = getclass "ParrotInterpreter"
   PINTVAL_size = ns."INTVAL_size"       # getattribute shortcut

or with global namespace ops

   PINTVAL_size = find_global "ParrotInterpreter", "INTVAL_size"

Comments, improvements, takers welcome,
leo

[1] w/o Python quirks

 >>> sys.maxint = 2
 >>> sys.maxint
2


[2] a remark about namespaces

We currently have:

/                       (namespace root)
   __parrot_core     ... MMD multi subs
   Integer
   Float
   ....                  Parrot PMC class namespaces

The PMC class namespaces should probably reside under "__parrot_core" to 
get rid of the namespace pollution. Or alternatively, we prepend two 
underscores:

/
   __parrot_core
   __ParrotInterpreter   aka __sys
   __ParrotIO            aka __io

Reply via email to