Dan Sugalski:
# At 10:26 AM -0800 2/26/02, Brent Dax wrote:
# >That'll just give us an explosion of wrapper types.
#
# Not wrapper types, no. But 'different' types, yes.
#
# Extenders will probably see things like:
#
#     typedef void PMC;
#
# or
#
#     typedef char PMC;
#
# rather than the actual struct.

Why not do a forward declaration of a PMC struct?

pmc.h:
        struct pmc;
        typedef struct pmc PMC;

        #ifdef PARROT_IN_CORE
        struct pmc {
                ...
        };
        #endif

BTW, that's Parrot_PMC, right?  Remember my statement about reserving
everything beginning with 'P'...

# >Like it or not,
# >embedders (and extenders--don't forget about them) will need
# to do some
# >simple operations on PMCs and strings.  We need to accommodate that.
#
# Right, but that's what the wrapper library is for. We will have a lot
# of simple functions that have just a line or two of real code behind
# them. That's OK--it's the only way to guarantee backwards
# compatibility in the future.

How do we decide what's worth wrapping?  Let's take the string library,
for example.  string_make is an obvious shoe-in.  Probably string_concat
and string_substr too.  What about string_ord?  string_transcode?  Where
do you draw the line?

I know you think that we just need get/set on PMCs, but I think we also
need simple operations--[+-*/%_x].  Method calls and indexing are
probably necessary too.  I think we can have just a few functions while
still being very useful:

        PMC* pmc_new(interpreter, type)

        Parrot_Int pmc_get_int(interpreter, pmc);
        void pmc_set_int(interpreter, pmc, int);

        Parrot_Float pmc_get_float(interpreter, pmc);
        void pmc_set_float(interpreter, pmc, float);

        Parrot_String pmc_get_string(interpreter, pmc);
        void pmc_set_string(interpreter, pmc, string);

        PMC* pmc_unop(interpreter, char unop, pmc);
        /* used like dest=pmc_unop(interpreter, '-', src) */

        PMC* pmc_binop(interpreter, pmc, char binop, pmc);
        /* used like dest=pmc_binop(interpreter, lhs, '*', rhs) */

        PMC* pmc_method(interpreter, pmc, methodname);
        /* should methodname be STRING* or char*?  Hmm... */

        PMC* pmc_get_indexed(interpreter, pmc, key);
        void pmc_set_indexed(interpreter, pmc, key, pmc);

        KEY* key_make_int(interpreter, int);
        KEY* key_make_float(interpreter, float);
        KEY* key_make_string(interpreter, string);
        KEY* key_make_pmc(interpreter, pmc);

(Those are without the Parrot_ prefix.)

--Brent Dax
[EMAIL PROTECTED]
Parrot Configure pumpking, regex hacker, embedding coder, and boy genius

#define private public
    --Spotted in a C++ program just before a #include

Reply via email to