Skip to content

Instantly share code, notes, and snippets.

@iacore
Created June 22, 2022 21:09
Show Gist options
  • Save iacore/6acd895214813149d0d8ec2b071a6cec to your computer and use it in GitHub Desktop.
Save iacore/6acd895214813149d0d8ec2b071a6cec to your computer and use it in GitHub Desktop.
use "constant" function sigilless
=begin pod
Example Usage:
=begin code
use OpenGL::GLFW:from<Perl5> qw<:all>;
use lib ".";
use ConstCaller;
constant GLFW = ConstCaller.new :package(OpenGL::GLFW.WHO) :prefix<GLFW>;
say GLFW<PRESS>;
=end code
=end pod
#| Use &PREFIX_CONST as PREFIX<CONST>
class ConstCaller does Associative {
has $.package;
has $.prefix;
method AT-KEY (Str:D $name) {
$!package{'&' ~ $!prefix ~ '_' ~ $name}.()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment