> On 16 Sep 2017, at 13:32, Norman Gaywood <ngayw...@une.edu.au> wrote: > > I have this: > #!/usr/bin/perl6 > use v6; > sub MAIN( :$debug = False, :$verbose = False ) { > $verbose = True if $debug; > say "verbose={$verbose}, debug={$debug}"; > } > $ ./tt.p6 > verbose=False, debug=False > $ ./tt.p6 --verbose > verbose=True, debug=False > $ ./tt.p6 --debug > Cannot assign to a readonly variable ($verbose) or a value > in sub MAIN at ./tt.p6 line 6 > in block <unit> at ./tt.p6 line 4 > > So $verbose is read-only. I think the compiler could have told me this a > compile time? > > I try to fix it: > ... > sub MAIN( :$debug = False, :$verbose is rw = False ) { > ... > $ ./tt.p6 --debug > ===SORRY!=== Error while compiling /home/ngaywood/./tt.p6 > Cannot use 'is rw' on optional parameter '$verbose'. > at /home/ngaywood/./tt.p6:4 > > Not sure what the neat way of doing this is.
You probably want “is copy” here? I mean, you want to be able to change it *within* MAIN, no? sub MAIN( :$debug = False, :$verbose is copy = False ) { $verbose = True if $debug; say "verbose={$verbose}, debug={$debug}"; } then works fine with —debug . Liz