On 1/25/06, Jonathan Lang <[EMAIL PROTECTED]> wrote:
> Larry Wall wrote:
> > But my hunch is that it's
> > a deep tagmemic/metaphorical problem we're trying to solve here.
> > Such issues arise whenever you start making statements of the form
> > "I want to use an A as if it were a B." The problem is much bigger
> > than just how do I translate Perl 5 to Perl 6. It's questions like:
> >
> > What makes a particular metaphor work?
> > Will the cultural context support use of an A as if it were a B?
> > How do we translate the user's thoughts to the computer's thoughts?
> > How do we translate one user's thoughts to another user's thoughts?
> > How do we know when such a translation is "good enough"?
> > How do we know when our mental model of an object is adequate?
> > How do we know when the computer's mental model of an object is
> > adequate?
> > What does adequate mean in context?
> > Will the culture support partially instantiated objects? :-)
> >
> > That's tagmemics, folks. The main problem with tagmemics is that, while
> > it helps you ask good questions, it doesn't give you easy answers for 'em...
>
> Let me take a (feeble) crack at this:
>
> It sounds like we're talking about something vaguely akin to C++'s
> typecasting, where you treat an object of a given class as if it were
> an object of a different class.
Actually this might not be a bad approach in this case. Take this for instance:
method foo (Foo $self, $key) {
((Hash) $self){$key}
}
The syntax is ugly, but it makes what you are doing more explicit. I
would also think that in most cases this could be compile time checked
(if we can check $self's type (Foo), we can make sure Foo does/isa
Hash).
Here are some other ideas for a typecasting syntax using "as" for the
keyword (which IIRC is taken for coercion??):
$self as Hash {
# $self is treated as a Hash inside the block
$self{$key} = $value;
}
# it could also return a wrapped
# $self for use in wider scopes
my $h = $self as Hash;
$h{$key} = $value;
Anyway, it's just a early morning (not enough coffee in my system) thought.
Stevan