Re: run "...", :out forgetting about the exit code?

2016-02-03 Thread Siavash

Nitpick: 'use strict' is the default.

On 2016-02-03 03:07:18 IRST, Peter Pentchev wrote:
> [roam@straylight ~]$ perl6 -e 'use v6.c; use strict; my $p = run "false"; say 
> $p.exitcode;'


Re: Finding and fixing Perl 6 bugs

2016-02-03 Thread Siavash

On 2016-02-03 06:47:23 IRST, Tom Browder wrote:
> Perl 5 (and I believe 6) uses the weird (to me) rt.perl.org bug system and
> I have so far found no instructions on how to use it.  There is the program
> perlbug for Perl 5 but no reference I can find on using it for Perl 6.  I
> have an account on rt.perl.bug but cannot find anything other than my
> non-existent entries.  There is a public interface so ordinary users can
> see bugs but apparently not do anything about it.

For Rakudo bugs send an email to rakudo...@perl.org
http://rakudo.org/how-to-help/

> The various Perl 6 git repos all have their own issue trackers but so far I
> find no similarity between issue numbers on git and git bug report
> e-mails.  For example,  see those for the ecosystem.  Git shows 2 issues
> open with #136 and #53, but e-mails show something else.

For anything other than Rakudo you can open an issue on GitHub.
https://github.com/perl6

The other issue numbers you mentioned are probably pull requests. For example,
https://github.com/perl6/ecosystem/pulls?q=is%3Apr+is%3Aclosed


Re: importing code

2016-03-11 Thread Siavash

To specify the name indirectly:

my $m = 'some-module';
require ::($m);

On 2016-03-11 11:17:44 IRST, mt1957 wrote:
> Op 10-03-16 om 20:14 schreef yary:
>> There's "require" to load a module at runtime
>>
>> http://docs.perl6.org/syntax/require
>>
>> The $*REPO object controls how to search for modules,
>> http://docs.perl6.org/language/5to6-perlvar mentions it. I don't know
>> much more than that,
> Thanks for your answer,
>
> I've played a little with require in REPL but there is a problem
>
> I would like to do the following...
>
>  > my $m = 'some-module';
>  > require $m;
> Could not find 'some-documnt' in:
>  /home/marcel
>  /home/marcel/lib
>  /home/marcel/.perl6/2016.02-95-g2f78f05
>  /home/marcel/Software/perl6/rakudo/install/share/perl6/site
>  /home/marcel/Software/perl6/rakudo/install/share/perl6/vendor
>  /home/marcel/Software/perl6/rakudo/install/share/perl6
>  CompUnit::Repository::AbsolutePath<74011248>
>  CompUnit::Repository::NQP<72611240>
>  CompUnit::Repository::Perl5<72611280>
>
> while directly used it works
>
>  > require some-module;
>  >
>
> Do you think it's a bug. If so I'll write this also to rakudo-bug.
>
> Marcel



Re: testing with a "warn"

2016-04-30 Thread Siavash

http://doc.perl6.org/routine/warn
"To simply print to $*ERR, please use note instead. warn should be
reserved for use in threatening situations when you don't quite want to
throw an exception."

And for testing, maybe something like this:
use Test;
my $warning;
{
warn 'some warning';
CONTROL {
when CX::Warn {
$warning = .message;
}
}
}
is $warning, 'some warning';

On 2016-04-30 09:07:24 IRDT, rnhainsworth wrote:
> Hi. Sorry to ask again, but there are two independent questions here. 1) What 
> is the purpose or best use of 'warn'. 2) How to test code that contains a 
> 'warn' used as it should be.
> 1) I thought that a 'warn' would be used where sometimes the user would want 
> a fail but not always. I have a module that in normal use I want to continue 
> even if there is a bad condition which has a default action, but that I can 
> get to fail if I set an external flag. Maybe I'm wrong. But this is not the 
> question I originally asked.
> 2) whatever may be the purpose of a warn, and I assume there is a good one 
> since its in core perl6, surely the code that contains it should be tested, 
> which means triggering the condition and picking up the warning. I can't work 
> out how to do this. Can't get Test::Output to pick up the message sent to 
> stderr from warn.
> Regards
>
>
>  Original message From: Larry Wall  Date: 
> 30/04/2016  06:45  (GMT+08:00) To: Brandon Allbery  Cc: 
> Timo Paulssen , perl6-users  Subject: 
> Re: testing with a "warn" 
> On Fri, Apr 29, 2016 at 03:50:21PM -0400, Brandon Allbery wrote:
> : On Fri, Apr 29, 2016 at 3:47 PM, Brandon Allbery 
> : wrote:
> : > Oh, they are resumable exceptions? Useful but rather high cost I'd think.
> : > (Granting that perl6 isn't one of those languages that think exceptions
> : > should be normal control flow. But anyone who decides it should be is
> : > probably in for a very slow slog.)
>
> Warnings are implemented like return or next; control exceptions are
> more efficient than error exceptions. (This is one of the reasons you
> have to catch them with a CONTROL block rather than a CATCH block.)
>
> : ...also I now know that I should not use warn in many cases where I would
> : have otherwise.
>
> If you need to produce actual warnings in hot code, something's wrong
> with your design. (If you just want to print to STDERR, you can use
> 'note' instead.)
>
> Larry



Re: perl 6 equivalent of "use warnings"

2017-01-11 Thread Siavash

Hi,

>From https://docs.perl6.org/language/5to6-nutshell#warnings

"Warnings are now on by default.

no warnings is currently NYI, but putting things in a quietly {} block will 
silence."

On 2017-01-12 03:42:22 GMT, ToddAndMargo wrote:
> Hi All,
>
>  Is there a perl 6 equivalent of perl 5's "use warnings"?
>
> Many thanks,
> -T


Re: Need dynamic variables help

2017-01-13 Thread Siavash

Hi,

`+` is addition operator:
https://docs.perl6.org/routine/$PLUS_SIGN#(Operators)_infix_+

String concatenation operator is `~`:
https://docs.perl6.org/routine/$TILDE#(Operators)_infix_~

So you should write:
print "Perl Version = " ~ $*PERL ~ "\n";

Or use `say` or `put` to add a newline:
say "Perl Version = $*PERL";

So for your commented line, you can write:
say "Display = %*ENV"

On 2017-01-13 09:01:32 GMT, Todd Chester wrote:
> Hi All,
>
> I am trying to understand how to read variables from the
> shell's environment.  I am reading this:
>
> https://docs.perl6.org/language/variables#Dynamic_variables
>
> 
> #!/usr/bin/perl6
> # print "Display = " + %*ENV{'DISPALY'} + "\n";
> print "Perl Version = " + $*PERL + "\n";
> 
>
>
> $ ./env.pl6
> Cannot resolve caller Numeric(Perl: ); none of these signatures match:
>  (Mu:U \v: *%_)
>in block  at ./env.pl6 line 3
>
>
> What am I missing?  I'd like to get the one I commented
> out on line 2 working too.  That gives me the following error:
>
> Use of uninitialized value of type Any in numeric context
>in block  at ./env.pl6 line 2
> Cannot convert string to number: base-10 number must begin with valid 
> digits or '.' in '⏏Display = ' (indicated by ⏏)
>in block  at ./env.pl6 line 2
>
>
> Many thanks,
> -T


Re: Need dynamic variables help

2017-01-13 Thread Siavash

But in Perl 5 `.` is string concatenation operator, not `+`

On 2017-01-13 09:33:10 GMT, Todd Chester wrote:
>>
>> On Fri, Jan 13, 2017 at 10:01 AM, Todd Chester > > wrote:
>>
>> Hi All,
>>
>> I am trying to understand how to read variables from the
>> shell's environment.  I am reading this:
>>
>> https://docs.perl6.org/language/variables#Dynamic_variables
>> 
>>
>> 
>> #!/usr/bin/perl6
>> # print "Display = " + %*ENV{'DISPALY'} + "\n";
>> print "Perl Version = " + $*PERL + "\n";
>> 
>>
>>
>> $ ./env.pl6
>> Cannot resolve caller Numeric(Perl: ); none of these signatures match:
>> (Mu:U \v: *%_)
>>   in block  at ./env.pl6 line 3
>>
>>
>> What am I missing?  I'd like to get the one I commented
>> out on line 2 working too.  That gives me the following error:
>>
>> Use of uninitialized value of type Any in numeric context
>>   in block  at ./env.pl6 line 2
>> Cannot convert string to number: base-10 number must begin with
>> valid digits or '.' in '⏏Display = ' (indicated by ⏏)
>>   in block  at ./env.pl6 line 2
>>
>>
>> Many thanks,
>> -T
>>
>>
>>
>>
>> -- 
>> Fernando Santagata
>
> On 01/13/2017 01:20 AM, Fernando Santagata wrote:
>> Try:
>>
>> print "Perl Version = " ~ $*PERL ~ "\n";
>>
>> or better:
>>
>> say "Perl Version = $*PERL";
>>
>> OTH
>
>
> Hi Fernando,
>
> That fixed it.  I was using Perl5's string concatenation.  Will "~"
> always replace "+" for this, or only with a dynamic variable?
>
> On line two, I misspelled "DISPLAY".
>
> 
> #!/usr/bin/perl6
> print "Display = " ~ %*ENV{'DISPLAY'} ~ "\n";
> print "Perl Version = " ~ $*PERL ~ "\n";
> 
>
> ./env.pl6
> Display = :0.0
> Perl Version = Perl 6
>
>
> Thank you!
> -T


Re: Array containing only elements that implement a role.

2017-01-03 Thread Siavash

Hi,

It's because of the default value of array elements. See the end of this
section: https://docs.perl6.org/language/list#Typing

my @a;
say @a.of.perl; # Mu
say @a.default.perl; # Any
say @a[0]; # (Any)

role Foo {};
my Foo @a;
say @a.of.perl; # Foo
say @a.default.perl; # Foo
say @a[0] # (Foo)

On 2017-01-03 10:59:34 GMT, Martin Barth wrote:
> Hi There,
>
> I am not sure if my RoleType @array; is correct, or if there is a better 
> way to declare such an array. But I find the error that is happening 
> when there are no elements in the array confusing on the first sight. It 
> took me a while to realize that my array was empty and therefore it 
> "means" the class/role itself.
>
>
>  > perl6 -e 'role Foo {method n{...}}; class Bar does Foo {method 
> n{"n"}}; my Foo@a = (); @a.push: Bar.new; say @a[0].n'
> n
>
>  > perl6 -e 'role Foo {method n{...}}; class Bar does Foo {method 
> n{"n"}}; my Foo@a = (); say @a[0].n'
> Method 'n' must be implemented by Foo because it is required by a role
>in any compose_method_table at gen/moar/m-Metamodel.nqp line 2824
>in any apply at gen/moar/m-Metamodel.nqp line 2834
>in any compose at gen/moar/m-Metamodel.nqp line 3006
>in any make_pun at gen/moar/m-Metamodel.nqp line 1692
>in any find_method at gen/moar/m-Metamodel.nqp line 1720
>in block  at -e line 1
>
>  > perl6 -e 'role Foo {method n{...}}; class Bar does Foo {method 
> n{"n"}}; my @a = (); say @a[0].n'
> No such method 'n' for invocant of type 'Any'
>in block  at -e line 1



Re: A stricter typed variable

2017-01-07 Thread Siavash

Hi,

If you really want to avoid `Array[Str].new`, you can do something like
this:

sub foo (@a where .all ~~ Str) {...}

On 2017-01-07 11:45:55 GMT, Fernando Santagata wrote:
> Hello,
>
> I have a function like this:
>
> sub test(Str :$format, :@filter)
> {
>   say $format;
>   say @filter;
> }
>
> and I wish to have a stricter type control over the second parameter.
>
> The natural way to do it seemed this:
>
> sub test(Str :$format, Array[Str] :$filter)
> {
>   say $format;
>   say $filter;
> }
>
> but then I have to call it this way:
>
> test format => 'gnutar', filter => Array[Str].new('gzip', 'uuencode');
>
> Is there a less cumbersome way to do it?
>
> Obviously this doesn't work:
>
> test format => 'gnutar', filter => ;
>
> because the argument is interpreted as a generic List.
> This doesn't work either:
>
> test format => 'gnutar', filter => ['gzip', 'uuencode'];
>
> because it's interpreted as a generic Array, not an Array[Str].
>
> Thank you!



Re: A stricter typed variable

2017-01-08 Thread Siavash

Note that you can also use subset to create a type:

subset ArrayOfStr of Array where .all ~~ Str;

sub foo (@a where ArrayOfStr) {...}

or:

sub foo (ArrayOfStr $a) {...}


On 2017-01-08 10:33:36 GMT, Fernando Santagata wrote:
> Thank you!
>
> On Sat, Jan 7, 2017 at 5:23 PM, Siavash <siavash.askari.n...@gmail.com>
> wrote:
>
>>
>> Hi,
>>
>> If you really want to avoid `Array[Str].new`, you can do something like
>> this:
>>
>> sub foo (@a where .all ~~ Str) {...}
>>
>> On 2017-01-07 11:45:55 GMT, Fernando Santagata wrote:
>> > Hello,
>> >
>> > I have a function like this:
>> >
>> > sub test(Str :$format, :@filter)
>> > {
>> >   say $format;
>> >   say @filter;
>> > }
>> >
>> > and I wish to have a stricter type control over the second parameter.
>> >
>> > The natural way to do it seemed this:
>> >
>> > sub test(Str :$format, Array[Str] :$filter)
>> > {
>> >   say $format;
>> >   say $filter;
>> > }
>> >
>> > but then I have to call it this way:
>> >
>> > test format => 'gnutar', filter => Array[Str].new('gzip', 'uuencode');
>> >
>> > Is there a less cumbersome way to do it?
>> >
>> > Obviously this doesn't work:
>> >
>> > test format => 'gnutar', filter => ;
>> >
>> > because the argument is interpreted as a generic List.
>> > This doesn't work either:
>> >
>> > test format => 'gnutar', filter => ['gzip', 'uuencode'];
>> >
>> > because it's interpreted as a generic Array, not an Array[Str].
>> >
>> > Thank you!
>>
>>


Re: lazy gather?

2017-03-14 Thread Siavash

Note that you can also use a map:

my \approx= fib.rotor(2 => -1).map: { .[1] ÷ .[0] };

On 2017-03-14 09:00:34 GMT, Marc Chantreux wrote:
> On Mon, Mar 13, 2017 at 08:33:05PM +0330, Siavash wrote:
>> I may be wrong, but I think the code should be:
>> my \golden= (1 + sqrt 5) ÷ 2;
>> my \fib   = 1, 1, * + * ... ∞ ;
>> my \approx= gather for fib.rotor(2 => -1) { take .[1] ÷ .[0] };
>> my \distances = approx.map: (golden - *).abs;
>> say distances[^1000];
>
> excellent! i updated my perl6 and tested this code and it works well!
> thank you everyone.


Re: lazy gather?

2017-03-13 Thread Siavash

Hi,

「gather」 should work. What version of Perl 6 are you using? (run perl6 -v)

I may be wrong, but I think the code should be:

my \golden= (1 + sqrt 5) ÷ 2;
my \fib   = 1, 1, * + * ... ∞ ;
my \approx= gather for fib.rotor(2 => -1) { take .[1] ÷ .[0] };
my \distances = approx.map: (golden - *).abs;
say distances[^1000];

On 2017-03-13 13:28:24 GMT, Marc Chantreux wrote:
> hello,
>
> i saw a math show with my son and we tried to use perl6
>
> * to demonstrate the fact that the ratio between the terms
>   n and n-1 in the fibonnaci sequence gets closer to the golden number
>
> * let him know how awesome is perl6
>
> so i wrote
>
> my \golden= ( 1 / sqrt 5 ) / 2;
> my \fib   = ( 1, 1, * + * ... * );
> my \approx= (gather for fib -> $a, $b { take $a / $b });
> my \distances = approx.map(  abs golden - * );
> say [>=] distances[^1000];
>
> and it didn't work: i had to rewrite
>
>   my \distances = approx.map(  abs golden - * );
>
> to
>
>   my \distances = approx.map({ abs golden - $_ });
>
> which is not so appealing.
>
> then my programs starts to burn cpu and gets nothing. this is because it
> seems that gather isn't on demand so i moved the subscript [^1000]. this
> works but isn't intellectually right anymore.
>
> any idea to make it more appealing ?
>
> regards


Re: What is my sub?

2018-05-22 Thread Siavash

https://www.nntp.perl.org/group/perl.perl6.users/2017/03/msg3423.html

On 2018-05-22 06:04:47 GMT, ToddAndMargo wrote:
> Hi All,
>
> I need to know the name of the subroutine I am in.
>
> This is the way I use to do it in Perl 5:
>
>  (my $Name = (caller(0))[3] ) ~~ s{.*::}{};
>
> How do I do it in Perl 6?
>
> Many thanks,
> -T


Re: How to accomplish a method interpolation?

2017-12-30 Thread Siavash

What you want is `%items{$item}."$attr"()`.

But if all you want is removing the show's repetition, maybe there are
other ways, for example:

for %!items:kv {
say $^key.tc, ' ', $^value.amount;
}

or if you want all items:

for %!items {
say .key.tc, ' ', .value.amount;
}

On 2017-12-30 05:13:43 GMT, clasclin . wrote:
> I'm reading a book "Make your own python text adventure" and decided to
> give it a try with perl6. So this code works as expected.
>
> class Bag {
> has %.items;
>
> method show {
> say "ropa ", %!items.amount
> if %!items:exists;
> say "femur ", %!items.amount
> if %!items:exists;
> say "fósforos ", %!items.amount
> if %!items:exists;
> }
> }
>
> I'm using a class called bag as my inventory and trying to keep track of
> items in a hash, so the key is just a name and the value is an object and
> just found that a pattern when I try to list the elements on the screen...
>
> dd %!items
> Hash %!items = {:femur(Items::Femur.new(amount => 1)),
> :fósforos(Items::Matches.new(amount => 3)), :ropa(Items::Cloth.new(amount
> => 4))}
>
> Items has data and the show method does what I expect, then I change the
> code, so I try to add a private method that handdle the pattern and change
> the show method to use the private one.
>
> class Bag {
> has %.items;
>
> method !show-item ($msg, $item, $attr) {
> # dd $msg; dd $item; dd $attr; # all Str
> say "$msg ", %items{$item}.$attr
> if %!items{$item}:exists;
> }
>
> method show {
>  self!show-item('Ropa', 'ropa', 'amount');
>  ...
>  }
> }
>
> Now I get an error, the line corresponds to the private method
> No such method 'CALL-ME' for invocant of type 'Str'
>
> Try a few variants like return instead of say or things like
> say "$msg", "%!items{$item}.$attr"; # output: Ropa
> Items::Cloth<94810994868552>.amount
> say "$msg", $!items{$item}.{$attr}; # output: Type Items::Cloth does
> not support associative indexing.
> say "$msg", %!items{$item}."{$attr}"; # ouput: gives a compile error
>
> The output I'm expecting is: Ropa 4
> Ropa is the $msg, and 4 corresponds to the value in the attribute amount.
>
> Is there a way to refactor my code? Thanks in advance.


Re: What does ^parents really tell you?

2018-07-31 Thread Siavash


"Returns the list of parent classes. By default it stops at Cool, Any or Mu, 
which you can suppress by supplying the :all adverb. With :tree, a nested list 
is returned."
https://docs.perl6.org/routine/parents

On 2018-07-29 21:57:21 +0430, Joseph Brenner wrote:
> If you look at the type diagram:
>
>   https://docs.perl6.org/type/Str#___top
>
> You can see that:
>Str is Cool is Any is Mu
>
> But if you use the ^parents method on a string, you don't get
> "Cool", instead you get "()":
>
>my $stringy = "abc";
>say $stringy.^name;  # Str
>say $stringy.^parents;   # ()
>
>say (Str).^parents;  # ()
>
> So what exactly does ^parents tell you about?
> Is there some other method you could use to trace the chain
> of ancestors upwards?


Re: What does ^methods really tell you?

2018-07-31 Thread Siavash


"Returns a list of public methods available on the class (which includes 
methods from superclasses and roles). By default this stops at the classes 
Cool, Any or Mu; to really get all methods, use the :all adverb. If :local is 
set, only methods declared directly in the class are returned."
https://docs.perl6.org/routine/methods

On 2018-07-31 06:56:07 +0430, Joseph Brenner wrote:
> I originally thought that $var.^methods gave you a list of all
> available methods on $var, but it looks like it doesn't (always?)
> report on inherited methods.
>
> my $stringy = '3.14159';
> say $stringy.^name;
>   # Str
> say $stringy.^mro;
>   # ((Str) (Cool) (Any) (Mu))
>
> The list returned from checking $stringy is the same as just
> checking (Str):
>
>   $stringy.^methods
>   (Str).^methods
>
> And it includes none of the (Cool) methods:
>
>   (Cool).^methods
>
> For example, trig functions like "cos" are part of the (Cool)
> list, but are not in the $stringy.^methods list, though you can
> call clearly them:
>
>   say $stringy.cos
>   -0.99964793
>
> I guess this seems to work to give you the full list of available
> methods:
>
>   $stringy.^methods(:all)


Re: Using HashBags

2018-04-07 Thread Siavash

Hi,

Don't know if there is a better way, but assuming you don't have control
over the data, you can do this:

my Bag $docents = @rows.map(*.pairup).Bag;

On 2018-04-07 10:10:52 GMT, mimosinnet wrote:
> Hi all,
>
> I do not seem to be able to get this done with the Bag or BagHash
> type:
>
> ---
> dd @rows;
>
>> Output: Array @rows = [["JF", 1], ["JF", 2], ["MM", 2], ["MPu", 2],
>> ["MM", 2], ["FE", 2], ["FV", 2], ["MPu", 2], ["JP", 2], ["JP", 2],
>> ["FV", 2], ["FV", 2], ["JF", 2], ["MM", 2], ["MPu", 2], ["MM", 2],
>> ["FE", 2], ["FV", 2], ["MPu", 2], ["JP", 2], ["JP", 2], ["JF", 4]]
>
> my %docents;
> for @rows -> @row {
>   %docents{ @row[0] } += @row[1];
> }
>
> dd %docents;
>
>> Output: Hash %docents = {:FE(4), :FV(8), :JF(9), :JP(8), :MM(8),
>> :MPu(8)}
>
> ---
>
> As I understand it, this would better be achieved with the Bag or
> BagHash type. What would be the easy way?
>
> Thanks! 


Re: latest rakudo srtar not found

2018-04-16 Thread Siavash

>From https://rakudo.org/files/star/windows:
"Installer for the [32-bit Rakudo Star](https://rakudo.org/latest/star/win32) 
is available, but is severely outdated. You may wish to attempt to [build from 
source](https://rakudo.org/files/star/source) instead."

On 2018-04-16 16:06:11 GMT, ToddAndMargo wrote:
>>> Hi,
>>>
>>> I was used to download the latest rakudo star install file for testing
>>> on appveyor using url
>>> http://rakudo.org/downloads/star/rakudo-star-latest-x86_64
>>> (JIT).msi. Messages returned are
>>>
>>> Error downloading remote file: One or more errors occurred.
>>> Inner Exception: Remote server returned 404: Not Found
>>>
>>> Is the file stored at another location perhaps?
>>>
>>> Regards
>
>
>>> MarcelOn 04/16/2018 08:02 AM, Siavash wrote:
>>
>> Hi,
>>
>> Rakudo.org was redesigned, apparently the new URL for you is:
>> https://rakudo.org/latest/star/win64
>>
>> The new download page:
>> https://rakudo.org/files
>>
>> On 2018-04-16 09:18:13 GMT, Marcel Timmerman wrote:
>
> no 32 bit Windows?


Re: latest rakudo srtar not found

2018-04-16 Thread Siavash

Hi,

Rakudo.org was redesigned, apparently the new URL for you is:
https://rakudo.org/latest/star/win64

The new download page:
https://rakudo.org/files

On 2018-04-16 09:18:13 GMT, Marcel Timmerman wrote:
> Hi,
>
> I was used to download the latest rakudo star install file for testing
> on appveyor using url
> http://rakudo.org/downloads/star/rakudo-star-latest-x86_64
> (JIT).msi. Messages returned are
>
> Error downloading remote file: One or more errors occurred.
> Inner Exception: Remote server returned 404: Not Found
>
> Is the file stored at another location perhaps?
>
> Regards
> Marcel


Re: Strange output on 'say Foo::Bar::<>;'

2018-10-11 Thread Siavash
Maybe someone with better knowledge can answer. But I guess ;; is 
https://docs.perl6.org/type/Signature#Long_names

The #`() part is a comment(inline).

And the number is what WHICH returns.
https://docs.perl6.org/routine/WHICH

On October 11, 2018 7:13:41 PM GMT+03:30, Richard Hogaboom 
 wrote:
>OK .. I mistakenly assumed that it should not compile from the doc 
>'(This does not work with the  variable)'.
>
>my $tmp = Foo::Bar::<>;
>say $tmp();  # zipi - works
>
>if ';; $_? is raw' is the signature, what does the ';;' mean and what 
>does '#`(Block|62717656) ...' mean?
>
>
>On 10/11/18 9:45 AM, Siavash wrote:
>> It means it's returning a Block.
>>
>> dd Foo::Bar::<> # Block  = -> ;; $_? is raw {
>#`(Block|94777643161752) ... }
>> say Foo::Bar::<>() # zipi
>
>-- 
>Richard A Hogaboom
>16 Alprilla Farm Road
>Hopkinton, MA 01748-1922
>richard.hogab...@gmail.com
>www.linkedin.com/in/richardhogaboom/
>https://github.com/rahogaboom
>M508-330-3775


Re: Could this be any more obscure?

2018-10-01 Thread Siavash


You can read the thread here:
https://www.nntp.perl.org/group/perl.perl6.users/2018/09/msg5757.html

On 2018-10-01 04:21:43 +0330, ToddAndMargo wrote:
> Hi All,
>
> My "Perl" box got corrupted and in the process of rebuilding
> it I lost this thread except for one one message from JJ.
> Anyway, I am not deliberately ignoring anyone, I just
> lost the thread.
>
> :'(
>
> -T


Re: Strange output on 'say Foo::Bar::<>;'

2018-10-11 Thread Siavash


It means it's returning a Block.

dd Foo::Bar::<> # Block  = -> ;; $_? is raw { 
#`(Block|94777643161752) ... }
say Foo::Bar::<>() # zipi


Re: Could this be any more obscure?

2018-09-30 Thread Siavash


On 2018-09-30 13:01:32 +0330, ToddAndMargo wrote:
> On 9/26/18 7:27 PM, Brandon Allbery wrote:
>> And again: this is only because you know perl 5. People are not born
>> knowing perl 5; to someone who doesn't know it, perldoc raises the
>> same kinds of questions you have been asking, and the answers have
>> to be found in perlsyn or perldata, etc. Which is exactly what you
>> have been complaining about with respect to perl 6 doing the same
>> kind of thing.
>
> Geez Louise Bradley!  The above is a really bad argument!
>
> "perldocs -f xxx" is a bazillion times easier to understand
> than Perl 6's manual, regardless if you know Perl 5 or not.
>
> And, by the way, I wonder just how may are coming to Perl 6
> without ANY Perl 5 experience?
>
> In every instance I can look up, perldocs puts Perl 6's
> documentation to shame.
>
> A simple comparison: which one leaves you knowing how to use
> the function and which one leaves you wondering "What the h***???"
>
> $ perldoc -f join
> join EXPR,LIST
> Joins the separate strings of LIST into a single string with
> fields separated by the value of EXPR, and returns that new
> string. Example:
>
>my $rec = join(':',
> $login,$passwd,$uid,$gid,$gcos,$home,$shell);
>
> Beware that unlike "split", "join" doesn't take a pattern
> as its first argument. Compare "split".
>
>
>
> https://docs.perl6.org/routine/join#(List)_routine_join
>
> (List) routine join
>
> Defined as:
>
> subjoin($separator, *@list --> Str:D)
> method join(List:D: $separator --> Str:D)
>
> Treats the elements of the list as strings, interleaves
> them with $separator and concatenates everything into a
> single string.
>
> Example:
>
> join ', ', ; # RESULT: «a, b, c»
>
> Note that the method form does not flatten sublists:
>
> say (1, ).join('|'); # OUTPUT: «1|a b c␤»
>

I actually found the Perl 6 description more readable. And the example
is better too.

But I think the example should show the slurpy part too. (join ', ', 1, 2, 3)

>
> Oh and what the &*@% is a "*@list"?

It seems you want to read a signature without learning how signatures
work.
https://docs.perl6.org/type/Signature#Slurpy_%28A.K.A._variadic%29_parameters

> And why does the sub have one
> and the method does not?  They are suppose to be identical.
>
> -T

Because one is a method and the other is a sub. Look at "List:D:".
And they are not identical, the last example showed the difference.

People have suggested you to try a book and you have disagreed. But to
me it looks like you are reading different chapters of a book different
people are writing for you on the mailing list.


Re: Could this be any more obscure?

2018-09-30 Thread Siavash


In the second line of my reply I was referring to the difference in
flattening.

In the first line I was saying that sub takes a list, but method
doesn't, its invocant is a list.


On 2018-09-30 14:18:53 +0330, ToddAndMargo wrote:
> On 9/30/18 3:02 AM, Siavash wrote:
>> Because one is a method and the other is a sub. Look at "List:D:".
>> And they are not identical, the last example showed the difference.
>
> The sub sure seems like it slurps to me.
>
> $ p6 'join( ", ", 1, 2, 3).say;'
> 1, 2, 3
>
> What am I missing?