Front page | perl.perl6.users |
Postings from September 2017
Re: :: question
September 14, 2017 05:55
Re: :: question
Message ID: firstname.lastname@example.org
On 09/13/2017 10:48 PM, Brandon Allbery wrote:
> On Thu, Sep 14, 2017 at 1:42 AM, ToddAndMargo <ToddAndMargo@zoho.com
> <mailto:ToddAndMargo@zoho.com>> wrote:
> On 09/13/2017 10:26 PM, Brandon Allbery wrote:
> On Thu, Sep 14, 2017 at 12:46 AM, ToddAndMargo
> <ToddAndMargo@zoho.com <mailto:ToddAndMargo@zoho.com>
> <mailto:ToddAndMargo@zoho.com <mailto:ToddAndMargo@zoho.com>>>
> What is the Perl6 equivalent of the perl 5 "::"?
> $Found = CheckSystemDependancy::Which ( $ProgramName,
> $HowToExit );
> It's the same... but unlike Perl 5, there is a difference
> between subs and methods, and subs are lexical by default (that
> is, they behave as if defined "my sub ..." --- which syntax is
> legal in Perl 6 (and I think in sufficiently recent perl 5 if
> you specify a minimum version in your script)). For a sub to be
> callable that way, it must explicitly be defined as "our sub ...".
> Although you will run into another issue because you have
> whitespace before the "(", so it will be called with one
> parameter that is a 2-element list.
> 8: use CheckSystemDependancy; # qw[ Which ];
> 35: #$Found = Which( $ProgramName, $HowToExit );
> 36: $Found = CheckSystemDependancy::Which( $ProgramName, $HowToExit );
> $ CheckSystemDependancy.pl6 ls live
> Could not find symbol '&Which'
> in block <unit> at ./CheckSystemDependancy.pl6 line 36
> Line 35 works, but line 36 does not.
> Okay, I guess I have to figure out how to rephrase my explanation.
> If you do 'use CheckSystemDependency qw[ Which ]' then you are asking
> for the bare name 'Which' to be imported into your local module's
> namespace. Only this bare name is imported, and only into your module.
You missed the comment mark
use CheckSystemDependancy; # qw[ Which ];
Does that change your analysis?
> If you want to use the other way, the CheckSystemDependency module MUST
> define Which as: our sub Which ...
> If it is not explicitly declared "our", then it is declared "my" and the
> only way the name can be seen outside the CheckSystemDependency module
> is for it to be exported and for your module to import it.
> You cannot simply call any sub you see in a different module. If it is
> not explicitly declared "our" then you cannot access it; it is declared
> locally to that module and cannot be seen anywhere else.
I am confused. `CheckSystemDependancy::Which` does not work in P6?
I am confused as to the syntax