Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Perl6 'fun'

Name: 🦋 2018-02-26 6:00

Let's make a Jolly module that will export some invisible terms and operators. We'll then sprinkle them into our Christmassy friends' code:

unit module Jolly;
sub term:«\c[INVISIBLE TIMES]» is export { 42 }
sub infix:«\c[INVISIBLE TIMES]» is export {
$^a × $^b
}

sub prefix:«\c[INVISIBLE SEPARATOR]» (|)
is looser(&[,]) is export
{
say "Ho-ho-ho!";

}


We've used the same character for the term and the infix operator. That's fine, as Perl 6 has fairly strict expectation of terms being followed by operators and vice versa, so it'll know when we meant to use the term or when to use the infix operator. Here's the resultant Grinch code, along with the output it produces:



⁣say 42⁢⁢;
# OUTPUT:
# 1764
# Ho-ho-ho!


That'll sure be fun to debug!

Name: Mentifex 2018-02-26 13:00

>>5

http://www.listbox.com/member/archive/303/2018/02

is the sum total of everything /prog/ related.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List