Re: mixin syntax: does vs but

2018-06-12 Thread Timo Paulssen
You can override WHAT with a method, you just have to use a syntax
that's not literally .WHAT, like this:

    class Test { method WHAT() { say "i'm here" } }; Test."WHAT"();
    # → i'm here


Re: mixin syntax: does vs but

2018-06-12 Thread JJ Merelo
Ah, OK, you didn't mean override WHAT itself, but get an ersatz what in
some other way. Got it. Thanks.

El mar., 12 jun. 2018 a las 21:32, Brad Gilbert ()
escribió:

> On Tue, Jun 12, 2018 at 2:16 PM, JJ Merelo  wrote:
> > This is what the documentation says: https://docs.perl6.org/syntax/WHAT
> > You can override it, but we'll pay no attention anyway, basically. So you
> > can't achieve it otherwise, I guess.
>
> It is easy to achieve.
>
> sub user-made-what ( ::Type ) { Type }
>
> say 42. # says (Int)
>
> >
> > El mar., 12 jun. 2018 a las 21:14, JJ Merelo ()
> > escribió:
> >>
> >>
> >>
> >> El mar., 12 jun. 2018 a las 21:11, Brandon Allbery (<
> allber...@gmail.com>)
> >> escribió:
> >>>
> >>> I should clarify this, but I'm not recalling full details at the moment
> >>> which is why I didn't originally.
> >>>
> >>> Perl uses a metaobject protocol (MOP, which you'll see in various
> places
> >>> in the docs). The "macro" to access the metaobject is the .HOW
> >>> pseudo-method. If you do this for a normal class or object of that
> class,
> >>> you get Perl6::Metamodel::ClassHOW back. This is what the .^method
> syntax is
> >>> accessing; it's short for (thing).HOW.method((thing), ...). The
> metaclass
> >>> doesn't magically know its children, so the object has to be used once
> to
> >>> get at its metaclass and a second time to tell the metaclass what it
> is to
> >>> introspect.
> >>>
> >>> I'm not seeing documentation for what .WHAT actually does; it
> (correctly)
> >>> notes that it's implemented specially within the compiler (hence
> "macro")
> >>> but not how you achieve it otherwise. Then again, .HOW has the same
> issue;
> >>> there's a bit of a bootstrapping issue with getting at the metamodel,
> you
> >>> need to have it first. Which is why it's wired into the compiler and
> gets
> >>> those uppercase pseudo-method names.
> >>
> >>
> >> All the metamodel is not exactly part of the language; it's part of the
> >> compiler. So it's in the gray NOT-SPECCED zone regarding documentation
> of
> >> "Perl 6" the language, as oposed to "Perl 6, the implementation by
> Rakudo".
> >> But it's a gray zone and sometimes you fall short of documenting things
> like
> >> WHAT. I'll see what we can in that area.
> >>
> >> JJ
> >>
> >
> >
> > --
> > JJ
>


-- 
JJ


Re: mixin syntax: does vs but

2018-06-12 Thread Brad Gilbert
On Tue, Jun 12, 2018 at 2:16 PM, JJ Merelo  wrote:
> This is what the documentation says: https://docs.perl6.org/syntax/WHAT
> You can override it, but we'll pay no attention anyway, basically. So you
> can't achieve it otherwise, I guess.

It is easy to achieve.

sub user-made-what ( ::Type ) { Type }

say 42. # says (Int)

>
> El mar., 12 jun. 2018 a las 21:14, JJ Merelo ()
> escribió:
>>
>>
>>
>> El mar., 12 jun. 2018 a las 21:11, Brandon Allbery ()
>> escribió:
>>>
>>> I should clarify this, but I'm not recalling full details at the moment
>>> which is why I didn't originally.
>>>
>>> Perl uses a metaobject protocol (MOP, which you'll see in various places
>>> in the docs). The "macro" to access the metaobject is the .HOW
>>> pseudo-method. If you do this for a normal class or object of that class,
>>> you get Perl6::Metamodel::ClassHOW back. This is what the .^method syntax is
>>> accessing; it's short for (thing).HOW.method((thing), ...). The metaclass
>>> doesn't magically know its children, so the object has to be used once to
>>> get at its metaclass and a second time to tell the metaclass what it is to
>>> introspect.
>>>
>>> I'm not seeing documentation for what .WHAT actually does; it (correctly)
>>> notes that it's implemented specially within the compiler (hence "macro")
>>> but not how you achieve it otherwise. Then again, .HOW has the same issue;
>>> there's a bit of a bootstrapping issue with getting at the metamodel, you
>>> need to have it first. Which is why it's wired into the compiler and gets
>>> those uppercase pseudo-method names.
>>
>>
>> All the metamodel is not exactly part of the language; it's part of the
>> compiler. So it's in the gray NOT-SPECCED zone regarding documentation of
>> "Perl 6" the language, as oposed to "Perl 6, the implementation by Rakudo".
>> But it's a gray zone and sometimes you fall short of documenting things like
>> WHAT. I'll see what we can in that area.
>>
>> JJ
>>
>
>
> --
> JJ


Re: mixin syntax: does vs but

2018-06-12 Thread JJ Merelo
This is what the documentation says: https://docs.perl6.org/syntax/WHAT
You can override it, but we'll pay no attention anyway, basically. So you
can't achieve it otherwise, I guess.

El mar., 12 jun. 2018 a las 21:14, JJ Merelo ()
escribió:

>
>
> El mar., 12 jun. 2018 a las 21:11, Brandon Allbery ()
> escribió:
>
>> I should clarify this, but I'm not recalling full details at the moment
>> which is why I didn't originally.
>>
>> Perl uses a metaobject protocol (MOP, which you'll see in various places
>> in the docs). The "macro" to access the metaobject is the .HOW
>> pseudo-method. If you do this for a normal class or object of that class,
>> you get Perl6::Metamodel::ClassHOW back. This is what the .^method syntax
>> is accessing; it's short for (thing).HOW.method((thing), ...). The
>> metaclass doesn't magically know its children, so the object has to be used
>> once to get at its metaclass and a second time to tell the metaclass what
>> it is to introspect.
>>
>> I'm not seeing documentation for what .WHAT actually does; it (correctly)
>> notes that it's implemented specially within the compiler (hence "macro")
>> but not how you achieve it otherwise. Then again, .HOW has the same issue;
>> there's a bit of a bootstrapping issue with getting at the metamodel, you
>> need to have it first. Which is why it's wired into the compiler and gets
>> those uppercase pseudo-method names.
>>
>
> All the metamodel is not exactly part of the language; it's part of the
> compiler. So it's in the gray NOT-SPECCED zone regarding documentation of
> "Perl 6" the language, as oposed to "Perl 6, the implementation by Rakudo".
> But it's a gray zone and sometimes you fall short of documenting things
> like WHAT. I'll see what we can in that area.
>
> JJ
>
>

-- 
JJ


Re: mixin syntax: does vs but

2018-06-12 Thread Brandon Allbery
I should clarify this, but I'm not recalling full details at the moment
which is why I didn't originally.

Perl uses a metaobject protocol (MOP, which you'll see in various places in
the docs). The "macro" to access the metaobject is the .HOW pseudo-method.
If you do this for a normal class or object of that class, you get
Perl6::Metamodel::ClassHOW back. This is what the .^method syntax is
accessing; it's short for (thing).HOW.method((thing), ...). The metaclass
doesn't magically know its children, so the object has to be used once to
get at its metaclass and a second time to tell the metaclass what it is to
introspect.

I'm not seeing documentation for what .WHAT actually does; it (correctly)
notes that it's implemented specially within the compiler (hence "macro")
but not how you achieve it otherwise. Then again, .HOW has the same issue;
there's a bit of a bootstrapping issue with getting at the metamodel, you
need to have it first. Which is why it's wired into the compiler and gets
those uppercase pseudo-method names.

On Tue, Jun 12, 2018 at 3:00 PM Brandon Allbery  wrote:

> .WHAT is a "macro"/shorthand, which is why it's uppercase. There's a
> metamodel (the real meaning of the ^) version of it as well.
>
> On Tue, Jun 12, 2018 at 2:59 PM Joseph Brenner  wrote:
>
>> >> say @y.^WHAT
>>
>> > If you want to print the name use `.^name`.
>>
>> > If you want the type object for more advanced usages use `.WHAT`.
>>
>> Sorry, typo on my part.
>>
>> Though that raises another syntactic oddity I might whine about: perl6
>> code examples frequently use ".WHAT".  I was interested in getting a
>> list of all available methods, so I started trying some guesses:
>> ".METHODS", ".METHOD", ".methods" But actually it's ".^methods".
>> Okay, the caret is used for introspection... but then why isn't it
>> ".^what"?
>>
>> (It also turns out that the list ".^methods" gives you is bizarre:
>> hard to read, has many duplicates, unsorted, full of odd entries that
>> look like internal use only widgets I don't care about just now...)
>>
>>
>>
>>
>> On Tue, Jun 12, 2018 at 11:34 AM, Brad Gilbert  wrote:
>> > On Tue, Jun 12, 2018 at 12:55 PM, Joseph Brenner 
>> wrote:
>> >> Thanks, both your suggestion and JJ Merelo's work, but I think I like
>> >> yours for readability:
>> >>
>> >>   # # using binding, suggested by JJ Merelo 
>> >>   # my @y := @x but LookInside;
>> >>
>> >>   # suggested by Elizabeth Mattijsen l...@dijkmat.nl
>> >>   my @y does LookInside = @x;
>> >>
>> >> I actually found the use of "but" in the objects docs to be
>> >> tremendously confusing at first:  it looks like some sort of
>> >> conditional check, like "unless".
>> >
>> > The reason `but` exists is basically for the following
>> >
>> > my $v = 0 but True;
>> >
>> > if $v { say $v } # prints 0
>> >
>> > In Perl 5 it is common to return the string `"0 but true"` for a value
>> that is
>> > both 0 and true.
>> >
>> > Since one of the design philosophies of Perl 6 is to reduce the number
>> > of special cases this was made to be more generally useful.
>> >
>> > Note that you should not do the following
>> >
>> > my $v = 0;
>> > $v does True;
>> >
>> > say 'WTF!' if 0; # prints WTF!
>> >
>> > Basically you can use `but` anywhere you like, but be careful with
>> `does`.
>> >
>> >> On Tue, Jun 12, 2018 at 1:01 AM, Elizabeth Mattijsen 
>> wrote:
>>  On 12 Jun 2018, at 09:06, Joseph Brenner  wrote:
>> 
>>  I thought this would work to make a copy of @x but with the role
>>  "LookInside" attached to it:
>> 
>>    my @y = @x but LookInside;
>> 
>>  But that didn't add the role to @y. E.g.
>> >
>> > That is effectively the same as:
>> >
>> > my @y = (@x but LookInside).map: *.self;
>> >
>> > That is @ sigiled variables tend to slurp in iterable values.
>> >
>>   say @y.^WHAT
>> >
>> > If you want to print the name use `.^name`.
>> >
>> > If you want the type object for more advanced usages use `.WHAT`.
>> >
>> 
>>  Would just report (Array), not (Array+{LookInside}).
>> >>>
>> >>> What you’re doing here, is assigning the elements of an Array but
>> Lookinside to a normal Array.  The elements of the Array do not have any
>> roles mixed in, so you wind up with a normal Array with normal elements in
>> them.  Perhaps you meant:
>> >>>
>> >>> my @y does LookInside = @x;
>> >>>
>> >>> Here you create an Array @y with the role LookInside mixed in, and
>> *then* assign the values from @x.
>> >>>
>>
>
>
> --
> brandon s allbery kf8nh   sine nomine
> associates
> allber...@gmail.com
> ballb...@sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>


-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: mixin syntax: does vs but

2018-06-12 Thread JJ Merelo
El mar., 12 jun. 2018 a las 21:11, Brandon Allbery ()
escribió:

> I should clarify this, but I'm not recalling full details at the moment
> which is why I didn't originally.
>
> Perl uses a metaobject protocol (MOP, which you'll see in various places
> in the docs). The "macro" to access the metaobject is the .HOW
> pseudo-method. If you do this for a normal class or object of that class,
> you get Perl6::Metamodel::ClassHOW back. This is what the .^method syntax
> is accessing; it's short for (thing).HOW.method((thing), ...). The
> metaclass doesn't magically know its children, so the object has to be used
> once to get at its metaclass and a second time to tell the metaclass what
> it is to introspect.
>
> I'm not seeing documentation for what .WHAT actually does; it (correctly)
> notes that it's implemented specially within the compiler (hence "macro")
> but not how you achieve it otherwise. Then again, .HOW has the same issue;
> there's a bit of a bootstrapping issue with getting at the metamodel, you
> need to have it first. Which is why it's wired into the compiler and gets
> those uppercase pseudo-method names.
>

All the metamodel is not exactly part of the language; it's part of the
compiler. So it's in the gray NOT-SPECCED zone regarding documentation of
"Perl 6" the language, as oposed to "Perl 6, the implementation by Rakudo".
But it's a gray zone and sometimes you fall short of documenting things
like WHAT. I'll see what we can in that area.

JJ


Re: mixin syntax: does vs but

2018-06-12 Thread JJ Merelo
El mar., 12 jun. 2018 a las 21:01, Brandon Allbery ()
escribió:

> .WHAT is a "macro"/shorthand, which is why it's uppercase. There's a
> metamodel (the real meaning of the ^) version of it as well.
>

Right. From here: https://docs.perl6.org/language/operators#postfix_.^

^method calls method on $invocant's metaclass. It desugars to
$invocant.HOW.method($invocant,
...)

(HOW means Higher Order Workings and it effectively returns the metaclass
for every kind of object: ClassHOW and so on).

JJ


Re: mixin syntax: does vs but

2018-06-12 Thread Brandon Allbery
.WHAT is a "macro"/shorthand, which is why it's uppercase. There's a
metamodel (the real meaning of the ^) version of it as well.

On Tue, Jun 12, 2018 at 2:59 PM Joseph Brenner  wrote:

> >> say @y.^WHAT
>
> > If you want to print the name use `.^name`.
>
> > If you want the type object for more advanced usages use `.WHAT`.
>
> Sorry, typo on my part.
>
> Though that raises another syntactic oddity I might whine about: perl6
> code examples frequently use ".WHAT".  I was interested in getting a
> list of all available methods, so I started trying some guesses:
> ".METHODS", ".METHOD", ".methods" But actually it's ".^methods".
> Okay, the caret is used for introspection... but then why isn't it
> ".^what"?
>
> (It also turns out that the list ".^methods" gives you is bizarre:
> hard to read, has many duplicates, unsorted, full of odd entries that
> look like internal use only widgets I don't care about just now...)
>
>
>
>
> On Tue, Jun 12, 2018 at 11:34 AM, Brad Gilbert  wrote:
> > On Tue, Jun 12, 2018 at 12:55 PM, Joseph Brenner 
> wrote:
> >> Thanks, both your suggestion and JJ Merelo's work, but I think I like
> >> yours for readability:
> >>
> >>   # # using binding, suggested by JJ Merelo 
> >>   # my @y := @x but LookInside;
> >>
> >>   # suggested by Elizabeth Mattijsen l...@dijkmat.nl
> >>   my @y does LookInside = @x;
> >>
> >> I actually found the use of "but" in the objects docs to be
> >> tremendously confusing at first:  it looks like some sort of
> >> conditional check, like "unless".
> >
> > The reason `but` exists is basically for the following
> >
> > my $v = 0 but True;
> >
> > if $v { say $v } # prints 0
> >
> > In Perl 5 it is common to return the string `"0 but true"` for a value
> that is
> > both 0 and true.
> >
> > Since one of the design philosophies of Perl 6 is to reduce the number
> > of special cases this was made to be more generally useful.
> >
> > Note that you should not do the following
> >
> > my $v = 0;
> > $v does True;
> >
> > say 'WTF!' if 0; # prints WTF!
> >
> > Basically you can use `but` anywhere you like, but be careful with
> `does`.
> >
> >> On Tue, Jun 12, 2018 at 1:01 AM, Elizabeth Mattijsen 
> wrote:
>  On 12 Jun 2018, at 09:06, Joseph Brenner  wrote:
> 
>  I thought this would work to make a copy of @x but with the role
>  "LookInside" attached to it:
> 
>    my @y = @x but LookInside;
> 
>  But that didn't add the role to @y. E.g.
> >
> > That is effectively the same as:
> >
> > my @y = (@x but LookInside).map: *.self;
> >
> > That is @ sigiled variables tend to slurp in iterable values.
> >
>   say @y.^WHAT
> >
> > If you want to print the name use `.^name`.
> >
> > If you want the type object for more advanced usages use `.WHAT`.
> >
> 
>  Would just report (Array), not (Array+{LookInside}).
> >>>
> >>> What you’re doing here, is assigning the elements of an Array but
> Lookinside to a normal Array.  The elements of the Array do not have any
> roles mixed in, so you wind up with a normal Array with normal elements in
> them.  Perhaps you meant:
> >>>
> >>> my @y does LookInside = @x;
> >>>
> >>> Here you create an Array @y with the role LookInside mixed in, and
> *then* assign the values from @x.
> >>>
>


-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: mixin syntax: does vs but

2018-06-12 Thread Joseph Brenner
>> say @y.^WHAT

> If you want to print the name use `.^name`.

> If you want the type object for more advanced usages use `.WHAT`.

Sorry, typo on my part.

Though that raises another syntactic oddity I might whine about: perl6
code examples frequently use ".WHAT".  I was interested in getting a
list of all available methods, so I started trying some guesses:
".METHODS", ".METHOD", ".methods" But actually it's ".^methods".
Okay, the caret is used for introspection... but then why isn't it
".^what"?

(It also turns out that the list ".^methods" gives you is bizarre:
hard to read, has many duplicates, unsorted, full of odd entries that
look like internal use only widgets I don't care about just now...)




On Tue, Jun 12, 2018 at 11:34 AM, Brad Gilbert  wrote:
> On Tue, Jun 12, 2018 at 12:55 PM, Joseph Brenner  wrote:
>> Thanks, both your suggestion and JJ Merelo's work, but I think I like
>> yours for readability:
>>
>>   # # using binding, suggested by JJ Merelo 
>>   # my @y := @x but LookInside;
>>
>>   # suggested by Elizabeth Mattijsen l...@dijkmat.nl
>>   my @y does LookInside = @x;
>>
>> I actually found the use of "but" in the objects docs to be
>> tremendously confusing at first:  it looks like some sort of
>> conditional check, like "unless".
>
> The reason `but` exists is basically for the following
>
> my $v = 0 but True;
>
> if $v { say $v } # prints 0
>
> In Perl 5 it is common to return the string `"0 but true"` for a value that is
> both 0 and true.
>
> Since one of the design philosophies of Perl 6 is to reduce the number
> of special cases this was made to be more generally useful.
>
> Note that you should not do the following
>
> my $v = 0;
> $v does True;
>
> say 'WTF!' if 0; # prints WTF!
>
> Basically you can use `but` anywhere you like, but be careful with `does`.
>
>> On Tue, Jun 12, 2018 at 1:01 AM, Elizabeth Mattijsen  wrote:
 On 12 Jun 2018, at 09:06, Joseph Brenner  wrote:

 I thought this would work to make a copy of @x but with the role
 "LookInside" attached to it:

   my @y = @x but LookInside;

 But that didn't add the role to @y. E.g.
>
> That is effectively the same as:
>
> my @y = (@x but LookInside).map: *.self;
>
> That is @ sigiled variables tend to slurp in iterable values.
>
  say @y.^WHAT
>
> If you want to print the name use `.^name`.
>
> If you want the type object for more advanced usages use `.WHAT`.
>

 Would just report (Array), not (Array+{LookInside}).
>>>
>>> What you’re doing here, is assigning the elements of an Array but 
>>> Lookinside to a normal Array.  The elements of the Array do not have any 
>>> roles mixed in, so you wind up with a normal Array with normal elements in 
>>> them.  Perhaps you meant:
>>>
>>> my @y does LookInside = @x;
>>>
>>> Here you create an Array @y with the role LookInside mixed in, and *then* 
>>> assign the values from @x.
>>>


Re: mixin syntax: does vs but

2018-06-12 Thread JJ Merelo
Hi,

El mar., 12 jun. 2018 a las 20:35, Brad Gilbert ()
escribió:

> On Tue, Jun 12, 2018 at 12:55 PM, Joseph Brenner 
> wrote:
> > Thanks, both your suggestion and JJ Merelo's work, but I think I like
> > yours for readability:
> >
> >   # # using binding, suggested by JJ Merelo 
> >   # my @y := @x but LookInside;
> >
> >   # suggested by Elizabeth Mattijsen l...@dijkmat.nl
> >   my @y does LookInside = @x;
> >
> > I actually found the use of "but" in the objects docs to be
> > tremendously confusing at first:  it looks like some sort of
> > conditional check, like "unless".
>
> The reason `but` exists is basically for the following
>
> my $v = 0 but True;
>
> if $v { say $v } # prints 0
>
> In Perl 5 it is common to return the string `"0 but true"` for a value
> that is
> both 0 and true.
>
> Since one of the design philosophies of Perl 6 is to reduce the number
> of special cases this was made to be more generally useful.
>
> Note that you should not do the following
>
> my $v = 0;
> $v does True;
>
> say 'WTF!' if 0; # prints WTF!
>
> Basically you can use `but` anywhere you like, but be careful with `does`.
>

We *badly* need that trait page to make everything clear. I'll have to
speed that up. Any help is welcome.

JJ
PS: If you change the last 0 above to $v, it says: «Hey␤Some exceptions
were thrown in END blocks:␤»


Re: mixin syntax: does vs but

2018-06-12 Thread Brad Gilbert
On Tue, Jun 12, 2018 at 12:55 PM, Joseph Brenner  wrote:
> Thanks, both your suggestion and JJ Merelo's work, but I think I like
> yours for readability:
>
>   # # using binding, suggested by JJ Merelo 
>   # my @y := @x but LookInside;
>
>   # suggested by Elizabeth Mattijsen l...@dijkmat.nl
>   my @y does LookInside = @x;
>
> I actually found the use of "but" in the objects docs to be
> tremendously confusing at first:  it looks like some sort of
> conditional check, like "unless".

The reason `but` exists is basically for the following

my $v = 0 but True;

if $v { say $v } # prints 0

In Perl 5 it is common to return the string `"0 but true"` for a value that is
both 0 and true.

Since one of the design philosophies of Perl 6 is to reduce the number
of special cases this was made to be more generally useful.

Note that you should not do the following

my $v = 0;
$v does True;

say 'WTF!' if 0; # prints WTF!

Basically you can use `but` anywhere you like, but be careful with `does`.

> On Tue, Jun 12, 2018 at 1:01 AM, Elizabeth Mattijsen  wrote:
>>> On 12 Jun 2018, at 09:06, Joseph Brenner  wrote:
>>>
>>> I thought this would work to make a copy of @x but with the role
>>> "LookInside" attached to it:
>>>
>>>   my @y = @x but LookInside;
>>>
>>> But that didn't add the role to @y. E.g.

That is effectively the same as:

my @y = (@x but LookInside).map: *.self;

That is @ sigiled variables tend to slurp in iterable values.

>>>  say @y.^WHAT

If you want to print the name use `.^name`.

If you want the type object for more advanced usages use `.WHAT`.

>>>
>>> Would just report (Array), not (Array+{LookInside}).
>>
>> What you’re doing here, is assigning the elements of an Array but Lookinside 
>> to a normal Array.  The elements of the Array do not have any roles mixed 
>> in, so you wind up with a normal Array with normal elements in them.  
>> Perhaps you meant:
>>
>> my @y does LookInside = @x;
>>
>> Here you create an Array @y with the role LookInside mixed in, and *then* 
>> assign the values from @x.
>>


Re: mixin syntax: does vs but

2018-06-12 Thread JJ Merelo
Please check this https://github.com/perl6/doc/commit/f6df30a8fc

It's going to be soon in the docs (they are updated every 5 minutes if
there are changes), however a general discussion of when to use "but" and
when to use "does" is still missing. I'm working towards it in this page
https://docs.perl6.org/language/traits, but there's still a long way to go.

JJ


Re: mixin syntax: does vs but

2018-06-12 Thread JJ Merelo
I have added this to the documentation:
https://github.com/perl6/doc/commit/ddd101b089

I'll add also Liz's example to make it even clearer. Or maybe a link if it
does not belong in that section. I'll see what's best.

JJ


Re: mixin syntax: does vs but

2018-06-12 Thread Joseph Brenner
Thanks, both your suggestion and JJ Merelo's work, but I think I like
yours for readability:

  # # using binding, suggested by JJ Merelo 
  # my @y := @x but LookInside;

  # suggested by Elizabeth Mattijsen l...@dijkmat.nl
  my @y does LookInside = @x;

I actually found the use of "but" in the objects docs to be
tremendously confusing at first:  it looks like some sort of
conditional check, like "unless".



On Tue, Jun 12, 2018 at 1:01 AM, Elizabeth Mattijsen  wrote:
>> On 12 Jun 2018, at 09:06, Joseph Brenner  wrote:
>>
>> I thought this would work to make a copy of @x but with the role
>> "LookInside" attached to it:
>>
>>   my @y = @x but LookInside;
>>
>> But that didn't add the role to @y. E.g.
>>
>>  say @y.^WHAT
>>
>> Would just report (Array), not (Array+{LookInside}).
>
> What you’re doing here, is assigning the elements of an Array but Lookinside 
> to a normal Array.  The elements of the Array do not have any roles mixed in, 
> so you wind up with a normal Array with normal elements in them.  Perhaps you 
> meant:
>
> my @y does LookInside = @x;
>
> Here you create an Array @y with the role LookInside mixed in, and *then* 
> assign the values from @x.
>
>
>
> Also, what JJ Merelo said: StackOverflow is your friend  :-)
>
>
>
> Liz


Re: mixin syntax: does vs but

2018-06-12 Thread JJ Merelo
El mar., 12 jun. 2018 a las 19:07, Brandon Allbery ()
escribió:

> That was not "also", that was "this is the right way". "Ask questions in
> StackOverflow whenever possible" does not leave room for "this is also a
> good venue", it asserts that there is one proper venue and others are
> discouraged.
>

Actually, there was an "also:" right before "Ask questions in StackOverflow
whenever possible". Maybe it should have been right after "StackOverflow".
Again, my mistake.

>
> It asserts that, for people who have difficulty using StackOverflow for
> whatever reason, *they do not belong here*.
>

Not my intention in the least way. They *very much* belong here.

JJ


Re: mixin syntax: does vs but

2018-06-12 Thread Joseph Brenner
> Use binding:
>
> my @x= <1 2 3>; my @y := @x but Iterable; say @y.^name; #  OUTPUT: 
> «Array+{Iterable}␤»

Hm... the docs on objects has this example:

https://docs.perl6.org/language/objects

  role R { method Str() {'hidden!'} };
  my $i = 2 but R;
  sub f(\bound){ put bound };
  f($i); # OUTPUT: «hidden!␤»

So, my mistake was thinking the form of that second line would work
with array variables?

Looking up "binding" in the docs, there's this material:

https://docs.perl6.org/language/list

  By default, when you assign a List to an @-sigiled variable, you
create an Array. Those are described below. If instead you want to
refer directly to a List object using an @-sigiled variable, you can
use binding with := instead.

 my @a := 1, 2, 3;

  One of the ways @-sigiled variables act like lists is by always
supporting positional subscripting. Anything bound to a @-sigiled
value must support the Positional role which guarantees that this is
going to fail:

 my @a := 1; # Type check failed in binding; expected Positional but got Int

And my first reaction to all this is "Seriously?!".  There are
multiple different things here that feel like syntactic glitches, and
you need to tell me about the Positional role now to have any hope of
convincing me this one makes sense on some level?

(One reason you don't want me on stackoverflow is that I'm a whiner
who is not likely to whole-heartedly promote the cause...)



On Tue, Jun 12, 2018 at 12:09 AM, JJ Merelo  wrote:
> Use binding:
>
> my @x= <1 2 3>; my @y := @x but Iterable; say @y.^name; #  OUTPUT:
> «Array+{Iterable}␤»
>
> El mar., 12 jun. 2018 a las 9:06, Joseph Brenner ()
> escribió:
>>
>> I thought this would work to make a copy of @x but with the role
>> "LookInside" attached to it:
>>
>>my @y = @x but LookInside;
>>
>> But that didn't add the role to @y. E.g.
>>
>>   say @y.^WHAT
>>
>> Would just report (Array), not (Array+{LookInside}).
>>
>> I found that this would do what I was trying to do though:
>>
>>my @y = @x;
>>@y does LookInside;
>>
>> I didn't think there would be any difference between the two
>> though.  What am I not getting?
>>
>> The full code looks like this:
>>
>> trial_introspect.pl6:
>>
>>   use v6;
>>   use Trial::Introspect;
>>   my @x = ;
>>   my @y = @x;
>>   @y does LookInside;
>>   say "Methods: ";
>>   say @y.methodical_methods;
>>
>>
>> .../Trial/Introspect.pm6:
>>
>>   role LookInside {
>> method methodical_methods {
>>   self.^methods.map({ .gist }).sort.unique.map({ "$_\n" }).grep({
>> ! /^Method/ });
>> }
>>   }
>
>
>
> --
> JJ


Re: mixin syntax: does vs but

2018-06-12 Thread Brandon Allbery
Smileys do not change "use … whenever possible". It;s still asserting there
is one correct way to contribute.


On Tue, Jun 12, 2018 at 1:07 PM Curt Tilmes  wrote:

>
> On Tue, Jun 12, 2018 at 12:56 PM Brandon Allbery 
> wrote:
>
>> Which doesn't change the fact that there's what amounts to an
>> accessibility issue.
>>
>> Do you *really* want to tell some percentage of people that they must be
>> willing to use the One True Web Site, or else go away because they're not
>> wanted hereabouts? Because insisting all the time that "(also: ask
>> questions in StackOverflow whenever possible :-) )" is doing exactly that.
>>
>> On Tue, Jun 12, 2018 at 12:51 PM JJ Merelo  wrote:
>>
>>>
>>> Well, it really helps newcomers to find answers to their problems. It's
>>> well indexed, and it also raises visibility of the Perl6 language.
>>>
>>
> "must be willing", "insisting", etc. is a very different type of approach
> from the gentle "whenever possible" with a smiley.
>
> No one is "insisting" or telling people they aren't wanted hereabouts.
>
> Use StackOverflow if possible (for the reasons expressed) If not (for
> whatever reason, we won't pry), use perl6-users, that's ok too.
>
>

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: mixin syntax: does vs but

2018-06-12 Thread Curt Tilmes
On Tue, Jun 12, 2018 at 12:56 PM Brandon Allbery 
wrote:

> Which doesn't change the fact that there's what amounts to an
> accessibility issue.
>
> Do you *really* want to tell some percentage of people that they must be
> willing to use the One True Web Site, or else go away because they're not
> wanted hereabouts? Because insisting all the time that "(also: ask
> questions in StackOverflow whenever possible :-) )" is doing exactly that.
>
> On Tue, Jun 12, 2018 at 12:51 PM JJ Merelo  wrote:
>
>>
>> Well, it really helps newcomers to find answers to their problems. It's
>> well indexed, and it also raises visibility of the Perl6 language.
>>
>
"must be willing", "insisting", etc. is a very different type of approach
from the gentle "whenever possible" with a smiley.

No one is "insisting" or telling people they aren't wanted hereabouts.

Use StackOverflow if possible (for the reasons expressed) If not (for
whatever reason, we won't pry), use perl6-users, that's ok too.


Re: mixin syntax: does vs but

2018-06-12 Thread Brandon Allbery
That was not "also", that was "this is the right way". "Ask questions in
StackOverflow whenever possible" does not leave room for "this is also a
good venue", it asserts that there is one proper venue and others are
discouraged.

It asserts that, for people who have difficulty using StackOverflow for
whatever reason, *they do not belong here*.

On Tue, Jun 12, 2018 at 1:01 PM JJ Merelo  wrote:

> Hi
>
> El mar., 12 jun. 2018 a las 18:56, Brandon Allbery ()
> escribió:
>
>> Which doesn't change the fact that there's what amounts to an
>> accessibility issue.
>>
>> Do you *really* want to tell some percentage of people that they must be
>> willing to use the One True Web Site, or else go away because they're not
>> wanted hereabouts? Because insisting all the time that "(also: ask
>> questions in StackOverflow whenever possible :-) )" is doing exactly that.
>>
>
>
> Sorry, I don't understand what you mean here. We're very happy with
> questions here, and I (and everyone else) answer them whenever I can. We
> ask people to *also* post them in StackOverflow if they have an account,
> and want, and have the time to do so, because I personally think it helps
> expand Perl6's community. It's OK if they don't. I posted the rationale
> after that here
> http://blogs.perl.org/users/jj_merelo/2018/04/stackoverflow-that.html I'm
> sorry if it sounds like kicking people out of here, because that wasn't
> really the intention.
>
> JJ
>


-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: mixin syntax: does vs but

2018-06-12 Thread JJ Merelo
Hi

El mar., 12 jun. 2018 a las 18:56, Brandon Allbery ()
escribió:

> Which doesn't change the fact that there's what amounts to an
> accessibility issue.
>
> Do you *really* want to tell some percentage of people that they must be
> willing to use the One True Web Site, or else go away because they're not
> wanted hereabouts? Because insisting all the time that "(also: ask
> questions in StackOverflow whenever possible :-) )" is doing exactly that.
>


Sorry, I don't understand what you mean here. We're very happy with
questions here, and I (and everyone else) answer them whenever I can. We
ask people to *also* post them in StackOverflow if they have an account,
and want, and have the time to do so, because I personally think it helps
expand Perl6's community. It's OK if they don't. I posted the rationale
after that here
http://blogs.perl.org/users/jj_merelo/2018/04/stackoverflow-that.html I'm
sorry if it sounds like kicking people out of here, because that wasn't
really the intention.

JJ


Re: mixin syntax: does vs but

2018-06-12 Thread Brandon Allbery
Which doesn't change the fact that there's what amounts to an accessibility
issue.

Do you *really* want to tell some percentage of people that they must be
willing to use the One True Web Site, or else go away because they're not
wanted hereabouts? Because insisting all the time that "(also: ask
questions in StackOverflow whenever possible :-) )" is doing exactly that.

On Tue, Jun 12, 2018 at 12:51 PM JJ Merelo  wrote:

>
>
> El mar., 12 jun. 2018 a las 18:34, Brandon Allbery ()
> escribió:
>
>> You really do want to be exclusionary, don't you?
>>
>> yada yada stackoverflow is the one truth yada yada.
>>
>
> Well, it really helps newcomers to find answers to their problems. It's
> well indexed, and it also raises visibility of the Perl6 language.
>
> Cheers
>
> JJ
>
>

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: mixin syntax: does vs but

2018-06-12 Thread JJ Merelo
El mar., 12 jun. 2018 a las 18:34, Brandon Allbery ()
escribió:

> You really do want to be exclusionary, don't you?
>
> yada yada stackoverflow is the one truth yada yada.
>

Well, it really helps newcomers to find answers to their problems. It's
well indexed, and it also raises visibility of the Perl6 language.

Cheers

JJ


Re: mixin syntax: does vs but

2018-06-12 Thread Brandon Allbery
You really do want to be exclusionary, don't you?

yada yada stackoverflow is the one truth yada yada.

Enough.

On Tue, Jun 12, 2018 at 3:12 AM JJ Merelo  wrote:

> (also: ask questions in StackOverflow whenever possible :-) )
>
> El mar., 12 jun. 2018 a las 9:09, JJ Merelo ()
> escribió:
>
>> Use binding:
>>
>> my @x= <1 2 3>; my @y := @x but Iterable; say @y.^name; #  OUTPUT:
>> «Array+{Iterable}␤»
>>
>> El mar., 12 jun. 2018 a las 9:06, Joseph Brenner ()
>> escribió:
>>
>>> I thought this would work to make a copy of @x but with the role
>>> "LookInside" attached to it:
>>>
>>>my @y = @x but LookInside;
>>>
>>> But that didn't add the role to @y. E.g.
>>>
>>>   say @y.^WHAT
>>>
>>> Would just report (Array), not (Array+{LookInside}).
>>>
>>> I found that this would do what I was trying to do though:
>>>
>>>my @y = @x;
>>>@y does LookInside;
>>>
>>> I didn't think there would be any difference between the two
>>> though.  What am I not getting?
>>>
>>> The full code looks like this:
>>>
>>> trial_introspect.pl6:
>>>
>>>   use v6;
>>>   use Trial::Introspect;
>>>   my @x = ;
>>>   my @y = @x;
>>>   @y does LookInside;
>>>   say "Methods: ";
>>>   say @y.methodical_methods;
>>>
>>>
>>> .../Trial/Introspect.pm6:
>>>
>>>   role LookInside {
>>> method methodical_methods {
>>>   self.^methods.map({ .gist }).sort.unique.map({ "$_\n" }).grep({
>>> ! /^Method/ });
>>> }
>>>   }
>>>
>>
>>
>> --
>> JJ
>>
>
>
> --
> JJ
>


-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: mixin syntax: does vs but

2018-06-12 Thread Elizabeth Mattijsen
> On 12 Jun 2018, at 09:06, Joseph Brenner  wrote:
> 
> I thought this would work to make a copy of @x but with the role
> "LookInside" attached to it:
> 
>   my @y = @x but LookInside;
> 
> But that didn't add the role to @y. E.g.
> 
>  say @y.^WHAT
> 
> Would just report (Array), not (Array+{LookInside}).

What you’re doing here, is assigning the elements of an Array but Lookinside to 
a normal Array.  The elements of the Array do not have any roles mixed in, so 
you wind up with a normal Array with normal elements in them.  Perhaps you 
meant:

my @y does LookInside = @x;

Here you create an Array @y with the role LookInside mixed in, and *then* 
assign the values from @x.



Also, what JJ Merelo said: StackOverflow is your friend  :-)



Liz

Re: mixin syntax: does vs but

2018-06-12 Thread JJ Merelo
(also: ask questions in StackOverflow whenever possible :-) )

El mar., 12 jun. 2018 a las 9:09, JJ Merelo () escribió:

> Use binding:
>
> my @x= <1 2 3>; my @y := @x but Iterable; say @y.^name; #  OUTPUT:
> «Array+{Iterable}␤»
>
> El mar., 12 jun. 2018 a las 9:06, Joseph Brenner ()
> escribió:
>
>> I thought this would work to make a copy of @x but with the role
>> "LookInside" attached to it:
>>
>>my @y = @x but LookInside;
>>
>> But that didn't add the role to @y. E.g.
>>
>>   say @y.^WHAT
>>
>> Would just report (Array), not (Array+{LookInside}).
>>
>> I found that this would do what I was trying to do though:
>>
>>my @y = @x;
>>@y does LookInside;
>>
>> I didn't think there would be any difference between the two
>> though.  What am I not getting?
>>
>> The full code looks like this:
>>
>> trial_introspect.pl6:
>>
>>   use v6;
>>   use Trial::Introspect;
>>   my @x = ;
>>   my @y = @x;
>>   @y does LookInside;
>>   say "Methods: ";
>>   say @y.methodical_methods;
>>
>>
>> .../Trial/Introspect.pm6:
>>
>>   role LookInside {
>> method methodical_methods {
>>   self.^methods.map({ .gist }).sort.unique.map({ "$_\n" }).grep({
>> ! /^Method/ });
>> }
>>   }
>>
>
>
> --
> JJ
>


-- 
JJ


Re: mixin syntax: does vs but

2018-06-12 Thread JJ Merelo
Use binding:

my @x= <1 2 3>; my @y := @x but Iterable; say @y.^name; #  OUTPUT:
«Array+{Iterable}␤»

El mar., 12 jun. 2018 a las 9:06, Joseph Brenner ()
escribió:

> I thought this would work to make a copy of @x but with the role
> "LookInside" attached to it:
>
>my @y = @x but LookInside;
>
> But that didn't add the role to @y. E.g.
>
>   say @y.^WHAT
>
> Would just report (Array), not (Array+{LookInside}).
>
> I found that this would do what I was trying to do though:
>
>my @y = @x;
>@y does LookInside;
>
> I didn't think there would be any difference between the two
> though.  What am I not getting?
>
> The full code looks like this:
>
> trial_introspect.pl6:
>
>   use v6;
>   use Trial::Introspect;
>   my @x = ;
>   my @y = @x;
>   @y does LookInside;
>   say "Methods: ";
>   say @y.methodical_methods;
>
>
> .../Trial/Introspect.pm6:
>
>   role LookInside {
> method methodical_methods {
>   self.^methods.map({ .gist }).sort.unique.map({ "$_\n" }).grep({
> ! /^Method/ });
> }
>   }
>


-- 
JJ