Skip to content

Instantly share code, notes, and snippets.

@hatyuki
Created January 17, 2014 01:19
Show Gist options
  • Save hatyuki/8466814 to your computer and use it in GitHub Desktop.
Save hatyuki/8466814 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use feature qw/ say /;
use Data::Lock qw/ dlock /;
use constant C_TRUE => 1;
use constant C_FALSE => 0;
dlock my $D_TRUE = 1;
dlock my $D_FALSE = 0;
my $V_TRUE = 1;
my $V_FALSE = 0;
my $I_TRUE = 1;
my $I_FALSE = 0;
Internals::SvREADONLY($I_TRUE, 1);
Internals::SvREADONLY($I_FALSE, 1);
say 'C_TRUE' if C_TRUE;
say 'C_FALSE' if C_FALSE;
say 'D_TRUE' if $D_TRUE;
say 'D_FALSE' if $D_FALSE;
say 'V_TRUE' if $V_TRUE;
say 'V_FALSE' if $V_FALSE;
say 'I_TRUE' if $I_TRUE;
say 'I_FALSE' if $I_FALSE;
__END__
perl -MO=Deparse ./constant_folding.pl
use Data::Lock ('dlock');
use constant ('C_TRUE', 1);
use constant ('C_FALSE', 0);
use warnings;
use strict;
use feature 'say';
dlock(my $D_TRUE = 1);
dlock(my $D_FALSE = 0);
my $V_TRUE = 1;
my $V_FALSE = 0;
my $I_TRUE = 1;
my $I_FALSE = 0;
&Internals::SvREADONLY(\$I_TRUE, 1);
&Internals::SvREADONLY(\$I_FALSE, 1);
say 'C_TRUE';
'???';
;
say 'D_TRUE' if $D_TRUE;
say 'D_FALSE' if $D_FALSE;
say 'V_TRUE' if $V_TRUE;
say 'V_FALSE' if $V_FALSE;
say 'I_TRUE' if $I_TRUE;
say 'I_FALSE' if $I_FALSE;
./constant_folding.pl syntax OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment