In trying to bring Tcl up to date with PDD20 and avoid the
deprecation of newsub, that led me to having to implement TclLexPad
(which would correspond to the new LexPad base type. The PDD says
this happens automatically, but:
Leo pointed out that while Tcl is using the '.HLL' directive, ...
nothing was actually being autoboxed to the various Tcl types, as tcl
has not been registering each type we care about.
I saw that Roger had implemented this for Amber, so I borrowed his
implementation, and added it as new syntax to the PMC declarations.
'pmclass' now takes two additional flags:
"hll HLL"
The High level language this PMC corresponds to.
"maps Type"
The basic parrot PMC type that this PMC correspond to
for
".HLL" usage. For example:
pmcclass TclInt hll Tcl maps Integer
allows this PMC to automatically be used when
autoboxing "I"
registers to PMCs.
Requires the "hll" flag.
This makes the generated .c file contain the appropriate code
for .HLL registration.
So, for TclString, we now define our pmc as:
pmclass TclString extends TclObject extends String dynpmc group
tcl_group hll Tcl maps String { ... }
and now this code:
.HLL 'Tcl', 'tcl_group'
.sub ''
$P1 = test()
$S1 = typeof $P1
print $S1
print_newline
.end
.sub test
.return ("coke")
.end
prints "TclString" instead of "String". (presuming you've built Tcl,
of course)
(Roger: you should steal this syntax for your Amber PMCs. =-)