Re: I need syntax to sub declare return a hash and an array

2020-01-23 Thread ToddAndMargo via perl6-users
On 2020-01-23 06:15, Elizabeth Mattijsen wrote: Larry Wall once warned that the "return..." syntax may be removed at some point. "return..." is a common idiom in many programming languages, and keeping it around might help programmers ease their transition to raku/perl6. So I'd hate to see "retu

Re: I need syntax to sub declare return a hash and an array

2020-01-23 Thread Tom Browder
On Thu, Jan 23, 2020 at 08:15 Elizabeth Mattijsen wrote: > >> Larry Wall once warned that the "return..." syntax may be removed at > some point. > > "return..." is a common idiom in many programming languages, and > > keeping it around might help programmers ease their transition to > > raku/perl

Re: I need syntax to sub declare return a hash and an array

2020-01-23 Thread Elizabeth Mattijsen
>> Larry Wall once warned that the "return..." syntax may be removed at some >> point. > "return..." is a common idiom in many programming languages, and > keeping it around might help programmers ease their transition to > raku/perl6. So I'd hate to see "return" go away--at least for the > forese

Re: I need syntax to sub declare return a hash and an array

2020-01-23 Thread William Michels via perl6-users
On Tue, Jan 21, 2020 at 5:00 AM Tom Browder wrote: > > On Mon, Jan 20, 2020 at 22:16 ToddAndMargo via perl6-users > wrote: >> >> On 2020-01-20 20:09, ToddAndMargo via perl6-users wrote: >> > On 2020-01-20 19:55, ToddAndMargo via perl6-users wrote: > > ... >> >> > I think this is it: >> > >> > >

Re: I need syntax to sub declare return a hash and an array

2020-01-22 Thread ToddAndMargo via perl6-users
On 2020-01-21 22:44, Peter Pentchev wrote: On Tue, Jan 21, 2020 at 07:16:17PM -0800, Todd Chester via perl6-users wrote: On 2020-01-21 18:57, Tom Browder wrote: On Tue, Jan 21, 2020 at 18:34 Todd Chester via perl6-users mailto:perl6-us...@perl.org>> wrote: On 2020-01-21 16:09, Todd Ches

Re: I need syntax to sub declare return a hash and an array

2020-01-21 Thread Peter Pentchev
On Tue, Jan 21, 2020 at 07:16:17PM -0800, Todd Chester via perl6-users wrote: > > > On 2020-01-21 18:57, Tom Browder wrote: > > On Tue, Jan 21, 2020 at 18:34 Todd Chester via perl6-users > > mailto:perl6-us...@perl.org>> wrote: > > > > On 2020-01-21 16:09, Todd Chester via perl6-users wrote:

Re: I need syntax to sub declare return a hash and an array

2020-01-21 Thread Todd Chester via perl6-users
On 2020-01-21 18:57, Tom Browder wrote: On Tue, Jan 21, 2020 at 18:34 Todd Chester via perl6-users mailto:perl6-us...@perl.org>> wrote: On 2020-01-21 16:09, Todd Chester via perl6-users wrote: >> 4) A block (that is the { ... } bit) will always 'return' the last >> expression e

Re: I need syntax to sub declare return a hash and an array

2020-01-21 Thread Tom Browder
On Tue, Jan 21, 2020 at 18:34 Todd Chester via perl6-users < perl6-us...@perl.org> wrote: > On 2020-01-21 16:09, Todd Chester via perl6-users wrote: > >> 4) A block (that is the { ... } bit) will always 'return' the last > >> expression evaluated. > > > > Seems to me I have see the last expression

Re: I need syntax to sub declare return a hash and an array

2020-01-21 Thread Todd Chester via perl6-users
On 2020-01-21 16:09, Todd Chester via perl6-users wrote: 4) A block (that is the { ... } bit) will always 'return' the last expression evaluated. Seems to me I have see the last expression returned even without the {...}.  Maybe I am misremembering. > sub AplusB( $a, $b --> Int ){$a+$b;}

Re: I need syntax to sub declare return a hash and an array

2020-01-21 Thread Todd Chester via perl6-users
On 2020-01-21 14:03, Elizabeth Mattijsen wrote: On 21 Jan 2020, at 22:37, Richard Hainsworth wrote: 2) 'returns' in the declaration (not the part in the block) used to be used, but for some arcane reason that I never really understood, it is deprecated. Not sure it is *the* reason, but the

Re: I need syntax to sub declare return a hash and an array

2020-01-21 Thread Todd Chester via perl6-users
> On 21/01/2020 04:09, ToddAndMargo via perl6-users wrote: >> On 2020-01-20 19:55, ToddAndMargo via perl6-users wrote: >>> Hi All, >>> >>> What is the proper way to state that I am returning a >>> hash from a sub? `sub x() returns % {}` >>> >>> And an array? `sub x() returns @ {}` >>> >>> Many

Re: I need syntax to sub declare return a hash and an array

2020-01-21 Thread Elizabeth Mattijsen
> On 21 Jan 2020, at 22:37, Richard Hainsworth wrote: > 2) 'returns' in the declaration (not the part in the block) used to be used, > but for some arcane reason that I never really understood, it is deprecated. Not sure it is *the* reason, but the return type is part of the signature of a bloc

Re: I need syntax to sub declare return a hash and an array

2020-01-21 Thread Richard Hainsworth
sub x( --> Hash) { my %h = A => 'a' } 1) '-->' in the signature is the best way to provide information to the compiler about what the subroutine should return 2) 'returns' in the declaration (not the part in the block) used to be used, but for some arcane reason that I never really understood

Re: I need syntax to sub declare return a hash and an array

2020-01-21 Thread ToddAndMargo via perl6-users
On 2020-01-21 05:00, Tom Browder wrote: The preferred syntax is: sub x(--> Hash) {...} See that in the docs. Larry Wall once warned that the "return..." syntax may be removed at some point. -Tom Hi Tom, Interesting. I have been showing both in my keepers. I currently use "returns "

Re: I need syntax to sub declare return a hash and an array

2020-01-21 Thread Tom Browder
On Mon, Jan 20, 2020 at 22:16 ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > On 2020-01-20 20:09, ToddAndMargo via perl6-users wrote: > > On 2020-01-20 19:55, ToddAndMargo via perl6-users wrote: ... > > I think this is it: > > > > > sub x() returns Associative { my %h= A=>"a"; re

Re: I need syntax to sub declare return a hash and an array

2020-01-20 Thread ToddAndMargo via perl6-users
On 2020-01-20 20:36, 浪花城主 wrote: How about returning a reference? Just for test (sorry I have no perl6 installed on local device): $ perl -le 'sub x {%hash=(1,2,3,4);\%hash}; print x->{1}' 2 Regards. Hi 浪花城主, No Perl6 installed I am Heart Broken!!! Why! Why! KIDS THESE DAYS!! :-) I

Re: I need syntax to sub declare return a hash and an array

2020-01-20 Thread 浪花城主
How about returning a reference? Just for test (sorry I have no perl6 installed on local device): $ perl -le 'sub x {%hash=(1,2,3,4);\%hash}; print x->{1}' 2 Regards. On Tue, Jan 21, 2020 at 11:56 AM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > Hi All, > > What is the proper w

Re: I need syntax to sub declare return a hash and an array

2020-01-20 Thread ToddAndMargo via perl6-users
On 2020-01-20 20:09, ToddAndMargo via perl6-users wrote: On 2020-01-20 19:55, ToddAndMargo via perl6-users wrote: Hi All, What is the proper way to state that I am returning a hash from a sub?   `sub x() returns % {}` And an array?  `sub x() returns @ {}` Many thanks, -T I think this is it

Re: I need syntax to sub declare return a hash and an array

2020-01-20 Thread ToddAndMargo via perl6-users
On 2020-01-20 19:55, ToddAndMargo via perl6-users wrote: Hi All, What is the proper way to state that I am returning a hash from a sub?   `sub x() returns % {}` And an array?  `sub x() returns @ {}` Many thanks, -T I think this is it: > sub x() returns Associative { my %h= A=>"a"; return %