----- Original Message -----
From: "Steve Fink" <[EMAIL PROTECTED]>
To: "K Stol" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Monday, March 10, 2003 12:32 AM
Subject: Re: Lua -> ParrotVM, question on PMCs


> [Arg. My outgoing mail  was messed up last week when I sent out a whole
> bunch of emails just before leaving for Hawaii, so this message was
> very delayed.]
>
> On Feb-24, K Stol wrote:
> > Hello,
> >
> > As Lua is a typeless language, variables can take values of any
> > type. This has to be checked during runtime, obviously. My guess is
> > that variables should be implemented on parrot as PMC's. I have
> > tried to read as much as possible on PMC's, but it's still a bit
> > unclear.
>
> > What I have understood is that PMC's are like C unions, but all
> > fields are accessible (or something like that).
>
> Not really. PMCs are really anything other than an int, a float, or a
> string. They all implement a common set of operations in a way that
> makes sense for the datatype they represent -- so the add operation
> for a complex number PMC, for example, would add the real and
> imaginary parts together.
>
I studied some pasm examples more closely, and also I got some more
understanding
of all this. Now I think it's something like this:

PMCs are used to implement typeless languages (most obvious example is, of
course, Perl6)
So whenever a PerlInt is created to store some integer value, and this PMC
is used in some string
or something, this PerlInt PMC has some way (=method) to convert the Integer
to a String.

Also, when a string is assigned to a PerlInt, this PerlInt becomes a
PerlString (right?)
So for some typeless language L that has for example 3 datatypes (int,
float, string) ,
L's datatypes could be implemented as these PMCs: LInt, LFloat, LString (for
example).
All coercion rules can be programmed into the PMC, for example, the rule how
to convert
the integer to a string, can be programmed literally into the
int_to_string() method of the LInt PMC.

Is it true, that typeless languages only use PMC for their data, or could an
integer in perl6 also be
stuffed in an integer register?

Am I right about this stuff, or have I misunderstood something?

Klaas-Jan

> > Are there any good tutorials on PMC's somewhere? I looked in the
> > mailing lists, but I couldn't find much there.
>
> The most relevant documentation for PMCs is in docs/vtables.pod.
> Knowing to look there requires you to know what a PMC is and even
> something about how it's implemented, which isn't very nice. We really
> ought to have a pointer to it somewhere.
>
> You will want to implement variables and values with PMCs, but the
> names of the variables will be elsewhere, in a symbol table. The best
> pointer I can give you for that right now is the "Symbol table ops"
> section of docs/core_ops.pod. Although it's possible that you can
> manage your own compile-time symbol table and never need to look up
> names at runtime; I'm guessing Lua is too dynamic for that, but I
> don't know.
>

Reply via email to