Created
June 22, 2022 21:09
-
-
Save iacore/6acd895214813149d0d8ec2b071a6cec to your computer and use it in GitHub Desktop.
use "constant" function sigilless
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=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