develooper Front page | perl.perl6.internals | Postings from March 2002

Re: Multimethod dispatch for parrot?

Thread Previous | Thread Next
From:
Shlomi Fish
Date:
March 7, 2002 20:54
Subject:
Re: Multimethod dispatch for parrot?
Message ID:
Pine.LNX.4.33L2.0203080642350.19701-100000@vipe.technion.ac.il

With the possibility of making this thread off-topic: isn't multi-method a
function that propogates according to the values of more than one
argument? Like:

sub myfunc
{
	my ($a, $b) = @_;

	if ($a->isa('Vector3') && $b->isa('Vector3'))
	{
		return Vector3::myfunc($a,$b);
	}
	elsif ($a->isa('Vector') && $b->isa('Vector'))
	{
		return Vector::myfunc($a,$b);
	}
	elsif ...
	.
	.
	.
}

The way I see it, it can also be implemented in user-land, but of course
if it's not parrotized then there will be some duplicate code around. Now,
there may be more complicated situation. Like a variable number of
parameters each one of them a class of a certain type ("grep { !
$class->isa('Vector'} } @_" or something of this vain. ), etc.

We probably should figure out what kind of multimethods are commonly used
in the languages we plan Parrot to be suitable for, and in perl6, and
decide what to have according to this. The user can complement the rest in
user-land.[1]

Regards,

	Shlomi Fish


[1] - I'm working on a pet dialect of Perl which I call Rindolf. Since it
will be mostly based on Perl 5, I plan to default on the user implement
multi-methods in user-land where he finds appropriate. I think it's more
flexible that way.

Regards,

	Shlomi Fish
 --


----------------------------------------------------------------------
Shlomi Fish        shlomif@vipe.technion.ac.il
Home Page:         http://t2.technion.ac.il/~shlomif/
Home E-mail:       shlomif@iglu.org.il

He who re-invents the wheel, understands much better how a wheel works.


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