develooper Front page | perl.perl6.internals | Postings from February 2001

Re: PDD 2, vtables

Thread Previous | Thread Next
From:
Simon Cozens
Date:
February 6, 2001 04:53
Subject:
Re: PDD 2, vtables
Message ID:
20010206125258.A17876@pembro26.pmb.ox.ac.uk
On Tue, Feb 06, 2001 at 11:26:57AM +0000, Tim Bunce wrote:
> > =item UTF-32 string
> > =item Native string
> > =item Foreign string
> 
> I'm a little surprised not to see UTF-8 there, but since I'm also
> confused about what Native string and Foreign string are I'll skip it.

"Native string encoding" is an abstraction that allows us to say "some
encoding that Perl knows how to deal with, but you don't need to care about".
The idea, if I understand it correctly, is that strings can be treated as
arrays of numbers, and you don't need to know how they're *really* stored.
They might be stored as UTF8 internally; I hope so.

"Foreign string" is the same, but with the implication that some external code
will be needed to tell Perl how it should convert between an array of numbers
and this encoding.

> Using the word 'variable' here probably isn't a good idea.
> Maybe "Destroys the contents of the PMC leaving it undef."

Agreed.

> > =item logical_or
> > =item logical_and
> > =item logical_not
> 
> Er, why not just use get_bool?

Overloading.

> > =item repeat (x)
> > 
> >    void		repeat(PMC1, PMC2, PMC3[, key]); ##
> > 
> > Performs the following sequence of operations: finds the string value
> > from C<PMC2>; finds an integer value I<n> from C<PMC3>; replicates the
> > string I<n> times; stores the resulting string in C<PMC1>.
> 
> So call it replicate?

Well, the Perl-space operator is called "repeat", and the Perl 5 operator
is OP_REPEAT, so...

> Before that I think a section on containers need to be added.

This is basically what the whole "key" thing is about. I'm not sure that
*that* much more needs to be described, (well, something needs to be
described, but not in great detail) other than the fact that operating on a
container PMC-key pair is equivalent to operating on a scalar PMC.

Hence, I can say:
    (on a hash)   get_number(hash, "key")
    (on an array) get_number(array, elem)
    (on a scalar) get_number(scalar)
and not worry about what's going on underneath. 

There ought to be special functions for containers though, yeah.

-- 
"I find that anthropomorphism really doesn't help me with a place full 
of bugs." -- Megahal (trained on asr), 1998-11-06

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About