Re: Need help with: Cannot find method 'postcircumfix:( )'...
On 03/20/2015 03:40 AM, Brandon Allbery wrote: On Thu, Mar 19, 2015 at 10:33 PM, Tom Browder tom.brow...@gmail.com mailto:tom.brow...@gmail.com wrote: Why do you say that is not a method? The first line says Sorry, somehow I managed to misread that. So you want what I have already said twice: the accessor `self.elem`. If you want to access the variable directly for some reason, you use the form `$.elem`. (By the way, that shadowing is generally bad form, and not just in Perl 6. It makes code confusing to read) Actually, $.elem is just short for $(self.elem); if you want direct access to the variable you'd write $!elem. Also, an indirect method call would be self.$elem, self.$elem is basically equivalent to $elem(self), which is why you get the cannot find method postcircumfix:( ) error, as whatever's in $elem is probably not callable like that Regards - Timo
Re: Need help with: Cannot find method 'postcircumfix:( )'...
On Thu, Mar 19, 2015 at 9:26 PM, Tom Browder tom.brow...@gmail.com wrote: On Mar 19, 2015 8:58 PM, Brandon Allbery allber...@gmail.com wrote: On Thu, Mar 19, 2015 at 9:32 PM, Tom Browder tom.brow...@gmail.com wrote: if (self.$elem) { # === LINE 995 === LINE 995 This is an indirect method call. Is that really what you intended? This is what I'm trying to achieve: No, it's supposed to be the value of the self attribute whose name is the value of my $elem. I have to go back and see how to do that. And this seems to work, new line 995 (my only change in the method): if (self.{$elem}) { # === LINE 995 === LINE 995 Best, -Tom
Re: Need help with: Cannot find method 'postcircumfix:( )'...
On 03/20/2015 11:00 AM, Timo Paulssen wrote: On 03/20/2015 03:40 AM, Brandon Allbery wrote: On Thu, Mar 19, 2015 at 10:33 PM, Tom Browder tom.brow...@gmail.com mailto:tom.brow...@gmail.com wrote: Why do you say that is not a method? The first line says Sorry, somehow I managed to misread that. So you want what I have already said twice: the accessor `self.elem`. If you want to access the variable directly for some reason, you use the form `$.elem`. (By the way, that shadowing is generally bad form, and not just in Perl 6. It makes code confusing to read) Actually, $.elem is just short for $(self.elem); if you want direct access to the variable you'd write $!elem. Also, an indirect method call would be self.$elem, small correction: self.$elem(). self.$elem is an error, which is useful to catch p5 programmers who use . for string concatenation. Cheers, Moritz
Re: Need help with: Cannot find method 'postcircumfix:( )'...
On Mar 19, 2015 9:30 PM, Brandon Allbery allber...@gmail.com wrote: On Thu, Mar 19, 2015 at 10:26 PM, Tom Browder tom.brow...@gmail.com wrote: On Mar 19, 2015 8:58 PM, Brandon Allbery allber...@gmail.com wrote: On Thu, Mar 19, 2015 at 9:32 PM, Tom Browder tom.brow...@gmail.com wrote: if (self.$elem) { # === LINE 995 === LINE 995 This is an indirect method call. Is that really what you intended? No, it's supposed to be the value of the self attribute whose name is the value of my $elem. I have to go back and see how to do that. Unless there is more that you didn't show, that function is not a method and has no `self`. Why do you say that is not a method? The first line says iAs I mentioned, if you *do* have an object reference `self` in scope somehow and want to access a `has $elem` defined within it, you use the automatically generated accessor `self.elem`. (If it was declared private, that is `has $!elem`, then I don't think you can get to it within that function unless it was passed in as a parameter.) -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
Re: Need help with: Cannot find method 'postcircumfix:( )'...
On Thu, Mar 19, 2015 at 10:33 PM, Tom Browder tom.brow...@gmail.com wrote: Why do you say that is not a method? The first line says Sorry, somehow I managed to misread that. So you want what I have already said twice: the accessor `self.elem`. If you want to access the variable directly for some reason, you use the form `$.elem`. (By the way, that shadowing is generally bad form, and not just in Perl 6. It makes code confusing to read) -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net
Re: Need help with: Cannot find method 'postcircumfix:( )'...
On Thu, Mar 19, 2015 at 9:32 PM, Tom Browder tom.brow...@gmail.com wrote: if (self.$elem) { # === LINE 995 === LINE 995 This is an indirect method call. Is that really what you intended? If you wanted the `my` variable, it's just `$elem`. If you somehow have an object in scope there (I don't see one offhand) and want a `has` variable from it named `$elem`, then you would normally use an accessor `self.elem`. Since this isn't a method, it can't (or at least shouldn't) access the `has` variable directly. -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net
Re: Need help with: Cannot find method 'postcircumfix:( )'...
Thanks for pointing out the error and the best practice comment. When I get the method to do what I really want I will post the solution. Best, -Tom
Re: Need help with: Cannot find method 'postcircumfix:( )'...
On Thu, Mar 19, 2015 at 10:26 PM, Tom Browder tom.brow...@gmail.com wrote: On Mar 19, 2015 8:58 PM, Brandon Allbery allber...@gmail.com wrote: On Thu, Mar 19, 2015 at 9:32 PM, Tom Browder tom.brow...@gmail.com wrote: if (self.$elem) { # === LINE 995 === LINE 995 This is an indirect method call. Is that really what you intended? No, it's supposed to be the value of the self attribute whose name is the value of my $elem. I have to go back and see how to do that. Unless there is more that you didn't show, that function is not a method and has no `self`. As I mentioned, if you *do* have an object reference `self` in scope somehow and want to access a `has $elem` defined within it, you use the automatically generated accessor `self.elem`. (If it was declared private, that is `has $!elem`, then I don't think you can get to it within that function unless it was passed in as a parameter.) -- brandon s allbery kf8nh sine nomine associates allber...@gmail.com ballb...@sinenomine.net unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net
Need help with: Cannot find method 'postcircumfix:( )'...
The error message is: Cannot find method 'postcircumfix:( )' in method _normalize_output at /usr/local/people/tbrowde/mydata/tbrowde-home-bzr/perl6/my-perl6-repos/Geo-Ellipsoid/test/../lib/Geo/Ellipsoid.pm:995 in method to at /usr/local/people/tbrowde/mydata/tbrowde-home-bzr/perl6/my-perl6-repos/Geo-Ellipsoid/test/../lib/Geo/Ellipsoid.pm:678 in sub print_dist at test_ellipsoid.pl:181 in sub MAIN at test_ellipsoid.pl:69 in block unit at test_ellipsoid.pl:25 Line 995 is in this method: method !_normalize_output(*@args) { my @a = @args; my $elem = shift @a; # 'bearing' or 'longitude' # adjust remaining input values by reference for (@a) - $_ { # - is 'read-write' operator if (self.$elem) { # === LINE 995 === LINE 995 # normalize to range [-pi,pi) while ($_ -(pi)) { $_ += $twopi } while ($_ = pi) { $_ -= $twopi } } else { # normalize to range [0,2*pi) while ($_ 0) { $_ += $twopi } while ($_ = $twopi) { $_ -= $twopi } } $_ = self!rad2deg($_) if self.units eq 'degrees'; } return @a; } Any hints would be appreciated. Best regards, -Tom
Re: Need help with: Cannot find method 'postcircumfix:( )'...
On Mar 19, 2015 8:58 PM, Brandon Allbery allber...@gmail.com wrote: On Thu, Mar 19, 2015 at 9:32 PM, Tom Browder tom.brow...@gmail.com wrote: if (self.$elem) { # === LINE 995 === LINE 995 This is an indirect method call. Is that really what you intended? No, it's supposed to be the value of the self attribute whose name is the value of my $elem. I have to go back and see how to do that. Good pointer, Brandon. Thanks! Best, -Tom