From: "Matt Diephouse" <[EMAIL PROTECTED]>
   Date: Sat, 5 Aug 2006 01:22:49 -0400

   Bob Rogers <[EMAIL PROTECTED]> wrote:
   >
   > This tweak may break other stuff (I didn't check), so take it with a
   > grain of salt.  However, this may be a hint that you are better off
   > using PMCs as values rather than as containers.  HTH,

   Right. So what you did was change Tcl so that we no longer use the
   assign opcode. This fixes this error, but causes a handful of other
   ones.

I'm not surprised.

   AFAICT, we have to use assign so that we don't break aliasing (which
   is rather important). If you have the same variable in two different
   scopes -- or under two different names -- merely replacing one of
   those variables with a new PMC (using PMCs as values) won't change the
   other variable. You have to use assign to morph the PMC into the new
   type. Among other things, this will break Tcl's [global] and
   [variable] commands and it isn't really a viable solution.
   PMCs *are* containers; they're designed that way.

Not necessarily . . .

   This leaves two options:

       1) Fixing the set_pmc vtable method for TclList and/or
   ResizablePMCArray and FixedPMCArray
       2) Using a hybrid list/string PMC that behaves in a similar way to
   Perl 5's scalars

   Option 1 is preferable, IMO, if it's doable. But it's a little out of
   my reach as far as C goes, unfortunately. Otherwise I'd have fixed it
   already. :-)

FWIW, the Common Lisp system I'm writing takes a third tack.  It defines
a ParrotObject container associated with the name that refers indirectly
to the current value.  Of course, Common Lisp "symbol" objects are part
of the language spec (and aliasing is not), so I have to at least make
it look like I'm doing it this way.  But indirection still seems more
natural than morphing -- I don't have to worry about whether morphing
will produce unintended side-effects.  And the best thing is that I can
do it all in PIR and Lisp.

   So when I said "using PMCs as values rather than as containers," I
really meant to suggest separating the container from the value.  But I
have no clue whether this would be easier than the other options.

   Thanks for taking a look at this.

No problem; thanks for giving me an excuse to take a look at how Tcl
works.

                                        -- Bob

Reply via email to