New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use 'is rw' on optional parameter #3686
Comments
From avuserow@gmail.comI tried 'sub f($x is rw = 60)', STD parses it but rakudo prohibits it. This is perl6 version 2015.01-141-gfec2339 built on MoarVM version 143936 avuserow | m: sub f($x is rw = 60) {$x++; say $x}; f In the "Parameter traits" section of S06, it mentions about 'is rw' and |
From @usev6The relevant sentences from the design docs (S06, introduced with commit 7846594ee4): "Since this option [is rw] forces an argument to be required, it cannot coexist with the ? mark to make an argument optional. (It may, however, be used with = indicating a default, but only if the default expression represents something that is nameable at compile time and that can bind as an lvalue, such as CALLER::<$/> or OUTER::<$_>.)" AFAIU the default value in question (= 60) does not qualify as a valid "is rw"-able expression according to S06. Rakudo makes no difference between parameters made optional with the ? mark or those made optional by providing a default value and simply disallows 'is rw' (introduced with commit 45c44bafbf), e.g.: $ perl6 -e 'sub f($x is rw = OUTER::<$_>) {$x++; say $x}; $_ = 41; f' |
1 similar comment
From @usev6The relevant sentences from the design docs (S06, introduced with commit 7846594ee4): "Since this option [is rw] forces an argument to be required, it cannot coexist with the ? mark to make an argument optional. (It may, however, be used with = indicating a default, but only if the default expression represents something that is nameable at compile time and that can bind as an lvalue, such as CALLER::<$/> or OUTER::<$_>.)" AFAIU the default value in question (= 60) does not qualify as a valid "is rw"-able expression according to S06. Rakudo makes no difference between parameters made optional with the ? mark or those made optional by providing a default value and simply disallows 'is rw' (introduced with commit 45c44bafbf), e.g.: $ perl6 -e 'sub f($x is rw = OUTER::<$_>) {$x++; say $x}; $_ = 41; f' |
@usev6 - Status changed from 'new' to 'open' |
From @AlexDanielStill reproducible (2017.11,HEAD(e5b660e)) I don't know if it's NYI or @LARRY. I'd put LARRY first, and then one of the LARRYs can turn it into a NYI. On 2015-08-05 15:25:57, bartolin@gmx.de wrote:
|
Migrated from rt.perl.org#123835 (status was 'open')
Searchable as RT123835$
The text was updated successfully, but these errors were encountered: