Re: need --> help

2018-10-12 Thread Brandon Allbery
Actually, I was trying to think too much like tuples earlier… would a subsignature work here? …Turns out no. Seems unfortunate. pyanfar Z$ perl6 derp.p6 ===SORRY!=== Error while compiling /home/allbery/derp.p6 Unable to parse expression in typename; couldn't find final ')' (corresponding starter

Re: need --> help

2018-10-12 Thread ToddAndMargo via perl6-users
On Fri, Oct 12, 2018 at 11:23 PM ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: On 10/12/18 2:35 PM, Curt Tilmes wrote: > > > On Fri, Oct 12, 2018 at 5:08 PM ToddAndMargo via perl6-users > mailto:perl6-us...@perl.org>

Re: need --> help

2018-10-12 Thread ToddAndMargo via perl6-users
On 10/12/18 3:27 PM, Curt Tilmes wrote: On Fri, Oct 12, 2018 at 6:23 PM ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: Is there any way to say I am return two things: a string and an integer? You can only return one thing, but that one thing can be a List that has

Re: need --> help

2018-10-12 Thread Ralph Mellor
I imagine P6 may one day be changed to do as you suggest. But for now I think something like this is the closest you'll get: subset Str_Int of List where Str, Int; sub foo (--> Str_Int) { return 'a', 42 } -- raiph On Fri, Oct 12, 2018 at 11:23 PM ToddAndMargo via perl6-users <

Re: need --> help

2018-10-12 Thread Curt Tilmes
On Fri, Oct 12, 2018 at 6:23 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > Is there any way to say I am return two things: a string and an integer? > You can only return one thing, but that one thing can be a List that has a string and an integer in it.

Re: need --> help

2018-10-12 Thread ToddAndMargo via perl6-users
On 10/12/18 2:35 PM, Curt Tilmes wrote: On Fri, Oct 12, 2018 at 5:08 PM ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: >>     On 10/12/18 12:52 PM, Curt Tilmes wrote: >>      > You could make a subset for the List your're trying to return: >>      >

Re: need --> help

2018-10-12 Thread Curt Tilmes
On Fri, Oct 12, 2018 at 5:08 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > >> On 10/12/18 12:52 PM, Curt Tilmes wrote: > >> > You could make a subset for the List your're trying to return: > >> > > >> > subset liststrint of List where .[0] ~~ Str && .[1] ~~

Re: need --> help

2018-10-12 Thread ToddAndMargo via perl6-users
On Fri, Oct 12, 2018 at 3:14 PM ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: >> On Fri, Oct 12, 2018 at 3:32 PM ToddAndMargo via perl6-users >> mailto:perl6-us...@perl.org> >> wrote: >> >>

Re: need --> help

2018-10-12 Thread Brad Gilbert
That would be `List` sub RtnOrd( Str $Char --> List ){ $Char, ord($Char) } say RtnOrd "A" # (A 65) On Fri, Oct 12, 2018 at 3:14 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > >> On Fri, Oct 12, 2018 at 3:32 PM ToddAndMargo via perl6-users > >>

Re: need --> help

2018-10-12 Thread ToddAndMargo via perl6-users
On Fri, Oct 12, 2018 at 3:32 PM ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: But this does not? $ p6 'sub RtnOrd( Str $Char --> Str, Int ){return $Char, ord($Char)}; say RtnOrd "A";' ===SORRY!=== Error while compiling -e Malformed

Re: need --> help

2018-10-12 Thread ToddAndMargo via perl6-users
On Fri, Oct 12, 2018 at 3:32 PM ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: Hi All, Why does this work $ p6 'sub RtnOrd( Str $Char --> Int ){return ord($Char)}; say RtnOrd "A";' 65 But this does not? $ p6 'sub RtnOrd( Str

Re: need --> help

2018-10-12 Thread Curt Tilmes
On Fri, Oct 12, 2018 at 3:32 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > > But this does not? > > $ p6 'sub RtnOrd( Str $Char --> Str, Int ){return $Char, > ord($Char)}; say RtnOrd "A";' > > ===SORRY!=== Error while compiling -e > Malformed return value (return

Re: need --> help

2018-10-12 Thread Brandon Allbery
Precedence. `--> (Str, Int)` might work better; right now it can't tell if you meant that, or intended the usual meaning for a comma which would separate parameters. On Fri, Oct 12, 2018 at 3:32 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > Hi All, > > Why does this work > >

need --> help

2018-10-12 Thread ToddAndMargo via perl6-users
Hi All, Why does this work $ p6 'sub RtnOrd( Str $Char --> Int ){return ord($Char)}; say RtnOrd "A";' 65 But this does not? $ p6 'sub RtnOrd( Str $Char --> Str, Int ){return $Char, ord($Char)}; say RtnOrd "A";' ===SORRY!=== Error while compiling -e Malformed return

Re: routine declaration line question

2018-10-12 Thread Larry Wall
On Fri, Oct 12, 2018 at 06:47:40AM -0400, Curt Tilmes wrote: : Adding it gives more information to the consumers of that routine, : the people reading it, the compiler optimizing use of the routine, : and the runtime execution which will validate the return and throw an : exception for you if it

Re: routine declaration line question

2018-10-12 Thread Curt Tilmes
On Fri, Oct 12, 2018 at 8:46 AM Simon Proctor wrote: > What if something could return an Int or a Rat? Or an single item or an > Array? Having Mu or Any as the listed return type isn't very useful. > > Maybe better to define a subset for it. Or just leave it empty and > document it. > For an

Re: routine declaration line question

2018-10-12 Thread Simon Proctor
What if something could return an Int or a Rat? Or an single item or an Array? Having Mu or Any as the listed return type isn't very useful. Maybe better to define a subset for it. Or just leave it empty and document it. On Fri, 12 Oct 2018, 13:35 Curt Tilmes, wrote: > > On Fri, Oct 12, 2018

Re: routine declaration line question

2018-10-12 Thread Curt Tilmes
On Fri, Oct 12, 2018 at 7:46 AM Simon Proctor wrote: > Only if the routine has an easily defined return Type. Many do not. > Is there not always a common root, even if it is Mu? Why not explicitly mark those as Mu for documentation purposes at least? That would differentiate those from the

Re: routine declaration line question

2018-10-12 Thread Simon Proctor
Only if the routine has an easily defined return Type. Many do not. On Fri, 12 Oct 2018 at 12:41, Curt Tilmes wrote: > > > On Fri, Oct 12, 2018 at 7:31 AM Todd Chester via perl6-users < > perl6-us...@perl.org> wrote: > >> I was asking because sometimes the documentation for routines does >> not

Re: routine declaration line question

2018-10-12 Thread Curt Tilmes
On Fri, Oct 12, 2018 at 7:31 AM Todd Chester via perl6-users < perl6-us...@perl.org> wrote: > I was asking because sometimes the documentation for routines does > not give a --> and I find having to dig around to figure out what > the return is to be time consuming and confusing. > > Based on

Re: routine declaration line question

2018-10-12 Thread Todd Chester via perl6-users
On 10/12/18 3:47 AM, Curt Tilmes wrote: On Fri, Oct 12, 2018 at 6:08 AM Todd Chester via perl6-users mailto:perl6-us...@perl.org>> wrote: > If nothing is being returned, it should really be indicated with --> Nil > since that can enable certain optimizations.  Similarly, if

Re: routine declaration line question

2018-10-12 Thread Curt Tilmes
On Fri, Oct 12, 2018 at 6:08 AM Todd Chester via perl6-users < perl6-us...@perl.org> wrote: > > If nothing is being returned, it should really be indicated with --> Nil > > since that can enable certain optimizations. Similarly, if a routine > always > > returns true upon success, that can be

Re: routine declaration line question

2018-10-12 Thread Todd Chester via perl6-users
On 10/5/18 8:39 AM, Larry Wall wrote: On Thu, Oct 04, 2018 at 03:13:15PM -0400, Trey Harris wrote: : Right; that's what I meant by "stylistically" — a `--> Mu` can highlight : that something is being returned (and that side-effects are not the primary : purpose), while nothing indicates that

Re: Run tests only if a module is available

2018-10-12 Thread Fernando Santagata
Thank you, it's what I needed! On Fri, Oct 12, 2018 at 1:12 AM Timo Paulssen wrote: > I'd go with run-time loading and if the module doesn't exist, just "flunk" > or "skip" or what Test.pm6 offers. > > Here's a link that explains checking if a module is installed and loading > it if it is: > >