Re: Need help with: Cannot find method 'postcircumfix:<( )>'...

2015-03-19 Thread Tom Browder
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:<( )>'...

2015-03-19 Thread Brandon Allbery
On Thu, Mar 19, 2015 at 10:33 PM, Tom Browder 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

Re: Need help with: Cannot find method 'postcircumfix:<( )>'...

2015-03-19 Thread Tom Browder
On Mar 19, 2015 9:30 PM, "Brandon Allbery" wrote: > Unless there is more that you didn't show, that function is not a method and has no `self`. [Please ignore last msg sent prematurely.] Why do you say that? The first line says it is a private method. -Tom

Re: Need help with: Cannot find method 'postcircumfix:<( )>'...

2015-03-19 Thread Tom Browder
On Mar 19, 2015 9:30 PM, "Brandon Allbery" wrote: > > On Thu, Mar 19, 2015 at 10:26 PM, Tom Browder wrote: >> >> On Mar 19, 2015 8:58 PM, "Brandon Allbery" wrote: >> > On Thu, Mar 19, 2015 at 9:32 PM, Tom Browder wrote: >> >> >> >> if (self.$elem) { # <=== LINE 995 === LINE

Re: Need help with: Cannot find method 'postcircumfix:<( )>'...

2015-03-19 Thread Brandon Allbery
On Thu, Mar 19, 2015 at 10:26 PM, Tom Browder wrote: > On Mar 19, 2015 8:58 PM, "Brandon Allbery" wrote: > > On Thu, Mar 19, 2015 at 9:32 PM, Tom Browder > wrote: > >> > >> if (self.$elem) { # <=== LINE 995 === LINE 995 > > This is an indirect method call. Is that really wha

Re: Need help with: Cannot find method 'postcircumfix:<( )>'...

2015-03-19 Thread Tom Browder
On Mar 19, 2015 8:58 PM, "Brandon Allbery" wrote: > On Thu, Mar 19, 2015 at 9:32 PM, Tom Browder 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 attr

Re: Need help with: Cannot find method 'postcircumfix:<( )>'...

2015-03-19 Thread Brandon Allbery
On Thu, Mar 19, 2015 at 9:32 PM, Tom Browder 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'

Need help with: Cannot find method 'postcircumfix:<( )>'...

2015-03-19 Thread Tom Browder
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-r

Re: Function Signatures: Return Types (replace wantarray?)

2015-03-19 Thread Darren Duncan
On 2015-03-19 4:17 PM, Tom Browder wrote: On Thu, Mar 19, 2015 at 5:58 PM, Tobias Leich wrote: The multi dispatcher *only* chooses the multi candidate by matching arguments to parameters. The return type is not considered. Okay, I have now kind of found that in the synopses (which are a bit c

Re: Function Signatures: Return Types (replace wantarray?)

2015-03-19 Thread Tom Browder
On Thu, Mar 19, 2015 at 5:58 PM, Tobias Leich wrote: > The multi dispatcher *only* chooses the multi candidate by matching > arguments to parameters. The return type is not considered. Okay, I have now kind of found that in the synopses (which are a bit confusing for me considering the function r

Re: Function Signatures: Return Types (replace wantarray?)

2015-03-19 Thread Brent Laabs
There is nothing exactly like wantarray in Perl 6. Functions can no longer return different values based on context, because as Darren mentioned above, it's a Bad Thing. There are a few ways of doing something similar by returning mixins, perhaps something like return $num but [$num, $num2]; (w

Re: Function Signatures: Return Types (replace wantarray?)

2015-03-19 Thread Darren Duncan
So, I think that a proper solution here is for there to be a single method foo that has the desired parameter signature, and have that method return a single object which acts like / has the roles/interfaces of both of the return types that 'wantarray' would have chosen between. Therefore, each

Re: Function Signatures: Return Types (replace wantarray?)

2015-03-19 Thread Tobias Leich
The multi dispatcher *only* chooses the multi candidate by matching arguments to parameters. The return type is not considered. Btw, the syntax for returning an arrayish thing might be: method foo($a, $b --> Positional) { ... } Am 19.03.2015 um 23:53 schrieb Darren Duncan: > I think as a general

Re: Function Signatures: Return Types (replace wantarray?)

2015-03-19 Thread Darren Duncan
I think as a general principle, multi methods should dispatch entirely on their parameter signatures, and dispatching on return type is just a bad design that leads to trouble. If you want different return types for identical parameters, you should give those 2 versions different method base na

Function Signatures: Return Types (replace wantarray?)

2015-03-19 Thread Tom Browder
I need to replace the Perl 5 'wantarray' and think a multi method with differing return types should do it. So I've tried this: multi method foo($a, $b --> {Num,Num}) { #... } multi method foo($a, $b --> Num) { #... } and get errors like: Missing block at Ellipsoid.pm:672 --> ethod to($lat1

Re: Passing arrays to subroutines

2015-03-19 Thread Tom Browder
On Thu, Mar 19, 2015 at 10:15 AM, Moritz Lenz wrote: > On 03/19/2015 04:05 PM, Tom Browder wrote: >> >> In Perl 5 I can do this: ... >> 1. How can I combine arrays @a and @b into one array? > > > generally with the comma operator: > > my @combined = @a, @b; It looks like I can also do this: my

Re: Passing arrays to subroutines

2015-03-19 Thread Moritz Lenz
On 03/19/2015 04:05 PM, Tom Browder wrote: In Perl 5 I can do this: my @a = (1, 2); my @b = (3); foo(@a,@b); sub foo { my $n = @_; die "Wrong num args: $n" if ($n != 3);} In Perl 6 I think this is correct (or nearly so): sub foo(*@args) { die "Wrong num args: { @args.elems }" if @args.ele

Passing arrays to subroutines

2015-03-19 Thread Tom Browder
In Perl 5 I can do this: my @a = (1, 2); my @b = (3); foo(@a,@b); sub foo { my $n = @_; die "Wrong num args: $n" if ($n != 3);} In Perl 6 I think this is correct (or nearly so): sub foo(*@args) { die "Wrong num args: { @args.elems }" if @args.elems != 3;} Questions for Perl 6: foo is now de

Re: Can a class have an attribute and a method with the same name?

2015-03-19 Thread Tom Browder
On Mar 19, 2015 3:02 AM, "Moritz Lenz" wrote: > On 03/19/2015 12:40 AM, Tom Browder wrote: > So, you can have an attribute $!x and a method x, but if you write > > class A { > has $.x; > method x() {... } > } > > then the method will prevent the automatic accessor from being generated. Th

Re: Can a class have an attribute and a method with the same name?

2015-03-19 Thread Moritz Lenz
Hi, On 03/19/2015 12:40 AM, Tom Browder wrote: I have a class with an attribute and a method with the same name and it looks so far like they clash. Attributes are always private. If you write 'has $.x', that generates not only the attribute, but also an accessor method of name 'x'. See also