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
Possible bug in Perl 6 OO #6685
Comments
From richard.hogaboom@gmail.comAttached is an executable file that demos a possible Perl 6 OO bug if -- |
From richard.hogaboom@gmail.com# Richard Hogaboom # Fedora 28 # in Perl 6 OO if you have in a class an attribute name and a method name that are the same, use v6; =begin pod class Address { my $addr = Address.new; =begin pod class Address { multi method var() { multi method var(Str $v) { my $addr = Address.new; =begin pod class Address { method var() { my $addr = Address.new; # is there a general prohibition on having an attribute and an explicit method of the same name? =begin pod class Address { method var() { my $addr = Address.new; # why does just adding a return statement eliminate the compile error? and hang? =begin pod class Address { method var() { my $addr = Address.new; # this eliminates the infinite loop , but returns to the previous readonly variable msg. # all this seems a caution against using the same name as an attribute and explicit method name, |
From @zoffixznetOn Mon, 04 Jun 2018 07:31:40 -0700, richard.hogaboom@gmail.com wrote:
Thanks for the report, but there's no bug here. The `has When you use `$.foo` syntax inside a method, it's a shorthand for `self.foo`; in other words, it's a If you define a method with the same name as the attribute, then it signals to the compiler that you chose Also, to return a writeable container, you need to either use `return-rw` instead of plain `return` when method var1() is rw { return $!var } With that knowledge, you can see why the failing examples fail: * EXAMPLE 3: You defined a method with the same name as attribute, so it'll function as the accessor. The body
No, as it's perfectly fine to declare your own accessors. Of course, writing `has |
The RT System itself - Status changed from 'new' to 'open' |
@zoffixznet - Status changed from 'open' to 'rejected' |
From @zoffixznetOn Sat, 09 Jun 2018 05:33:04 -0700, cpan@zoffix.com wrote:
Correction, that should be: method var1() is rw { $!var } |
Migrated from rt.perl.org#133246 (status was 'rejected')
Searchable as RT133246$
The text was updated successfully, but these errors were encountered: