Perl 6 Quick Syntax Reference by J. J. Merelo
Author:J. J. Merelo
Language: eng
Format: epub
ISBN: 9781484249567
Publisher: Apress
will return True and False, and the result of using eq followed by a collapse via so or ?. As a matter of fact, this is what where does in signatures: it smartmatches against the value of the argument.
Decoupling Signatures
You have seen that Perl 6 is able to capture all values that are going to be used to invoke a routine in a, well, Capture; in fact, it has also objects, called Signatures, which contain the format of the signature a routine is called with. They are mostly used to check if a routine follows a certain signature via smartmatch.
Sometimes all the possibilities with which a routine is going to be called are not known in advance. You know the general layout, but the details might vary, and several possible types might be used as an argument. There’s a straightforward solution: to go sigilless, but then you lose all type information and the possibility of tailoring the implementation to the different types used.my $card-printer = :(Int,Str);
sub print-card( Int $card-number,
Str $suit,
&printer where .signature ~~ $card-printer) {
return printer( $card-number, $suit);
}
my &de-printer = -> Int $card, Str $suit { "$card de $suit" };
my &printer:<♦> = -> Int $card, Str $suit { "$card ♦ $suit" };
say print-card( 2, "Bastos", &de-printer); # 2 de Bastos
say print-card( 9, "Espadas", &printer:<♦>); # 9 ♦ Espadas
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Mikado Method by Ola Ellnestam Daniel Brolund(20975)
Hello! Python by Anthony Briggs(20254)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(18615)
Dependency Injection in .NET by Mark Seemann(18408)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(17931)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(17690)
Kotlin in Action by Dmitry Jemerov(17589)
Adobe Camera Raw For Digital Photographers Only by Rob Sheppard(16939)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(16509)
Grails in Action by Glen Smith Peter Ledbrook(15654)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(10485)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(8059)
Microservices with Go by Alexander Shuiskov(7824)
Practical Design Patterns for Java Developers by Miroslav Wengner(7725)
Test Automation Engineering Handbook by Manikandan Sambamurthy(7677)
Angular Projects - Third Edition by Aristeidis Bampakos(7166)
The Art of Crafting User Stories by The Art of Crafting User Stories(6613)
NetSuite for Consultants - Second Edition by Peter Ries(6536)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(6308)