On Wed, Jul 12, 2006 at 01:55:39PM -0500, Patrick R. Michaud wrote:
> On Wed, Jul 12, 2006 at 11:36:56AM -0700, chromatic wrote:
> > On Wednesday 12 July 2006 11:27, Patrick R. Michaud wrote:
> > > The perl6 compiler has a custom string type, currently called
> > > "Perl6Str". What's the canonically correct mechanism for creating
> > > an object of that type?
> > >
> > > $P0 = new 'Perl6Str'
> > > $P0 = new .Perl6Str
> > > $P0 = new [ 'Perl6Str' ]
> >
> > I tend to use:
> >
> > .local int str_type
> > str_type = find_type [ 'Perl6Str' ]
> >
> > .local pmc p6str
> > p6str = new str_type
>
> Along similar lines...
>
> - If another HLL wants to create a Perl6Str, how does it do it?
> - If another HLL wants to create a subclass of Perl6Str...?
AFAIK there is no answer for this at present.
(1) POSSIBLE KLUDGE
In the very short term we could introduce a simple hack that would allow
the user to specify the root namespace for the creation of the new class,
defaulting to the HLL root:
.HLL "evillang"
.sub foo
$P0 = get_hll_namespace # ['evillang']
$P1 = newclass ['Perl6Str'], $P0 # Not a Perl 6 string, but an
incredible simulation
...
(2) ELEGANT DIRECTION FOR THE FUTURE
[to be determined]
Seriously: Allison's busy (as am I) with nailing namespaces to the wall, so
I wouldn't ask her to decide this. I do have ... not so much an idea, but
an approach, which I'll suggest when the time comes:
At present, newclass creates a class object and a namespace, both of which
have the same name. That must change once we stop depending on typed
namespaces. Assuming a single namespace object can represent a single class
in future -- which is good for class manipulation and introspection -- I
think we'd want to stop having 'newclass' futz with namespaces at all,
leaving it up to the user to give it a name ... if any. Yes, Virginia,
there are anonymous classes. :-)
So it might look like:
.HLL "evillang"
.sub foo
$P0 = newclass
...
set_hll_global ['Perl6Str'], $P0 # Not a Perl 6 string, but an
incredible simulation
...
--
Chip Salzenberg <[EMAIL PROTECTED]>