September 2017
Beginner
402 pages
9h 52m
English
Sometimes a module can offer vast functionality and only a portion of it is used by a program. In this case, you may organize a module in such a way that only a limited collection of the names is exported. Perl 6 provides a mechanism for tagging the names, as shown in the following example of a module:
unit module Math;sub add($a, $b) is export(:plusminus) { return $a + $b;}sub subtract($a, $b) is export(:plusminus) { return $a - $b;}sub mul($a, $b) is export(:muldiv) { return $a * $b;}sub div($a, $b) is export(:muldiv) { return $a / $b;}
In this module, there are two collections of the functions: two with the :plusminus tag and two with the :muldiv tag.
While importing a module, use the tag to select the names to import. ...
Read now
Unlock full access