Re: need p5/p6 :: help

2018-09-15 Thread Brent Laabs
Now that Larry has spoken on the issue of vocabulary, it's lexicanonical.

On Fri, Sep 14, 2018 at 12:49 PM Larry Wall  wrote:

> On Fri, Sep 14, 2018 at 04:15:02AM -0700, Todd Chester wrote:
> : Also, did you answer my question about "::" and did it
> : just go over my head?
>
> The implication was that "::" didn't change, but the default package
> scoping of p5 that you're relying on is no longer the default in p6.
>
> : The p5 guys use to tell me "its lexiconical", meaning it was figured
> : out on the fly.  (Took me forever to catch on.)  Is that any
> : relation to your use of the word "lexical"?
>
> I would like to see a citation of this use of the word "lexiconical".
> In the first place, the word "lexiconical" has not been used in
> perl5-porters in living memory, and if had been used there, it is
> unlikely to have meant "figured out on the fly".
>
> : https://www.dictionary.com/browse/lexical?s=t
> :
> :adjective
> :
> :of or relating to the words or vocabulary of a language,
> :especially as distinguished from its grammatical and
> :syntactical aspects.
> :
> :of, relating to, or of the nature of a lexicon.
>
> The relationship of lexicons to lexical scoping here is a bit tenuous,
> but it goes something like this: Every scope in your program can define
> things local to that scope.  When a scope does define something, it's
> creating a new lexicon of terms, like a private lingo or patois for a
> given workplace that no other workplace will understand.  It is that
> set of private definitions (overlaid on all the definitions pulled in
> from larger scopes) that functions as a "dictionary" here.
>
> So when people say "lexically scoped", they mean there are multiple
> lexicons,
> and each symbol is looked in the nearest one that actually has a definition
> for the term.  The whole point of "scoping" is to decide what is near, and
> what is far.
>
> So, for instance, you may have worked in a workplace or participated
> in a forum where the local lexicon of the "p5 guys" contained the
> word "lexiconical" with some kind of idiosyncratic meaning involving
> dynamic lookup.  That term is not used in the larger p5 culture that
> way, so people outside that workplace or forum will not understand that
> idiosyncratic definition of "lexiconical", which seems to have nothing
> whatsoever to do with lexicons.
>
> Lexical scoping is not figured out on the fly; it's figured out while the
> code is compiling.  You can have delayed compilation when you eval a
> string,
> of course, but then the fact that the lexical lookups are delayed is not
> a special feature of the lexicon; everything related to the compiler is
> delayed when you eval.  "Figured out on the fly" is a feature of eval, not
> of lexicons.
>
> Now, all that being said, in p5 subroutines are looked up in packages,
> and packages are modifiable, so we do have to discover what to call "on
> the fly" in that case.  But in p5 culture we never refer to packages as
> lexicons because that would confuse people.
>
> In Perl 6 culture we never mix them up either, but we also never put subs
> into packages by default.  The reason Foo::bar notation doesn't work is
> because bar isn't in Foo anymore unless you explicitly put it there.
>
> Larry
>


Re: need p5/p6 :: help

2018-09-15 Thread Larry Wall
On Fri, Sep 14, 2018 at 06:12:15PM -0400, Vadim Belman wrote:
: Though technically this aspect was clear to me, but to settle things down in 
my mind completely: for now ordinary (not 'our') sub belongs not to the package 
object but to the block which belongs to that package. Is it correct way to 
describe things?

Mostly right.

I would not say that the block "belongs" to a package.  A block belongs
to a larger block, which belongs to a larger block, which (eventually)
belongs to a file, which functions as yet another block.  (And, in fact,
in Perl 6 the file itself belongs to its SETTING, which is a fake lexical
scope containing the whole file.)

Now, certainly, any given line of code happens to know which package is
its current default package, so in that sense a block may be associated
with one or more packages.  But there is no need for the block to take its
identity from its associated packages, since it can ignore them entirely.
What it can't ignore is its textual position.  A block's location is
its real identity, where it "belongs".

Larry


Re: need p5/p6 :: help

2018-09-14 Thread ToddAndMargo

On 09/14/2018 05:33 PM, Brad Gilbert wrote:

On Fri, Sep 14, 2018 at 7:10 PM ToddAndMargo  wrote:


On 09/14/2018 04:37 PM, Brandon Allbery wrote:


  "{$x}::{$y}"


Most of my programming before Perl 5 was bash.  I
did a lot of "${x}abc" to keep the variables
from being confused with each other.

I carried the practice over to perl 6 with
"{$x}abc" but the developers over on the chat
line told me not to do it.  I don't remember why,
(I just do everything they tell me.)

Now I just use an escape or a ~


There are some caveats using {} in a string literal

 > say "iteration: { ++$ }" xx 5
 (iteration: 1 iteration: 1 iteration: 1 iteration: 1 iteration: 1)
 > my $a; say "iteration: { ++$a }" xx 5
 (iteration: 1 iteration: 2 iteration: 3 iteration: 4 iteration: 5)

That is likely what they were talking about.

Basically these two bits of code are equivelent

 "{$x}::{$y}"

 "" ~ {$x}() ~ "::" ~ {$y}() ~ ""

So I wouldn't use {} if you can just use the variable itself.



Thank you!


Re: need p5/p6 :: help

2018-09-14 Thread Brad Gilbert
On Fri, Sep 14, 2018 at 7:10 PM ToddAndMargo  wrote:
>
> On 09/14/2018 04:37 PM, Brandon Allbery wrote:
>
> >  "{$x}::{$y}"
>
> Most of my programming before Perl 5 was bash.  I
> did a lot of "${x}abc" to keep the variables
> from being confused with each other.
>
> I carried the practice over to perl 6 with
> "{$x}abc" but the developers over on the chat
> line told me not to do it.  I don't remember why,
> (I just do everything they tell me.)
>
> Now I just use an escape or a ~

There are some caveats using {} in a string literal

> say "iteration: { ++$ }" xx 5
(iteration: 1 iteration: 1 iteration: 1 iteration: 1 iteration: 1)
> my $a; say "iteration: { ++$a }" xx 5
(iteration: 1 iteration: 2 iteration: 3 iteration: 4 iteration: 5)

That is likely what they were talking about.

Basically these two bits of code are equivelent

"{$x}::{$y}"

"" ~ {$x}() ~ "::" ~ {$y}() ~ ""

So I wouldn't use {} if you can just use the variable itself.


Re: need p5/p6 :: help

2018-09-14 Thread ToddAndMargo

On 09/14/2018 04:37 PM, Brandon Allbery wrote:


 "{$x}::{$y}"


Most of my programming before Perl 5 was bash.  I
did a lot of "${x}abc" to keep the variables
from being confused with each other.

I carried the practice over to perl 6 with
"{$x}abc" but the developers over on the chat
line told me not to do it.  I don't remember why,
(I just do everything they tell me.)

Now I just use an escape or a ~


Re: need p5/p6 :: help

2018-09-14 Thread ToddAndMargo
On Fri, Sep 14, 2018 at 7:32 PM ToddAndMargo > wrote:


What is this all about?


$ p6 'my $x="abc"; my $y="def"; say "$x::$y";'
===SORRY!=== Error while compiling -e
Malformed lookup of ::$y; please use ::('$y'), ::{'$y'}, or ::<$y>
at -e:1
--> my $x="abc"; my $y="def"; say "$x⏏::$y";

$ p6 'my $x="abc"; my $y="def"; say "$x\::$y";'
abc::def

$ p6 'say "abc::def";'
abc::def

What does the compiler think `::$y` is?

Many thanks,
-T


On 09/14/2018 04:37 PM, Brandon Allbery wrote:
It thinks it's interpolating a variable $x::... and then it gets stuck 
because it sees $y instead of the rest of a variable name. You can use 
braces to control what's part of the name:


pyanfar Z$ 6 'my $x = "abc"; my $y = "def"; say "{$x}::{$y}"'
abc::def

Otherwise, you couldn't interpolate the name of a variable $x::y in some 
other module.




Makes sense, I think.  I have just been using an escape
   $a\::$b


Re: need p5/p6 :: help

2018-09-14 Thread Brandon Allbery
It thinks it's interpolating a variable $x::... and then it gets stuck
because it sees $y instead of the rest of a variable name. You can use
braces to control what's part of the name:

pyanfar Z$ 6 'my $x = "abc"; my $y = "def"; say "{$x}::{$y}"'
abc::def

Otherwise, you couldn't interpolate the name of a variable $x::y in some
other module.


On Fri, Sep 14, 2018 at 7:32 PM ToddAndMargo  wrote:

> What is this all about?
>
>
> $ p6 'my $x="abc"; my $y="def"; say "$x::$y";'
> ===SORRY!=== Error while compiling -e
> Malformed lookup of ::$y; please use ::('$y'), ::{'$y'}, or ::<$y>
> at -e:1
> --> my $x="abc"; my $y="def"; say "$x⏏::$y";
>
> $ p6 'my $x="abc"; my $y="def"; say "$x\::$y";'
> abc::def
>
> $ p6 'say "abc::def";'
> abc::def
>
> What does the compiler think `::$y` is?
>
> Many thanks,
> -T
>


-- 
brandon s allbery kf8nh
allber...@gmail.com


Re: need p5/p6 :: help

2018-09-14 Thread ToddAndMargo

What is this all about?


$ p6 'my $x="abc"; my $y="def"; say "$x::$y";'
===SORRY!=== Error while compiling -e
Malformed lookup of ::$y; please use ::('$y'), ::{'$y'}, or ::<$y>
at -e:1
--> my $x="abc"; my $y="def"; say "$x⏏::$y";

$ p6 'my $x="abc"; my $y="def"; say "$x\::$y";'
abc::def

$ p6 'say "abc::def";'
abc::def

What does the compiler think `::$y` is?

Many thanks,
-T


Re: need p5/p6 :: help

2018-09-14 Thread ToddAndMargo

On 09/14/2018 12:49 PM, Larry Wall wrote:

On Fri, Sep 14, 2018 at 04:15:02AM -0700, Todd Chester wrote:
: Also, did you answer my question about "::" and did it
: just go over my head?

The implication was that "::" didn't change, but the default package
scoping of p5 that you're relying on is no longer the default in p6.

: The p5 guys use to tell me "its lexiconical", meaning it was figured
: out on the fly.  (Took me forever to catch on.)  Is that any
: relation to your use of the word "lexical"?

I would like to see a citation of this use of the word "lexiconical".
In the first place, the word "lexiconical" has not been used in
perl5-porters in living memory, and if had been used there, it is
unlikely to have meant "figured out on the fly".

: https://www.dictionary.com/browse/lexical?s=t
:
:adjective
:
:of or relating to the words or vocabulary of a language,
:especially as distinguished from its grammatical and
:syntactical aspects.
:
:of, relating to, or of the nature of a lexicon.

The relationship of lexicons to lexical scoping here is a bit tenuous,
but it goes something like this: Every scope in your program can define
things local to that scope.  When a scope does define something, it's
creating a new lexicon of terms, like a private lingo or patois for a
given workplace that no other workplace will understand.  It is that
set of private definitions (overlaid on all the definitions pulled in
from larger scopes) that functions as a "dictionary" here.

So when people say "lexically scoped", they mean there are multiple lexicons,
and each symbol is looked in the nearest one that actually has a definition
for the term.  The whole point of "scoping" is to decide what is near, and
what is far.

So, for instance, you may have worked in a workplace or participated
in a forum where the local lexicon of the "p5 guys" contained the
word "lexiconical" with some kind of idiosyncratic meaning involving
dynamic lookup.  That term is not used in the larger p5 culture that
way, so people outside that workplace or forum will not understand that
idiosyncratic definition of "lexiconical", which seems to have nothing
whatsoever to do with lexicons.

Lexical scoping is not figured out on the fly; it's figured out while the
code is compiling.  You can have delayed compilation when you eval a string,
of course, but then the fact that the lexical lookups are delayed is not
a special feature of the lexicon; everything related to the compiler is
delayed when you eval.  "Figured out on the fly" is a feature of eval, not
of lexicons.

Now, all that being said, in p5 subroutines are looked up in packages,
and packages are modifiable, so we do have to discover what to call "on
the fly" in that case.  But in p5 culture we never refer to packages as
lexicons because that would confuse people.

In Perl 6 culture we never mix them up either, but we also never put subs
into packages by default.  The reason Foo::bar notation doesn't work is
because bar isn't in Foo anymore unless you explicitly put it there.

Larry



Thank you!


Re: need p5/p6 :: help

2018-09-14 Thread ToddAndMargo

On 09/14/2018 12:49 PM, Larry Wall wrote:

I would like to see a citation of this use of the word "lexiconical".
In the first place, the word "lexiconical" has not been used in
perl5-porters in living memory, and if had been used there, it is
unlikely to have meant "figured out on the fly".


Hi Larry,

I did a google and duckduckgo search through
comp.lang.perl.misc for lexiconical and came up
short, except for something I wrote on the "C"
list.

At the time, those guys had my head spinning.  I
come from Modula2 and the concept of type Any
did not resonate.  They were trying to explain
how a variable could be different types, depending
on what you assigned to it.

-T


Re: need p5/p6 :: help

2018-09-14 Thread Elizabeth Mattijsen
> On 15 Sep 2018, at 00:12, Vadim Belman  wrote:
>> In Perl 6 culture we never mix them up either, but we also never put subs
>> into packages by default.  The reason Foo::bar notation doesn't work is
>> because bar isn't in Foo anymore unless you explicitly put it there.
> Though technically this aspect was clear to me, but to settle things down in 
> my mind completely: for now ordinary (not 'our') sub belongs not to the 
> package object but to the block which belongs to that package. Is it correct 
> way to describe things?

Yes.

And you can even introspect it:

{
sub foo() { }
# check out this scope’s lexpad for subroutines
.say for MY::.keys.grep: *.starts-with('&’);   # 
}
# check out outer scope’s lexpad for subroutines
say for MY::.keys.grep: *.starts-with('&’);  # nothing

Re: need p5/p6 :: help

2018-09-14 Thread Vadim Belman
> 
> In Perl 6 culture we never mix them up either, but we also never put subs
> into packages by default.  The reason Foo::bar notation doesn't work is
> because bar isn't in Foo anymore unless you explicitly put it there.
> 
> Larry
> 


Though technically this aspect was clear to me, but to settle things down in my 
mind completely: for now ordinary (not 'our') sub belongs not to the package 
object but to the block which belongs to that package. Is it correct way to 
describe things?

Best regards,
Vadim Belman


Re: need p5/p6 :: help

2018-09-14 Thread Larry Wall
On Fri, Sep 14, 2018 at 04:15:02AM -0700, Todd Chester wrote:
: Also, did you answer my question about "::" and did it
: just go over my head?

The implication was that "::" didn't change, but the default package
scoping of p5 that you're relying on is no longer the default in p6.

: The p5 guys use to tell me "its lexiconical", meaning it was figured
: out on the fly.  (Took me forever to catch on.)  Is that any
: relation to your use of the word "lexical"?

I would like to see a citation of this use of the word "lexiconical".
In the first place, the word "lexiconical" has not been used in
perl5-porters in living memory, and if had been used there, it is
unlikely to have meant "figured out on the fly".

: https://www.dictionary.com/browse/lexical?s=t
: 
:adjective
: 
:of or relating to the words or vocabulary of a language,
:especially as distinguished from its grammatical and
:syntactical aspects.
: 
:of, relating to, or of the nature of a lexicon.

The relationship of lexicons to lexical scoping here is a bit tenuous,
but it goes something like this: Every scope in your program can define
things local to that scope.  When a scope does define something, it's
creating a new lexicon of terms, like a private lingo or patois for a
given workplace that no other workplace will understand.  It is that
set of private definitions (overlaid on all the definitions pulled in
from larger scopes) that functions as a "dictionary" here.

So when people say "lexically scoped", they mean there are multiple lexicons,
and each symbol is looked in the nearest one that actually has a definition
for the term.  The whole point of "scoping" is to decide what is near, and
what is far.

So, for instance, you may have worked in a workplace or participated
in a forum where the local lexicon of the "p5 guys" contained the
word "lexiconical" with some kind of idiosyncratic meaning involving
dynamic lookup.  That term is not used in the larger p5 culture that
way, so people outside that workplace or forum will not understand that
idiosyncratic definition of "lexiconical", which seems to have nothing
whatsoever to do with lexicons.

Lexical scoping is not figured out on the fly; it's figured out while the
code is compiling.  You can have delayed compilation when you eval a string,
of course, but then the fact that the lexical lookups are delayed is not
a special feature of the lexicon; everything related to the compiler is
delayed when you eval.  "Figured out on the fly" is a feature of eval, not
of lexicons.

Now, all that being said, in p5 subroutines are looked up in packages,
and packages are modifiable, so we do have to discover what to call "on
the fly" in that case.  But in p5 culture we never refer to packages as
lexicons because that would confuse people.

In Perl 6 culture we never mix them up either, but we also never put subs
into packages by default.  The reason Foo::bar notation doesn't work is
because bar isn't in Foo anymore unless you explicitly put it there.

Larry


Re: need p5/p6 :: help

2018-09-14 Thread Brad Gilbert
lexical means it is only available within that scope,
or in sub-scopes

{
my $a;
{
$a = 42;
}
}
$a  # error

{
sub foo (){}
# my sub foo (){}  # identical
{
foo();
}
}
foo() # error

---

Note that

sub foo (){}

is really short for

my only sub foo (){}

The `only` and the `my` are implied

---

For something to be attached to a namespace
it has to be declared as `our` or `has`.

module Foo {
constant Bar = 42;
# our constant Bar = 42; # identical

our sub foo (){64} # in the namespace
}
say Foo::Bar; # 42
say Baz::foo; # 64

class Baz {
method bar (){42}
# has method bar (){42} # identical

our sub foo (){64}
}
say Baz.bar; # 42
say Baz::foo; # 64
On Fri, Sep 14, 2018 at 6:15 AM Todd Chester  wrote:
>
>  > On 14/09/2018 12:59, Todd Chester wrote:
>  >> Hi All,
>  >>
>  >> I am in the process of converting a YUGE program I wrote in
>  >> Perl 5 to Perl 6.  I used "xx::yy" at lot for readability
>  >> so I could tell where something came from.
>  >>
>  >> I take it "::" means something different is Perl 6 than Perl 5.
>  >>
>  >> $ p6 'use lib "/home/linuxutil"; use PrintColors;
>  >> PrintColors::PrintRed "Hi\n";'
>  >>
>  >> Could not find symbol ''
>  >>in block  at -e line 1
>  >>
>  >> In p5 "PrintColors::PrintRed" means to use the routine called
>  >> "PrintRed" found in a modules called "PrintColors".
>  >>
>  >> Does p6 have an equivalent?
>  >>
>  >> Many thanks,
>  >> -T
>
> On 09/14/2018 04:01 AM, Timo Paulssen wrote:
> > It's important for the PrintRed sub inside PrintColors to be declared
> > "our", otherwise it is "my" scoped, i.e. limited to the lexical extent
> > of the module file.
> >
>
> sub PrintRed   ( $Str ) is export { print color('bold'), color('red'),
> "$Str", color('reset'); }
>
> I have never understood the use of "our" in a module.
> I can't tell the difference.
>
> Also, did you answer my question about "::" and did it
> just go over my head?
>
> The p5 guys use to tell me "its lexiconical", meaning it was figured
> out on the fly.  (Took me forever to catch on.)  Is that any
> relation to your use of the word "lexical"?
>
> https://www.dictionary.com/browse/lexical?s=t
>
> adjective
>
> of or relating to the words or vocabulary of a language,
> especially as distinguished from its grammatical and
> syntactical aspects.
>
> of, relating to, or of the nature of a lexicon.
>
> -T


Re: need p5/p6 :: help

2018-09-14 Thread Todd Chester

> On 14/09/2018 12:59, Todd Chester wrote:
>> Hi All,
>>
>> I am in the process of converting a YUGE program I wrote in
>> Perl 5 to Perl 6.  I used "xx::yy" at lot for readability
>> so I could tell where something came from.
>>
>> I take it "::" means something different is Perl 6 than Perl 5.
>>
>> $ p6 'use lib "/home/linuxutil"; use PrintColors;
>> PrintColors::PrintRed "Hi\n";'
>>
>> Could not find symbol ''
>>in block  at -e line 1
>>
>> In p5 "PrintColors::PrintRed" means to use the routine called
>> "PrintRed" found in a modules called "PrintColors".
>>
>> Does p6 have an equivalent?
>>
>> Many thanks,
>> -T

On 09/14/2018 04:01 AM, Timo Paulssen wrote:

It's important for the PrintRed sub inside PrintColors to be declared
"our", otherwise it is "my" scoped, i.e. limited to the lexical extent
of the module file.



sub PrintRed   ( $Str ) is export { print color('bold'), color('red'), 
"$Str", color('reset'); }


I have never understood the use of "our" in a module.
I can't tell the difference.

Also, did you answer my question about "::" and did it
just go over my head?

The p5 guys use to tell me "its lexiconical", meaning it was figured
out on the fly.  (Took me forever to catch on.)  Is that any
relation to your use of the word "lexical"?

https://www.dictionary.com/browse/lexical?s=t

   adjective

   of or relating to the words or vocabulary of a language,
   especially as distinguished from its grammatical and
   syntactical aspects.

   of, relating to, or of the nature of a lexicon.

-T


Re: need p5/p6 :: help

2018-09-14 Thread Timo Paulssen
It's important for the PrintRed sub inside PrintColors to be declared
"our", otherwise it is "my" scoped, i.e. limited to the lexical extent
of the module file.

On 14/09/2018 12:59, Todd Chester wrote:
> Hi All,
>
> I am in the process of converting a YUGE program I wrote in
> Perl 5 to Perl 6.  I used "xx::yy" at lot for readability
> so I could tell where something came from.
>
> I take it "::" means something different is Perl 6 than Perl 5.
>
> $ p6 'use lib "/home/linuxutil"; use PrintColors;
> PrintColors::PrintRed "Hi\n";'
>
> Could not find symbol ''
>   in block  at -e line 1
>
> In p5 "PrintColors::PrintRed" means to use the routine called
> "PrintRed" found in a modules called "PrintColors".
>
> Does p6 have an equivalent?
>
> Many thanks,
> -T