ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl6-language
perl6-language
Re: MMD vs. anonymous parameter types referencing earlier parameters
by =22TSa_=28Thomas_Sandla=DF=29=22 other posts by this author
Jun 14 2005 6:44AM messages near this date
MMD vs. anonymous parameter types referencing earlier parameters | Re: MMD vs. anonymous parameter types referencing earlier parameters
Chip Salzenberg wrote:
>  This:
>  
>      multi sub is_equal(Integer $a, Integer where { $_ == $a } $b: ) { 1 }
>  
>  hurts.  At least as I've been given to understand it[*], is impossible
>  to implement, because the second parameter's type can't be precalculated
>  in order to prepare for MMD dispatching.

Quite interesting that Cecil already has it. The thing is called
Predicate Dispatch and there exist efficient implementation strategies.
And it is possible to calculate a static supertype of the above,
which is &is_equal:( Integer, Integer : ).


>  In short, $b has no pre-calculable type.  And you can't calculate the
>  MMD potential of a subroutine unless you know the actual types of its
>  MMD-participating parameters.

I don't know what 'MMD potential' is.


>  (This also means that the type of &is_equal:(...) is impossible to
>  express, unless I greatly misunderstand the &foo:() syntax.  But
>  it doesn't matter what you call it if you can't call it.)

The syntax might just be:

    &is_equal:(Integer $a, Integer where { $_ == $a } :)

The only point is that I see no way for the compiler to
optimize to anything but a dynamic dispatch. Thus a more
declarative style of predicate specification would be
helpfull.


>  PS: Of course this example also implies that each parameter's
>      declaration introduces a new lexical scope to its right.

Well the colloquial spec of your function is just 'it takes
two equal integers'. And the two element list (3,3) is a
subtype of it.

Regards,
-- 
TSa (Thomas SandlaÃ?)
Thread:
Larry Wall
Chip Salzenberg
=22TSa_=28Thomas_Sandla=DF=29=22
Chip Salzenberg
Larry Wall
=22TSa_=28Thomas_Sandla=DF=29=22

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved