A few months ago, I put together a cargo cult version of basic PMC types for
Tcl based on their Perl counterparts. I ripped out all reference to PerlUndef,
and made sure the shimmering (automatic conversion of datatypes) was working between the various types.
After posting this to the list, I was told that this was good, but these PMCs
needed to be dynamic. That is, rather than being types that are shipped with
the basic parrot core, they should be available as a dynamically loadable
library. Makes sense. (Note: This also means that Perl's PMCs should also
be moved to a dynamic library, especially now that parrot has its own,
non-Perl base types.).
Things sat for a bit after that. Thanks to Mattia Barbon who provided a way to group related pmcs together into a single library to load (Before this, interrelated
pmcs were uncompilable, as each depended on another that hadn't been compiled yet.). Also thanks to Steve Fink, who got that working under OS X, which
is my primary development environment.
Now, if you
cd dynclasses && makeyou get
runtime/parrot/dynext/tclgroup.so
(or something like it.) (If you don't, there's a bug, and please report it
to the perl6 internals list. )
foo.imc
containing:
.sub main loadlib $P0, "tclgroup" # Load combined tcl lib $I0 = find_type "TclInt" # Find ID for a TclInt * $P0 = new $I0 # Instantiate $P0 = "asdf" # Assign print $P0 print "\n" $S0 = typeof $P0 # Get the type description. print $S0 print "\n" end .endThis snippet prints out
asdf TclStringNote that the type of the PMC has shimmered (morphed, if you prefer) to the appropriate data type. I need to do more work to nail down the appropriate reactions for each kind of shimmer for Tcl.
puts '[string range [list 1 2 3] 0 2]'Actually generates
'1 2'which will have been shimmered from a TclList (returned by [list]) to a TclString
String
, which you can, thanks to runtime/parrot/include/pmctypes.pasm
, just create with $P0 = new String
)