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.
Deep Learning with Python by François Chollet(12568)
Hello! Python by Anthony Briggs(9913)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9795)
The Mikado Method by Ola Ellnestam Daniel Brolund(9777)
Dependency Injection in .NET by Mark Seemann(9337)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8295)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7763)
Grails in Action by Glen Smith Peter Ledbrook(7696)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7054)
Microservices with Go by Alexander Shuiskov(6817)
Practical Design Patterns for Java Developers by Miroslav Wengner(6734)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6675)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6409)
Angular Projects - Third Edition by Aristeidis Bampakos(6079)
The Art of Crafting User Stories by The Art of Crafting User Stories(5607)
NetSuite for Consultants - Second Edition by Peter Ries(5547)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5347)
Kotlin in Action by Dmitry Jemerov(5062)
