Skip to content

Instantly share code, notes, and snippets.

@hoelzro
Created March 7, 2013 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoelzro/5109267 to your computer and use it in GitHub Desktop.
Save hoelzro/5109267 to your computer and use it in GitHub Desktop.
Perl 6 window manager
#!/usr/bin/env perl6
use v6;
class Window {
has $.name;
has $.class;
}
class WindowManager {
proto method manage-window(Window $w) { * }
multi method manage-window(Window $w ( :class<Firefox> )) {
say "Managing Firefox";
}
multi method manage-window(Window $w) {
say "Falling back to default management";
}
}
my $manager = WindowManager.new;
my $window = Window.new(:class<Firefox>, :name<Firefox>);
$manager.manage-window($window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment