Skip to content
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

Shouldn't be able to make 'is rw' parameters optional or give them defaults in Rakudo #2262

Closed
p6rt opened this issue Nov 16, 2010 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Nov 16, 2010

Migrated from rt.perl.org#79288 (status was 'resolved')

Searchable as RT79288$

@p6rt
Copy link
Author

p6rt commented Nov 16, 2010

From @masak

<masak> blog post!
http://strangelyconsistent.org/blog/november-16-2010-the-polite-revolt
<masak> rakudo​: sub foo($x? is rw) { $x = "OH HAI" }; foo()
<p6eval> rakudo 015d77​: OUTPUT«Cannot modify readonly value [...]
<masak> discuss.
* masak submits rakudobug
* masak looks
<Tene> masak​: A third of the way through or so, I was thinking "Could
he use 'is copy' instead?" :)
<Tene> masak​: I agree in that I expect rw defaults to be a copy/assign.
<Tene> masak​: Shouldn't be too hard to fix, I expect.
<masak> Tene​: oh, good.
<Tene> I mean, the functionality is obviously already there, as 'is
copy' can do it fine, so you'd just look at what's different in the
PAST, etc.
<jnthn> akshually probably an easy-ish binder patch.
<masak> \o/

@p6rt
Copy link
Author

p6rt commented Nov 17, 2010

From @masak

On Tue Nov 16 14​:45​:34 2010, masak wrote​:

<masak> blog post!
http://strangelyconsistent.org/blog/november-16-2010-the-polite-revolt
<masak> rakudo​: sub foo($x? is rw) { $x = "OH HAI" }; foo()
<p6eval> rakudo 015d77​: OUTPUT«Cannot modify readonly value [...]
<masak> discuss.
* masak submits rakudobug
* masak looks
<Tene> masak​: A third of the way through or so, I was thinking "Could
he use 'is copy' instead?" :)
<Tene> masak​: I agree in that I expect rw defaults to be a copy/assign.
<Tene> masak​: Shouldn't be too hard to fix, I expect.
<masak> Tene​: oh, good.
<Tene> I mean, the functionality is obviously already there, as 'is
copy' can do it fine, so you'd just look at what's different in the
PAST, etc.
<jnthn> akshually probably an easy-ish binder patch.
<masak> \o/

New spec change says this​:

Raku/old-design-docs@44511d7
] Since this option forces an argument to be required,
] it cannot co-exist with any marks that indicate an optional parameter,
] such as C<?> or a default value.

Repurposing this ticket to be about that.

$ perl6 -e 'sub foo($x? is rw) {}; foo(); say "alive"'
alive

Should die at compile time.

@p6rt
Copy link
Author

p6rt commented Nov 17, 2010

@masak - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jan 13, 2012

From @jnthn

New spec change says this​:

Raku/old-design-docs@44511d7

] Since this option forces an argument to be required,
] it cannot co-exist with any marks that indicate an optional
parameter,
] such as C<?> or a default value.

Repurposing this ticket to be about that.

$ perl6 -e 'sub foo($x? is rw) {}; foo(); say "alive"'
alive

Should die at compile time.

Now it does​:

===SORRY!===
Cannot use 'is rw' on an optional parameter

Tagging testneeded.

/jnthn

@p6rt
Copy link
Author

p6rt commented Jan 4, 2015

From @usev6

On Fri Jan 13 04​:54​:34 2012, jnthn@​jnthn.net wrote​:

New spec change says this​:

Raku/old-design-docs@44511d7

] Since this option forces an argument to be required,
] it cannot co-exist with any marks that indicate an optional
parameter,
] such as C<?> or a default value.

Repurposing this ticket to be about that.

$ perl6 -e 'sub foo($x? is rw) {}; foo(); say "alive"'
alive

Should die at compile time.

Now it does​:

===SORRY!===
Cannot use 'is rw' on an optional parameter

Tagging testneeded.

/jnthn

Still dies at compile time (as expected)​:

$ perl6 -e 'sub foo($x? is rw) {}'
===SORRY!=== Error while compiling -e
Cannot use 'is rw' on an optional parameter
at -e​:1
------>

$ perl6 -e 'sub foo($x is rw = 4) {}'
===SORRY!=== Error while compiling -e
Cannot use 'is rw' on an optional parameter
at -e​:1
------>

I added two tests to S06-signature/optional.t with commit Raku/roast@1014935495

I'm closing this ticket now.

@p6rt
Copy link
Author

p6rt commented Jan 4, 2015

@usev6 - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant