Re: a necessary no-op

2018-10-29 Thread Brandon Allbery
What jumps out to me is the difference between a normal method and a
metamethod; the latter might not do sufficient validation, so you're
catching the exception from trying to invoke .gist. And that just happens
to do the right thing in your case; if you're getting a VMNull from an
implementation-internal name (possibly something in NQP which leads to a
VMNull if you try to treat it as a P6 object), that would be likely.

On Mon, Oct 29, 2018 at 10:37 PM Joseph Brenner  wrote:

> I've got a weird one here... a line that looks like it does
> nothing significant is needed for the code to work.
> If the line below marked "The Mystery Line" is commented out,
> you just get the error:
>
>===SORRY!===
>Cannot look up attributes in a VMNull type object
>
> Augment::Util:
>
> class Recomposer {
> method recompose_core {
> my @type_symbols = (|CORE::).grep({ .key eq .value.^name
> }).map( *.value );
> for @type_symbols -> $type_symbol {
> my $type_symbol_name = $type_symbol.^name;
> try {
> my $nada = $type_symbol.gist;  # The Mystery Line
> $type_symbol.^compose;
> # if there's no ^.compose method, just skip to next
> type symbol object
> CATCH {
> default { }
> }
> }
> }
> }
> }
>
>
> The problem seems to be local to that "recompose_core" routine,
> though just to be complete I'll tack on the rest of my code...
> sorry about the length, it's hard to strip it down much further
> than this.
>
> The goal here is to be able to start the repl with the command:
>
>   perl6 -Mmethod-menu
>
> And have a new method (something like .^methods) named simply .m
> available everywhere.
>
>
> method-menu:
>
> use Object::Examine;
> use Augment::Util;
> use MONKEY-TYPING;
> augment class Any does Introspector {
> method m {
> return self.menu;
> }
> Recomposer.recompose_core();
> }
>
>
> Object::Examine:
>
> role Introspector {
> method menu {
> my @seen_methods = ();
> my @levels  = self.^mro; # better than ^parents: current class and
> above
> my $report = '';
> my @data;
> for @levels -> $l {
> my $level_name = $l.^name;
> my @current_methods  = clean_methods( methods_for( $l ) );
> my @child_methods = ( @current_methods (-) @seen_methods
> ).keys;
> # saving up the data...
> for @child_methods -> $cm {
> @data.push([$cm, $level_name]);
> }
> @seen_methods = ( @seen_methods (+) @current_methods ).keys;
> }
> my @lines = @data.sort({ $_[0] });
> for @lines -> $l {
> my $fmt = "%-25s %-25s\n";
> $report ~= sprintf $fmt, $l[0], $l[1];
> }
> return $report;
> }
> sub methods_for(Mu $obj) {
> my @raws = $obj.^methods(:local);  # or :all?
> }
> sub clean_methods (@raws) {
> my @strs = @raws.map({ .gist });
> my @ways = @strs.sort;
> my @unis = @ways.unique;
> # filter out methods 'Method+{is-nodal}.new' and 'menu'
> my @trim = @unis.grep({ ! /^ Method\+\{is\-nodal\}\.new /
> }).grep({ ! / ^ (menu) \s* $ / });
> }
> }
>
> 01-method-menu.t:
>
> use v6;
> use Test;
> use method-menu;
> my $test_case = "'use method-menu;' and the 'm' method";
> subtest {
>   my $report1 = (Array).m;
>   my @report1 = $report1.lines;
>   my $l1 = @report1.elems;  # 203
>   cmp-ok($l1, '>', 24, "report1 shows over 24 methods: $l1");
> }, $test_case;
> done-testing();
>


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


Re: Exception Handling, DivideByZero

2018-10-29 Thread Brandon Allbery
Two issues:

(1) all standard exceptions are in or under the X:: namespace.

(2) .WHAT doesn't show names with their namespaces, whereas .^name does.

pyanfar Z$ 6 'my $r = 4/0; say $r; CATCH {default {say .^name}}'
X::Numeric::DivideByZero


On Mon, Oct 29, 2018 at 1:04 PM Joseph Brenner  wrote:

> I was just looking into doing some finer-grained exception handling,
> so I tried this:
>
>use v6;
>try {
>my $result = 4/0;
>say "result: $result";
>CATCH {
>#when DivideByZero { say "Oh, you know."; }
>default { say .WHAT; .Str.say } # (DivideByZero)   Attempt
> to divide 4 by zero using div
>}
>}
>
> The first time through, The .WHAT tells me I've got
> "DivideByZero", and so I added the line that's commented out
> here, at which point I got the error:
>
>===SORRY!===
>Function 'DivideByZero' needs parens to avoid gobbling block (or
> perhaps it's a class that's not declared or available in this scope?)
>
> Putting parens around (DivideByZero) doesn't help:
>
>Undeclared name:
>   DivideByZero used at line 12
>
> My impression was this would just work from looking
> at the examples using things like X::AdHoc here:
>
>   https://docs.perl6.org/language/exceptions
>


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


Re: what type $in,$out and $err is

2018-10-28 Thread Brandon Allbery
It takes Any — and quite a few more things than are currently documented,
like IIRC filenames, and looks at the actual type passed to decide what to
do with it.

On Sun, Oct 28, 2018 at 3:31 PM Xiao Yafeng  wrote:

> I'm curious about what type of $in is on Proc class. As described in
> perl6doc:
> $in, $out and $err are the three standard streams of the
> to-be-launched program, and default to "-" meaning they inherit the
> stream from the parent process. Setting one (or more) of them to True
> makes the stream available as an IO::Pipe object of the same name,
> like for example $proc.out.
>
> I mean, if $in is IO::Pipe object, how can I pass it True?
>
> > my IO::Pipe $bb = True;
> Type check failed in assignment to $bb; expected IO::Pipe but got Bool
> (Bool::True)
>   in block  at  line 4
>
> I'm interested in the underlying mechanics of  it. Please enlighten me.
>
> Besides, just curious, why choose '_' as default it looks strange
>


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


Re: Appropriate last words

2018-10-25 Thread Brandon Allbery
I didn't phrase that quite right.

pyanfar Z$ 6 'my @lines; $*OUT.^find_method("print").wrap: -> $self, $str {
@lines.push($str) }; use Test; note "hello"; is @lines[0], "hello\n",
"wrapped err too"'
ok 1 - wrapped err too

This wraps it for every IO::Handle, not just for the IO::Handle in $*OUT.
You may need "but" for that?

On Thu, Oct 25, 2018 at 9:34 PM Brian Duggan  wrote:

> On Thursday, October 25, Brandon Allbery wrote:
> > You can't actually wrap print that way, can you? Or rather, if that works
> > it wouldn't be specific to $*ERR.
>
> Um, you definitely can, and yes it's not specific to $*ERR, e.g.
>
> my @lines;
> $*OUT.^find_method('print').wrap: -> $self, $str { @lines.push($str) }
>
> use Test;
> say "hello";
> is @lines[0], "hello\n", 'said hello';
>
> produces
>
> ok 1 - said hello
>
> Brian
>


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


Re: Appropriate last words

2018-10-25 Thread Brandon Allbery
You can't actually wrap print that way, can you? Or rather, if that works
it wouldn't be specific to $*ERR.

On Thu, Oct 25, 2018 at 6:16 PM Brian Duggan  wrote:

> On Thursday, October 25, Richard Hainsworth wrote:
> > >&exit.wrap: -> $status { $exit-args = $status; fail }
> >
> > Is the call to 'fail' replicating the original action of &exit?
>
> No -- the call to fail is throwing an exception.  The idea
> is that the exception could then be caught in the test.
>
> > >¬e.wrap: -> |c { $note-args = c; callsame; }
> > Does this mean that the next routine in a chain (in this case `exit note
> ...
> > `), so in fact `exit`, is called?
>
> No -- "callsame" is calling the original "note".
>
> > >$*ERR.^find_method('print').wrap: -> |c { True; }
> > This wrap I am not so clear about. Why is `^find_method('print') needed?
>
> Since callsame called note (above) note will still print
> to stderr -- if we want to intercept this, i.e. to not print
> to stderr, we can wrap the 'print' method of $*ERR.
>
> This is just one of doing it...maybe I did more wrapping than
> necessary :-)  And in any case, in a test suite, some of
> these wraps might have to be temporary. (so that they
> don't interfere with code in the test suite)
>
> Brian
>


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


Re: I need unprintable regex help

2018-10-20 Thread Brandon Allbery
The escape sequence \x allows you to embed characters by their code.
"\x0D\x0A" is the same as the variable.

I'm not sure what you thought I was showing you on IRC last night, since I
pointed this out multiple times.

On Sat, Oct 20, 2018 at 3:43 AM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> Hi All,
>
> my Str $CrLf   = chr(0x0d) ~ chr(0x0a);
> $String ~~ s:global/ $CrLf /\n/;
>
> How do I get rid of the extra $CrLf variable?
>
> Many thanks,
> -T
>


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


Re: augment again

2018-10-18 Thread Brandon Allbery
pyanfar Z$ 6 'use MONKEY-TYPING; augment class Any {method hic { say "hoc"
}}; my @a = ; @a.hic'
No such method 'hic' for invocant of type 'Array'. Did you mean 'hic'?
  in block  at -e line 1

zsh: exit 1
pyanfar Z$ 6 'use MONKEY-TYPING; augment class Any {method hic { say "hoc"
}}; Array.^compose; my @a = ; @a.hic'
hoc

Basically you have to re-compose any class you want to see the added
methods.

On Thu, Oct 18, 2018 at 9:53 PM Joseph Brenner  wrote:

> I've got another question about aug--yes, I know--ment.
>
> I've got a module ides_of_augment.pm6:
>
>   use MONKEY-TYPING;
>   augment class Any {
>   method hiccup {
>   say "hic!";
>   }
>   }
>
> I would've thought it could be used in the repl like this:
>
>   perl6 -Mides_of_augment
>
>   > (Any).hiccup
>   hic!
>   > my @a=< a b c d >;
>   [a b c d]
>   > @a.hiccup
>   No such method 'hiccup' for invocant of type 'Array'. Did you mean
> 'hiccup'?
> in block  at  line 1
>
> As you can see, it kind-of augments the Any class, but evidently
> does it too late to (completely) change an instance of Array.
>
> I tried a few things like "BEGIN augment" or "INIT augment"
> without any luck.
>
> Any suggestions (besides "don't do it")?
>


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


Re: Malformed UTF-8 ???

2018-10-15 Thread Brandon Allbery
Isn't the point that it's $ReturnStr that's throwing the immutable error,
not $RunString? That's what I see in the thread history.

On Mon, Oct 15, 2018 at 9:40 PM Curt Tilmes  wrote:

>
>
> On Mon, Oct 15, 2018 at 9:34 PM ToddAndMargo via perl6-users <
> perl6-us...@perl.org> wrote:
>
>> On 10/15/18 9:04 AM, Larry Wall wrote:
>> > This almost certainly means that $ReturnStr is a read-only paramater to
>> > a routine.  Add "is copy" to the declaration if you want to modify it.
>>
>> I am not seeing it.
>>
>> sub RunNoShellAll( Str $RunString, Int $StdOut, Int $StdErr, Int $Code ) {
>>
>
> You are declaring $RunString as a read-only parameter.
>
> Try this:
>
>  sub RunNoShellAll( Str $RunString is copy, Int $StdOut, Int $StdErr, Int
> $Code ) {
>
>

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


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 was at line 1)
at /home/allbery/derp.p6:1
--> sub foo (Int $a --> List(Str⏏, Int)) { return ~$a, $a + 1 }


On Fri, Oct 12, 2018 at 6:44 PM Ralph Mellor 
wrote:

> 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 <
> 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>> 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] ~~
>> Int;
>> >  >>  > sub RtnOrd( Str $Char --> liststrint) ...
>> >  >>
>> >  >> I am confused.
>> >  >>
>> >  >> I want to get the --> syntax correct for `return $Char,
>> > ord($Char)`
>> >
>> > On 10/12/18 1:49 PM, Brad Gilbert wrote:
>> >  > That would be `List`
>> >  >
>> >  >  sub RtnOrd( Str $Char --> List ){ $Char, ord($Char) }
>> >  >  say RtnOrd "A"
>> >  >  # (A 65)
>> >
>> > $ p6 'sub RtnOrd( Str $Char --> List ){return $Char, ord($Char)};
>> say
>> > RtnOrd "A";'
>> > (A 65)
>> >
>> > But "List" does not tell my what is in the list.
>> >
>> >
>> > You can create a brand new type, a subset of Lists where the first
>> element
>> > (we refer to with [0]) is of type Str (~~ Str) and the second element
>> of
>> > the List
>> > (we refer to with [1]) is of type Int (~~ Int).
>> >
>> > Define it like this:
>> > subset list-str-int of List where .[0] ~~ Str && .[1] ~~ Int;
>> >
>> > then you can say that your routine returns a list that looks like that:
>> >
>> >   sub RtnOrd( Str $Char --> list-str-int)
>> >
>>
>> Is there any way to say I am return two things: a string and an integer?
>>
>

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


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
>
>  $ 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 value (return constraints only allowed at the end
> of the signature)
>  at -e:1
>  --> sub RtnOrd( Str $Char --> Str⏏, Int ){return $Char,
> ord($Char)}; say R
>
>
> Many thanks,
> -T
>
>
> No pointy:
>
> $ p6 'sub RtnOrd( Str $Char ){return $Char, ord($Char)}; say RtnOrd "A";'
> (A 65)
>


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


Re: Atom file icons of executables

2018-10-11 Thread Brandon Allbery
But there are quasi-standard APIs for accessing that information. In
particular, Javascript has access to such APIs.

And trying to do this without integrating with OS services has its own
complexities, like how you handle 'execute bit' on Windows which doesn't
have one. Which is why there are JS APIs mapping to the system versions
that handle e.g. Unix execute bit vs. Windows shell mappings.

On Thu, Oct 11, 2018 at 9:01 PM Richard Hainsworth 
wrote:

> I don't think so. The icon is inside the panel of files available for
> editing. Since atom is cross-OS it cannot rely on one desktop manager of
> one OS.
>
> On Fri, 12 Oct 2018, 02:10 Brandon Allbery,  wrote:
>
>> This will be part of the desktop manager (probably Gnome), not Atom.
>> Check the context menu for the icon in the file manager. I don't run Gnome
>> so don't know where they hide how you set it currently.
>>
>> On Thu, Oct 11, 2018 at 5:20 AM Richard Hainsworth <
>> rnhainswo...@gmail.com> wrote:
>>
>>> I use atom to edit perl6 scripts because of the nice perl6 syntax
>>> highlighting. Also I came across Atom from this group.
>>>
>>> Although files with .p6 or .pm6 have a nice camilea icon associated with
>>> them, ...
>>>
>>> ... if I give a p6 file an exec bit, the icon changes to something like
>>> an onion.
>>>
>>> I'm using Ubuntu.
>>>
>>> I've searched on Google, tried StackOverflow, and tried the Atom sites.
>>> I can't find where to look to change this behaviour.
>>>
>>> Sorry for the slightly off-topic question.
>>>
>>
>>
>> --
>> brandon s allbery kf8nh
>> allber...@gmail.com
>>
>

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


Re: Atom file icons of executables

2018-10-11 Thread Brandon Allbery
This will be part of the desktop manager (probably Gnome), not Atom. Check
the context menu for the icon in the file manager. I don't run Gnome so
don't know where they hide how you set it currently.

On Thu, Oct 11, 2018 at 5:20 AM Richard Hainsworth 
wrote:

> I use atom to edit perl6 scripts because of the nice perl6 syntax
> highlighting. Also I came across Atom from this group.
>
> Although files with .p6 or .pm6 have a nice camilea icon associated with
> them, ...
>
> ... if I give a p6 file an exec bit, the icon changes to something like
> an onion.
>
> I'm using Ubuntu.
>
> I've searched on Google, tried StackOverflow, and tried the Atom sites.
> I can't find where to look to change this behaviour.
>
> Sorry for the slightly off-topic question.
>


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


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

2018-10-11 Thread Brandon Allbery
More to the point of this, currently there is no way to reconstruct the
definition of a block, so you get its signature and an inline comment in
place of the body.

There is an easier way to see the same behavior: &Foo::Bar::zape
This is getting the block/sub as a value instead of invoking it.

Similarly, you can get something like that for subs in the setting, but
most of those will show you the dispatch proto instead because they don't
know which implementation to use:

pyanfar Z$ 6 'say &say'
proto sub say (|) {*}


On Thu, Oct 11, 2018 at 12:43 PM Siavash 
wrote:

> 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 <
> richard.hogab...@gmail.com> wrote:
>>
>> OK .. I mistakenly assumed that it should not compile from the doc
>> '(This does not work with the &zape variable)'.
>>
>> my $tmp = Foo::Bar::<&zape>;
>> 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::<&zape> # Block &zape = -> ;; $_? is raw { 
>>> #`(Block|94777643161752) ... }
>>>  say Foo::Bar::<&zape>() # zipi
>>>
>>

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


Re: slurp so many?

2018-10-07 Thread Brandon Allbery
Use the read method instead. I did say in my previous message that .read is
for bytes, .readchars is for graphemes (UTF8 characters plus any modifiers).

On Sun, Oct 7, 2018 at 11:03 PM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> On 10/7/18 7:58 PM, ToddAndMargo via perl6-users wrote:
> > On 10/7/18 7:54 PM, ToddAndMargo via perl6-users wrote:
> >> On 10/7/18 4:53 PM, Curt Tilmes wrote:
> >>>
> >>>
> >>> On Sun, Oct 7, 2018 at 7:42 PM ToddAndMargo via perl6-users
> >>> mailto:perl6-us...@perl.org>> wrote:
> >>>
> >>> I use `slurp` all the time, so of course, I can't
> >>> make heads or tails out of
> >>>
> >>> https://docs.perl6.org/routine/slurp
> >>>
> >>> I want to slurp the first 400 characters of
> >>> a file and close the handle.  Am I missing a
> >>> `so many` parameter somewhere?
> >>>
> >>>
> >>> The purpose of slurp is to read the whole file -- if you want part of
> >>> it, look for .words(), .lines(), .read(),
> >>> and for the specific use you point out, .readchars() --
> >>> https://docs.perl6.org/type/IO::Handle#method_readchars
> >>>
> >>> Something like this:
> >>>
> >>> my $io = "myfile".IO.open;
> >>> my $start = $io.readchars(400);
> >>> $io.close;
> >>>
> >>> Curt
> >>>
> >>
> >>
> >> Hi Curt,
> >>
> >> Thank you!  Readchars it is!  I will make a sub call out of it.
> >>
> >> Where is my typo?
> >>
> >> $ p6 'my $fh=open "/home/linuxutil/To", :r; my Str $f=readchars( $fh,
> >> 400 ); say so $f.constains( chr(0) );'
> >>
> >> ===SORRY!=== Error while compiling -e
> >> Undeclared routine:
> >>  readchars used at line 1
> >>
> >> $ perl6 -v
> >> This is Rakudo version 2018.06 built on MoarVM version 2018.06
> >> implementing Perl 6.c.
> >>
> >>
> >>
> >
> >
> > Oopos!  It is a method.
> >
> > $ p6 'my $fh=open "/home/linuxutil/To", :r; my Str $f = $fh.readchars(
> > 400 ); $fh.close; say so $f.constains( chr(0) );'
> >
> > Malformed UTF-8
> >in block  at -e line 1
> >
> > What is with the Malformed UTF-8?  Is readchars not binary?
> >
> > -T
> >
> >
>
>
> With a text file and with a binary file and contains speeled
> right.
>
>
> $ p6 'my $fh=open "/home/linuxutil/X11Test.pl6", :r; my Str $f =
> $fh.readchars( 400 ); $fh.close; say so $f.contains( chr(0) );'
>
> False
>
>
> $ p6 'my $fh=open "/home/linuxutil/To", :r; my Str $f = $fh.readchars(
> 400 ); $fh.close; say so $f.contains( chr(0) );'
>
> Malformed UTF-8
>in block  at -e line 1
>
> how do I rid myself oof the UTF-8 error?
>


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


Re: slurp so many?

2018-10-07 Thread Brandon Allbery
The whole point of slurp is (possibly lazily in the future) reading
everything. If you want to read by bytes, it's the read method; by lines,
it's get; for extended characters / graphemes, it's readchars. They all
have rather different intents.

On Sun, Oct 7, 2018 at 7:42 PM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> Hi All,
>
> I use `slurp` all the time, so of course, I can't
> make heads or tails out of
>
>   https://docs.perl6.org/routine/slurp
>
> I want to slurp the first 400 characters of
> a file and close the handle.  Am I missing a
> `so many` parameter somewhere?
>
> Many thanks,
> -T
>


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


Re: What is the syntax of a reference pointer in p6?

2018-10-07 Thread Brandon Allbery
He was thinking "don't make perl 5 as incompatible with perl 4".
Pass-by-reference objects make for a major change to the language's
behavior; it and its consequences are a large part of why perl 6 is
incompatible with perl 5.

On Sun, Oct 7, 2018 at 4:29 AM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> On 10/6/18 3:20 AM, JJ Merelo wrote:
> > No, we don't have that in Perl 6, explicitly so.
>
> Hi JJ,
>
> Yippee !  P6 is a wonderful clean up of P5.  I hated
> having to send arrays to subroutines as pointers.  What
> was Larry thinking !?!?!?  ( He has redeemed himself 1000+
> times over with P6.)
>
> -T
>


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


Re: flatten?

2018-10-05 Thread Brandon Allbery
Turns out I misspoke anyway; << >> isn't enough by itself.

$ p6 'my @x=; my @y=<<1 2 @x 3 4>>; say @y; dd @y;'

@y will contain (1, 2, '@x', 3, 4). (Actually, the numbers will be things
that are simultaneously numbers and strings, showing up as IntStr.new(1,
'1') and such.) '@x' is a two-character string, not the list @x or its
contents.

pyanfar Z$ 6 'my @x = ; my @y = <<1 2 @x[] 3 4>>; dd @y'
Array @y = [IntStr.new(1, "1"), IntStr.new(2, "2"), "a", "b", "c",
IntStr.new(3, "3"), IntStr.new(4, "4")]

Which flattens because it's interpolating values, since quoting constructs
produce string-like things or lists of string-like things (role Stringy),
not lists of lists. If you want a list of lists, you are better off just
using lists directly, not the quoting constructs that are intended to give
you lists of strings. This is similar to Perl 5, where qw() also doesn't
expand variables:

pyanfar Z$ perl -MData::Dumper -E 'my @x = qw(a b c); my @y = qw(1 @x
2); say Dumper(\@y)'
$VAR1 = [
  '1',
  '@x',
  '2'
];


On Fri, Oct 5, 2018 at 11:27 PM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> On 10/5/18 6:28 PM, Brandon Allbery wrote:
> > You can't with that, because < ... > acts like single quotes; '@x' there
> > is a string literal, not the list @x. If you use << ... >> then it act
> > like double quotes, and will use the list instead.
>
> I am sorry.  With the top posting, I can't tell
> what you are talking about.  I also can't tell which
> of the three question I asked that you are
> answering
>
> :'(
>
> >
> > On Fri, Oct 5, 2018 at 9:23 PM ToddAndMargo via perl6-users
> > mailto:perl6-us...@perl.org>> wrote:
> >
> > On 10/5/18 6:09 PM, Brandon Allbery wrote:
> >  > That's where the | comes in. If you say
> >  >
> >  >  my @b = (1, |@a, 2);
> >  >
> >  > then you get (1, 'a', 'b', 'c', 2) like in Perl 5. But you can
> > specify
> >  > what gets flattened, so you can choose to flatten some arrays but
> > not
> >  > others if you need to for some reason:
> >  >
> >  >  my @b = (1, |@b, 2, @b, 3);
> >  >
> >  > gives you (1, 'a', 'b', 'c', 2, ('a', 'b', 'c'), 3). This often
> > matters
> >  > in parameter lists, if you want one of the parameters to be the
> list
> >  > itself instead of it being spread across multiple parameters. In
> > Perl 5
> >  > you had to say \@b to pass a ref to the list instead, and the sub
> > had to
> >  > know it was getting a scalar containing an arrayref and needed to
> >  > dereference it (if you don't know, don't ask; it's ugly).
> >
> > Am I correct in my assumption?
> >
> > A little off the question, but how do I address something
> > inside a nested array?
> >
> > In the following, how do I get at the "b"
> >
> >
> > $ p6 'my @x=; my @y=<1 2 @x 3 4>; say @y; dd @y;'
> >
> > [1 2 @x 3 4]
> >
> > Array @y = [IntStr.new(1, "1"), IntStr.new(2, "2"), "\@x",
> > IntStr.new(3,
> > "3"), IntStr.new(4, "4")]
> >
> > Also, how do I flatten @y above?
> >
> > Thank you for the help!
> > -T
> >
> >
> >
> > --
> > brandon s allbery kf8nh
> > allber...@gmail.com <mailto:allber...@gmail.com>
>
>
> --
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~
>


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


Re: flatten?

2018-10-05 Thread Brandon Allbery
You can't with that, because < ... > acts like single quotes; '@x' there is
a string literal, not the list @x. If you use << ... >> then it act like
double quotes, and will use the list instead.

On Fri, Oct 5, 2018 at 9:23 PM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> On 10/5/18 6:09 PM, Brandon Allbery wrote:
> > That's where the | comes in. If you say
> >
> >  my @b = (1, |@a, 2);
> >
> > then you get (1, 'a', 'b', 'c', 2) like in Perl 5. But you can specify
> > what gets flattened, so you can choose to flatten some arrays but not
> > others if you need to for some reason:
> >
> >  my @b = (1, |@b, 2, @b, 3);
> >
> > gives you (1, 'a', 'b', 'c', 2, ('a', 'b', 'c'), 3). This often matters
> > in parameter lists, if you want one of the parameters to be the list
> > itself instead of it being spread across multiple parameters. In Perl 5
> > you had to say \@b to pass a ref to the list instead, and the sub had to
> > know it was getting a scalar containing an arrayref and needed to
> > dereference it (if you don't know, don't ask; it's ugly).
>
> Am I correct in my assumption?
>
> A little off the question, but how do I address something
> inside a nested array?
>
> In the following, how do I get at the "b"
>
>
> $ p6 'my @x=; my @y=<1 2 @x 3 4>; say @y; dd @y;'
>
> [1 2 @x 3 4]
>
> Array @y = [IntStr.new(1, "1"), IntStr.new(2, "2"), "\@x", IntStr.new(3,
> "3"), IntStr.new(4, "4")]
>
> Also, how do I flatten @y above?
>
> Thank you for the help!
> -T
>


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


Re: flatten?

2018-10-05 Thread Brandon Allbery
That's where the | comes in. If you say

my @b = (1, |@a, 2);

then you get (1, 'a', 'b', 'c', 2) like in Perl 5. But you can specify what
gets flattened, so you can choose to flatten some arrays but not others if
you need to for some reason:

my @b = (1, |@b, 2, @b, 3);

gives you (1, 'a', 'b', 'c', 2, ('a', 'b', 'c'), 3). This often matters in
parameter lists, if you want one of the parameters to be the list itself
instead of it being spread across multiple parameters. In Perl 5 you had to
say \@b to pass a ref to the list instead, and the sub had to know it was
getting a scalar containing an arrayref and needed to dereference it (if
you don't know, don't ask; it's ugly).

On Fri, Oct 5, 2018 at 9:01 PM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> >> On Fri, Oct 5, 2018 at 7:44 PM ToddAndMargo via perl6-users
> >> mailto:perl6-us...@perl.org>> wrote:
> >>
> >> On 10/5/18 3:15 PM, Ralph Mellor wrote:
> >>  > Well I guess my first way of explaining it was a complete bust.
> :)
> >>  >
> >>  > It's not going to be worth me discussing your reply to my first
> >> attempt.
> >>
> >> Hi Ralph,
> >>
> >> Thank you!  I am going to have to save it for later and read it
> >> over REAL SLOW!
> >>
> >> :-)
> >>
> >> -T
>
> On 10/5/18 5:50 PM, Brandon Allbery wrote:
> > You know how in perl 5, if you do:
> >
> > my @a = qw(a b c);
> > my @b = (1, @a, 2);
> >
> > @b will be (1, 'a', 'b', 'c', 2)? That's flattening. $b[1] will be 'a'.
> > Perl 5 doesn't really understand nested data structures, so you have to
> > simulate them with refs. If you use [@a] instead, $b[1] will contain an
> > arrayref that must be dereferenced to get at its contents. (Which it
> > tries to hide from you by letting you say $b[1][0] instead of
> > $b[1]->[0], which is what it's really doing. But if you say 'my $c =
> > $b[1]', you need $c->[0] to get its first item, not $c[0]. Refs are
> > better than what we had to do in Perl 4 with globs, but they're still
> > kinda icky.)
> >
> > Perl 6 understands nested lists and other data structures, and doesn't
> > flatten. If you do the above in Perl 6, you get (1, ('a', 'b', 'c'), 2)
> > with a nested list. @b[1] is ('a', 'b', 'c') and @b[1][0] is 'a', and
> > there's no hidden dereference operator involved, nor a "magic" arrayref
> > to be dereferenced.
> >
>
> Hi Brandon,
>
> I am following
>
>  my @a = qw(a b c);
>  my @b = (1, @a, 2);
>
>  @b is (1, ('a', 'b', 'c'), 2)
>
> So would flattening @b be (1 a b c 2) ?
>
> If I wanted to assign a flattened @b to @c, how would I do that?
>
> Thank you for the help!
>
> -T
>


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


Re: flatten?

2018-10-05 Thread Brandon Allbery
You know how in perl 5, if you do:

   my @a = qw(a b c);
   my @b = (1, @a, 2);

@b will be (1, 'a', 'b', 'c', 2)? That's flattening. $b[1] will be 'a'.
Perl 5 doesn't really understand nested data structures, so you have to
simulate them with refs. If you use [@a] instead, $b[1] will contain an
arrayref that must be dereferenced to get at its contents. (Which it tries
to hide from you by letting you say $b[1][0] instead of $b[1]->[0], which
is what it's really doing. But if you say 'my $c = $b[1]', you need $c->[0]
to get its first item, not $c[0]. Refs are better than what we had to do in
Perl 4 with globs, but they're still kinda icky.)

Perl 6 understands nested lists and other data structures, and doesn't
flatten. If you do the above in Perl 6, you get (1, ('a', 'b', 'c'), 2)
with a nested list. @b[1] is ('a', 'b', 'c') and @b[1][0] is 'a', and
there's no hidden dereference operator involved, nor a "magic" arrayref to
be dereferenced.

On Fri, Oct 5, 2018 at 7:44 PM ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> On 10/5/18 3:15 PM, Ralph Mellor wrote:
> > Well I guess my first way of explaining it was a complete bust. :)
> >
> > It's not going to be worth me discussing your reply to my first attempt.
>
> Hi Ralph,
>
> Thank you!  I am going to have to save it for later and read it
> over REAL SLOW!
>
> :-)
>
> -T
>


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


Re: routine declaration line question

2018-10-05 Thread Brandon Allbery
Haskell supports it via typeclass resolution, which is mostly a source of
confusion to newcomers who assume (read :: Read a => String -> a) must be
deciding what to produce based on the String because they're not expecting
return type polymorphism. It doesn't seem to be a problem otherwise.
(Multiparameter typeclasses have a bigger problem, return type polymorphism
being only one of several ways to expose it.)

On Fri, Oct 5, 2018 at 2:03 PM Trey Harris  wrote:

>
>
> On Fri, Oct 5, 2018 at 1:13 PM Brandon Allbery 
> wrote:
>
>> My problem with it being in the signature is still that it doesn't say
>> which part of the contract it applies to; it appears to be claiming it's
>> part of dispatch, when it's not.
>>
>
> Explicit argument polymorphism has been shown to be useful and increasing
> in elegance more often than it causes debugging complexity, while return
> polymorphism has generally been a nightmare in languages that have tried
> it, no? True that no other polymorphic language (AFAIK, but haven’t looked
> lately) has true multimethods, but my guess is that return polymorphism
> would be even worse within multiple dispatch than in single-dispatch
> languages.
>
> Not that I thought you were arguing that --> *should* apply to dispatch,
> just trying to get everyone on the same page in case we’re not (and maybe
> I’m the one who needs my page flipped to the same place in the hymnal).
>
> But right now we have a situation where “everything within the signature 
> *except
> for* the return constraint can participate in multi dispatch”, which does
> feel weird. But is that actually true? Something’s nagging at me that
> there’s something else in this category as well, but I can’t think what.
> (Recursive multi dispatch on signatures of multi Callable arguments,
> maybe? I would try but my machine’s offline upgrading….) If there are more
> rules about what participates in multi dispatch than “change anything in
> the signature to the left of the --> and you’re good”, then it’s probably
> acceptable for --> to not participate either—it’s already more complex
> than it looks.
> ​
>
>
>
>>
>> On Fri, Oct 5, 2018 at 12:01 PM Larry Wall  wrote:
>>
>>> On Thu, Oct 04, 2018 at 09:35:08PM +0200, JJ Merelo wrote:
>>> : El jue., 4 oct. 2018 21:21, Brandon Allbery 
>>> escribió:
>>> :
>>> : > I don't think we've reached the point of such conventions yet. And
>>> there's
>>> : > some history here, in --> not having done anything in the early days
>>> except
>>> : > possibly slow things down, and between --> and 'returns' (which is
>>> now
>>> : > deprecated).
>>> : >
>>> :
>>> : Not yet. Maybe never...
>>>
>>> --> generalizes to pointy blocks and such.  'returns' doesn't.
>>>
>>> --> allows return of explicit literal Nil and True and 42.  'returns'
>>> doesn't.
>>>
>>> --> makes the return an official part of the routine's contract.
>>> 'returns' doesn't.
>>>
>>> For various purposes it would be nice to know we have the entire in/out
>>> contract
>>> before we start processing all the oh-by-the-way traits that can turn
>>> the contract
>>> into a time-traveling brain pretzel.  For instance, what if one of the
>>> phaser traits
>>> needs to know will be returned, and the 'returns' comes after that?
>>> Putting in error
>>> messages that say "Too late for returns trait" is a design smell...
>>>
>>> So never say never.  :)
>>>
>>> Larry
>>>
>>
>>
>> --
>> brandon s allbery kf8nh
>> allber...@gmail.com
>>
>

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


Re: routine declaration line question

2018-10-05 Thread Brandon Allbery
My problem with it being in the signature is still that it doesn't say
which part of the contract it applies to; it appears to be claiming it's
part of dispatch, when it's not.

On Fri, Oct 5, 2018 at 12:01 PM Larry Wall  wrote:

> On Thu, Oct 04, 2018 at 09:35:08PM +0200, JJ Merelo wrote:
> : El jue., 4 oct. 2018 21:21, Brandon Allbery 
> escribió:
> :
> : > I don't think we've reached the point of such conventions yet. And
> there's
> : > some history here, in --> not having done anything in the early days
> except
> : > possibly slow things down, and between --> and 'returns' (which is now
> : > deprecated).
> : >
> :
> : Not yet. Maybe never...
>
> --> generalizes to pointy blocks and such.  'returns' doesn't.
>
> --> allows return of explicit literal Nil and True and 42.  'returns'
> doesn't.
>
> --> makes the return an official part of the routine's contract.
> 'returns' doesn't.
>
> For various purposes it would be nice to know we have the entire in/out
> contract
> before we start processing all the oh-by-the-way traits that can turn the
> contract
> into a time-traveling brain pretzel.  For instance, what if one of the
> phaser traits
> needs to know will be returned, and the 'returns' comes after that?
> Putting in error
> messages that say "Too late for returns trait" is a design smell...
>
> So never say never.  :)
>
> Larry
>


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


Re: routine declaration line question

2018-10-04 Thread Brandon Allbery
I figure they'll evolve with wider use, but we certainly aren't there yet.
On the other hand, discussions like this will help shape that evolution.

On Thu, Oct 4, 2018 at 3:35 PM JJ Merelo  wrote:

>
>
> El jue., 4 oct. 2018 21:21, Brandon Allbery 
> escribió:
>
>> I don't think we've reached the point of such conventions yet. And
>> there's some history here, in --> not having done anything in the early
>> days except possibly slow things down, and between --> and 'returns' (which
>> is now deprecated).
>>
>
> Not yet. Maybe never...
>
>>
>> On Thu, Oct 4, 2018 at 3:13 PM 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 the return value, though it exists,
>>> is incidental and probably from "falling off the end" or using `return` as
>>> a control-flow jump.
>>> On Thu, Oct 4, 2018 at 15:04 Brandon Allbery 
>>> wrote:
>>>
>>>> Arguably it should be --> Any, since Mu vs. Any has meaning with
>>>> respect to Junctions. But in this case it's just not stating a redundancy.
>>>>
>>>> The way you'd phrased it makes it sound like it's an explicit
>>>> no-meaningful-result, as opposed to 'we don't know or care'.
>>>>
>>>> On Thu, Oct 4, 2018 at 3:02 PM Trey Harris  wrote:
>>>>
>>>>> Ah (replying to both Brandon and JJ since their replies crossed):
>>>>>
>>>>> So `--> Mu` is not a sufficient and/or correct return constraint for
>>>>> things like AT-POS because why, then?
>>>>> On Thu, Oct 4, 2018 at 14:56 Brandon Allbery 
>>>>> wrote:
>>>>>
>>>>>> I think they meant more like my AT-POS example: the point is the
>>>>>> return value, but you can't say ahead of time what type it will have.
>>>>>>
>>>>>> On Thu, Oct 4, 2018 at 2:48 PM Trey Harris  wrote:
>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Oct 4, 2018 at 02:13 JJ Merelo  wrote:
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> El jue., 4 oct. 2018 a las 3:36, Trey Harris ()
>>>>>>>> escribió:
>>>>>>>>
>>>>>>>>> _All_ routines in Perl 6 return _something._ A lack of a "-->"
>>>>>>>>> simply indicates stylistically that the return is not useful because 
>>>>>>>>> it's
>>>>>>>>> whatever "falls off the end". (There's a bit of variance here as I'm 
>>>>>>>>> not
>>>>>>>>> sure it's a convention everyone has followed.) It's equivalent to 
>>>>>>>>> "--> Mu"
>>>>>>>>> because anything that could "fall of the end" is Mu.
>>>>>>>>>
>>>>>>>>
>>>>>>>> No, it means that it's not constrained to a type. It can still
>>>>>>>> return something, but it can be anything.
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> I get all that, except for the "No" at the front. ;-)
>>>>>>>
>>>>>>> Or were you talking about the "not useful" bit? Yes, of course in
>>>>>>> any given codebase, the lack of a return value has no more or less 
>>>>>>> meaning
>>>>>>> than a lack of any constraint. The programmer may not like using
>>>>>>> constraints at all and treats Perl 6 like Perl 5 in the respect of 
>>>>>>> wanting
>>>>>>> arbitrarily mungible values.
>>>>>>>
>>>>>>> But the word "stylistically" was important, as I was responding to
>>>>>>> Todd's question about the docs—I think a lack of a return value in the 
>>>>>>> docs
>>>>>>> (at least, the ones I could come up with in a grep pattern on my 
>>>>>>> checkout
>>>>>>> of docs) does tend to indicate that the return is not useful, that the
>>>>>>> routine is a "procedure" run for its side effects rather than for
>>>>>>> evaluation.
>>>>>>>
>>>>>>> Is that what you meant?
>>>>>>>
>>>>>>> If you were saying in "it can still return something, but can be
>>>>>>> anything", that "anything ⊃ (is a strict superset of) `Mu`", then I
>>>>>>> don't understand, because I thought all values conformed to Mu.
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> --
>>>>>> brandon s allbery kf8nh
>>>>>> allber...@gmail.com
>>>>>>
>>>>>
>>>>
>>>> --
>>>> brandon s allbery kf8nh
>>>> allber...@gmail.com
>>>>
>>>
>>
>> --
>> brandon s allbery kf8nh
>> allber...@gmail.com
>>
>

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


Re: routine declaration line question

2018-10-04 Thread Brandon Allbery
I don't think we've reached the point of such conventions yet. And there's
some history here, in --> not having done anything in the early days except
possibly slow things down, and between --> and 'returns' (which is now
deprecated).

On Thu, Oct 4, 2018 at 3:13 PM 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 the return value, though it exists,
> is incidental and probably from "falling off the end" or using `return` as
> a control-flow jump.
> On Thu, Oct 4, 2018 at 15:04 Brandon Allbery  wrote:
>
>> Arguably it should be --> Any, since Mu vs. Any has meaning with respect
>> to Junctions. But in this case it's just not stating a redundancy.
>>
>> The way you'd phrased it makes it sound like it's an explicit
>> no-meaningful-result, as opposed to 'we don't know or care'.
>>
>> On Thu, Oct 4, 2018 at 3:02 PM Trey Harris  wrote:
>>
>>> Ah (replying to both Brandon and JJ since their replies crossed):
>>>
>>> So `--> Mu` is not a sufficient and/or correct return constraint for
>>> things like AT-POS because why, then?
>>> On Thu, Oct 4, 2018 at 14:56 Brandon Allbery 
>>> wrote:
>>>
>>>> I think they meant more like my AT-POS example: the point is the return
>>>> value, but you can't say ahead of time what type it will have.
>>>>
>>>> On Thu, Oct 4, 2018 at 2:48 PM Trey Harris  wrote:
>>>>
>>>>>
>>>>>
>>>>> On Thu, Oct 4, 2018 at 02:13 JJ Merelo  wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> El jue., 4 oct. 2018 a las 3:36, Trey Harris ()
>>>>>> escribió:
>>>>>>
>>>>>>> _All_ routines in Perl 6 return _something._ A lack of a "-->"
>>>>>>> simply indicates stylistically that the return is not useful because 
>>>>>>> it's
>>>>>>> whatever "falls off the end". (There's a bit of variance here as I'm not
>>>>>>> sure it's a convention everyone has followed.) It's equivalent to "--> 
>>>>>>> Mu"
>>>>>>> because anything that could "fall of the end" is Mu.
>>>>>>>
>>>>>>
>>>>>> No, it means that it's not constrained to a type. It can still return
>>>>>> something, but it can be anything.
>>>>>>
>>>>>
>>>>>
>>>>> I get all that, except for the "No" at the front. ;-)
>>>>>
>>>>> Or were you talking about the "not useful" bit? Yes, of course in any
>>>>> given codebase, the lack of a return value has no more or less meaning 
>>>>> than
>>>>> a lack of any constraint. The programmer may not like using constraints at
>>>>> all and treats Perl 6 like Perl 5 in the respect of wanting arbitrarily
>>>>> mungible values.
>>>>>
>>>>> But the word "stylistically" was important, as I was responding to
>>>>> Todd's question about the docs—I think a lack of a return value in the 
>>>>> docs
>>>>> (at least, the ones I could come up with in a grep pattern on my checkout
>>>>> of docs) does tend to indicate that the return is not useful, that the
>>>>> routine is a "procedure" run for its side effects rather than for
>>>>> evaluation.
>>>>>
>>>>> Is that what you meant?
>>>>>
>>>>> If you were saying in "it can still return something, but can be
>>>>> anything", that "anything ⊃ (is a strict superset of) `Mu`", then I
>>>>> don't understand, because I thought all values conformed to Mu.
>>>>>
>>>>>
>>>>
>>>> --
>>>> brandon s allbery kf8nh
>>>> allber...@gmail.com
>>>>
>>>
>>
>> --
>> brandon s allbery kf8nh
>> allber...@gmail.com
>>
>

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


Re: bitwise or?

2018-10-04 Thread Brandon Allbery
It's fine syntactically, but I think has no effect because it'd be '$v =
$v' after the '+|='. Conceivably some future version of rakudo could warn
about it having no effect.

On Thu, Oct 4, 2018 at 3:09 PM ToddAndMargo  wrote:

> On 10/4/18 12:06 PM, ToddAndMargo wrote:
> > On 10/4/18 12:00 PM, JJ Merelo wrote:
> >>
> >>
> >> El jue., 4 oct. 2018 a las 20:58, ToddAndMargo ( >> >) escribió:
> >>
> >> Hi All,
> >>
> >> I am trying to come up with something like +=
> >>
> >>$ p6 'my $v = 32; $v += 2; say $v;'
> >>34
> >>
> >> to replace
> >>
> >>$ p6 'my $v = 0b0010; $v = $v +| 0b0001; say $v;'
> >>48
> >>
> >>
> >> But I obviously have something wrong:
> >>
> >>$ p6 'my $v = 0b0010; $v +| 0b0001; say $v;'
> >>WARNINGS for -e:
> >>Useless use of "+|" in expression "$v +| 0b0001"
> >>in sink context (line 1)
> >>
> >>
> >> You are not assigning the result of the operation to anything.
> >>
> >>  say my $v = 0b0010; $v +|= 0b0001; say $v;   # OUTPUT:
> >> «32␤48␤»
> >>
> >> Cheers
> >>
> >> JJ
> >
> >
> > Hi JJ,
> >
> > I missed an "=".  Thank you!
> >
> > $ p6 'my $v = 0b0010; $v = $v +|= 0b0001; say $v;'
> > 48
> >
> > $ p6 'my $v = 0b0010; $v = $v +|= 0b00010001; say $v;'
> > 49
> >
> > -T
> >
> >
>
>
> OOOPS!!!  I wonder why that did not error out?  had an extra `$v =`
>
>
> Corrected:
>
> $ p6 'my $v = 0b0010; $v +|= 0b00010001; say $v;'
> 49
>
>
> --
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~
>


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


Re: routine declaration line question

2018-10-04 Thread Brandon Allbery
Arguably it should be --> Any, since Mu vs. Any has meaning with respect to
Junctions. But in this case it's just not stating a redundancy.

The way you'd phrased it makes it sound like it's an explicit
no-meaningful-result, as opposed to 'we don't know or care'.

On Thu, Oct 4, 2018 at 3:02 PM Trey Harris  wrote:

> Ah (replying to both Brandon and JJ since their replies crossed):
>
> So `--> Mu` is not a sufficient and/or correct return constraint for
> things like AT-POS because why, then?
> On Thu, Oct 4, 2018 at 14:56 Brandon Allbery  wrote:
>
>> I think they meant more like my AT-POS example: the point is the return
>> value, but you can't say ahead of time what type it will have.
>>
>> On Thu, Oct 4, 2018 at 2:48 PM Trey Harris  wrote:
>>
>>>
>>>
>>> On Thu, Oct 4, 2018 at 02:13 JJ Merelo  wrote:
>>>
>>>>
>>>>
>>>> El jue., 4 oct. 2018 a las 3:36, Trey Harris ()
>>>> escribió:
>>>>
>>>>> _All_ routines in Perl 6 return _something._ A lack of a "-->" simply
>>>>> indicates stylistically that the return is not useful because it's 
>>>>> whatever
>>>>> "falls off the end". (There's a bit of variance here as I'm not sure it's 
>>>>> a
>>>>> convention everyone has followed.) It's equivalent to "--> Mu" because
>>>>> anything that could "fall of the end" is Mu.
>>>>>
>>>>
>>>> No, it means that it's not constrained to a type. It can still return
>>>> something, but it can be anything.
>>>>
>>>
>>>
>>> I get all that, except for the "No" at the front. ;-)
>>>
>>> Or were you talking about the "not useful" bit? Yes, of course in any
>>> given codebase, the lack of a return value has no more or less meaning than
>>> a lack of any constraint. The programmer may not like using constraints at
>>> all and treats Perl 6 like Perl 5 in the respect of wanting arbitrarily
>>> mungible values.
>>>
>>> But the word "stylistically" was important, as I was responding to
>>> Todd's question about the docs—I think a lack of a return value in the docs
>>> (at least, the ones I could come up with in a grep pattern on my checkout
>>> of docs) does tend to indicate that the return is not useful, that the
>>> routine is a "procedure" run for its side effects rather than for
>>> evaluation.
>>>
>>> Is that what you meant?
>>>
>>> If you were saying in "it can still return something, but can be
>>> anything", that "anything ⊃ (is a strict superset of) `Mu`", then I
>>> don't understand, because I thought all values conformed to Mu.
>>>
>>>
>>
>> --
>> brandon s allbery kf8nh
>> allber...@gmail.com
>>
>

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


Re: bitwise or?

2018-10-04 Thread Brandon Allbery
You're not doing anything with '$v +| 0b0001'. Were you looking for
something like '+|='? (Which I think should work.)

On Thu, Oct 4, 2018 at 2:58 PM ToddAndMargo  wrote:

> Hi All,
>
> I am trying to come up with something like +=
>
>   $ p6 'my $v = 32; $v += 2; say $v;'
>   34
>
> to replace
>
>   $ p6 'my $v = 0b0010; $v = $v +| 0b0001; say $v;'
>   48
>
>
> But I obviously have something wrong:
>
>   $ p6 'my $v = 0b0010; $v +| 0b0001; say $v;'
>   WARNINGS for -e:
>   Useless use of "+|" in expression "$v +| 0b0001"
>   in sink context (line 1)
>
>   32
>
> Where is my goof?
>
> Many thanks,
> -T
>


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


Re: routine declaration line question

2018-10-04 Thread Brandon Allbery
I think they meant more like my AT-POS example: the point is the return
value, but you can't say ahead of time what type it will have.

On Thu, Oct 4, 2018 at 2:48 PM Trey Harris  wrote:

>
>
> On Thu, Oct 4, 2018 at 02:13 JJ Merelo  wrote:
>
>>
>>
>> El jue., 4 oct. 2018 a las 3:36, Trey Harris () escribió:
>>
>>> _All_ routines in Perl 6 return _something._ A lack of a "-->" simply
>>> indicates stylistically that the return is not useful because it's whatever
>>> "falls off the end". (There's a bit of variance here as I'm not sure it's a
>>> convention everyone has followed.) It's equivalent to "--> Mu" because
>>> anything that could "fall of the end" is Mu.
>>>
>>
>> No, it means that it's not constrained to a type. It can still return
>> something, but it can be anything.
>>
>
>
> I get all that, except for the "No" at the front. ;-)
>
> Or were you talking about the "not useful" bit? Yes, of course in any
> given codebase, the lack of a return value has no more or less meaning than
> a lack of any constraint. The programmer may not like using constraints at
> all and treats Perl 6 like Perl 5 in the respect of wanting arbitrarily
> mungible values.
>
> But the word "stylistically" was important, as I was responding to Todd's
> question about the docs—I think a lack of a return value in the docs (at
> least, the ones I could come up with in a grep pattern on my checkout of
> docs) does tend to indicate that the return is not useful, that the routine
> is a "procedure" run for its side effects rather than for evaluation.
>
> Is that what you meant?
>
> If you were saying in "it can still return something, but can be
> anything", that "anything ⊃ (is a strict superset of) `Mu`", then I don't
> understand, because I thought all values conformed to Mu.
>
>

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


Re: routine declaration line question

2018-10-04 Thread Brandon Allbery
Consider a function which returns the element at a given position in a list:

method AT-POS(\position)

The only thing you can say about the result type is that it's whatever the
type of the element at that position is. So it doesn't bother specifying a
type at all, because the prototype can't know ahead of time what lists you
might use it on contain. If you need to know, you can smartmatch the type
of the returned value afterward or use the .^can MOP method to see if it
supports a named method, etc.

(The \ in there means it's a raw value, for speed; AT-POS, as suggested by
being all uppercase, is used internally for a bunch of things and wants to
be as fast as possible, so it's using some internal tricks.)

On Thu, Oct 4, 2018 at 1:51 AM ToddAndMargo  wrote:

> >>
>  On Wed, Oct 3, 2018 at 7:21 PM ToddAndMargo   > wrote:
> 
>    >> On 04/10/2018 03:07, ToddAndMargo wrote:
>    >>> Hi All,
>    >>>
>    >>> In another thread, Timo wrote me:
>    >>>
>    >>> The "-->" part of the signature is optional. If
> there isn't
>    >>> one, it defaults to Mu, which is the type that
> everything
>    >>> conforms to, i.e. the sub or method that either has
>   "--> Mu"
>    >>> explicitly, or has it by leaving it out, may return
>    >>> absolutely whatever it wants.
>    >>>
>    >>> After all, the "-->" part is a constraint, and it
> gets
>    >>> validated at compile time every time a sub or method
>    >>> returns.
>    >>>
>    >>> I got to thinking, some routines do not return anything.
> Without
>    >>> the "-->" constraint, how am I to determine if something is
>    >>> being returned?
>    >>>
>    >>> Yours in confusion,
>    >>> -T
> 
>   On 10/3/18 6:44 PM, Timo Paulssen wrote:
>    > I just spotted a grave mistake in my earlier mail:
>    >
>    > the --> constraints are validated at *run* time, not
> *compile* time;
>    > that's a very big difference, and an important one. Of course
> "every
>    > time a sub or method returns" doesn't make much sense if i
> had meant
>    > "compile time", but I felt i should really point it out before
>   causing
>    > too much confusion.
>    >
> 
>   Hi Timo,
> 
>   Thank you for the help over on the chat line with IN!
> 
>   My confusion is not that it returns something (Mu).
> 
>   My confusion is "what" it returns.  And not all subs
>   return things, like "say" and "print".
> 
>   I am presuming I am to pick the "what" from context
>   from the examples?
> 
>   -T
> >>
> >> On 10/3/18 7:53 PM, yary wrote:
> >>>   > And not all subs return things, like "say" and "print".
> >>>
> >>> say and print return true if the print succeeded, just like in perl 5.
> >>>
>  say say "hi";
> >>>
> >>> hi
> >>>
> >>> True
> >>>
> >>>
> >>> Useful if printing to a filehandle, and the file you're writing to is
> on
> >>> a volume that fills up. Or a network drive that goes away. You do check
> >>> for those, right?
> >>>
> >>>
> >>> -y
> >>
> >> Hi Yary,
> >>
> >> Ya,  my misunderstanding.  Trey just taught me that.  Home
> >> brew ones too.
> >>
> >> $ p6 'sub x($Str) {say $Str};say x("y");'
> >> y
> >> True
> >>
> >>
> >> I think where I got mixed up was not realizing that the
> >> things subs return can be ignored.  And it is not like I
> >> don't do that all the time either.  I think I just
> >> spaced as in Modula2, you get the finger shaken at you.
> >>
> >> Now All I have to figure out is how tot tell "what" is being
> >> returned.  Am I suppose to pick that up from context?
> >>
> >> -T
>
>
> On 10/3/18 10:02 PM, Brad Gilbert wrote:
>  > If a routine does not declare it's return type, absolutely anything
>  > can be returned.
>  >
>  > One reason may be that its return value isn't really useful.
>  >
>  > It could be that the writer didn't think to declare it. (or didn't
> want to)
>  >
>  > Another possibility is that the potential returned values are of many
>  > different types.
>  >
>  > ---
>  >
>  > Note that any returned value that gets ignored will get sunk.
>  > (That means the `.sink()` method will get called)
>  >
>  >  class Baz {
>  >  method sink () { say 'the result of foo() was sunk' }
>  >  }
>  >  sub foo () {
>  >  Baz.new
>  >  }
>  >
>  >  foo(); # the result of foo() was sunk
>  >
>  > So I suppose it is similar to Modula2, except it is up to the writer
>  > of the class if they shake their finger at you.
>  > On Wed, Oct 3, 2018 at 10:26 PM ToddAndMargo 
>
> Thank you.  The default return is Mu.  That I get.
>
> How do I figure out what data is being return

Re: routine declaration line question

2018-10-03 Thread Brandon Allbery
Perl 6 routines always return *something*; if you don't return anything
explicitly, it will return the result of the last statement/expression, or
Mu as a last resort. (Mu is the "least defined value" in Perl 6. Any is
somewhat more common, but is slightly more defined since it can participate
in junction autothreading.) It's analogous to Perl 5 returning undef if you
don't give it something else to return.

On Wed, Oct 3, 2018 at 9:07 PM ToddAndMargo  wrote:

> Hi All,
>
> In another thread, Timo wrote me:
>
> The "-->" part of the signature is optional. If there isn't
> one, it defaults to Mu, which is the type that everything
> conforms to, i.e. the sub or method that either has "--> Mu"
> explicitly, or has it by leaving it out, may return
> absolutely whatever it wants.
>
> After all, the "-->" part is a constraint, and it gets
> validated at compile time every time a sub or method
> returns.
>
> I got to thinking, some routines do not return anything.  Without
> the "-->" constraint, how am I to determine if something is
> being returned?
>
> Yours in confusion,
> -T
>


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


Re: No. It is lucid! Re: Could this be any more obscure?

2018-10-01 Thread Brandon Allbery
That just sounds like the backing store got restored from backup, losing
anything added after the backup was taken. Which is not the best way to do
things (incrementals are nice), but if things had gone wrong enough might
have been the best they could do.

On Mon, Oct 1, 2018 at 7:13 PM ToddAndMargo  wrote:

> On 9/30/18 9:11 PM, Richard Hainsworth wrote:
> > your 'perl' box was corrupted.
>
>
> Somewhere the imap daemons got appeased and suddenly a day later,
> I watched it all come blazing back.
>
> Hopefully tomorrow I will get a chance to read over what yo wrote.
>
> By the way, the eMail I send about the thread disappearing
> got removed when the rest came back.   Hmm
>


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


Re: A problem with native CArrays

2018-09-30 Thread Brandon Allbery
Might be because there's a prefix form of + with a wider type? "Every DWIM
has a WAT"

On Sun, Sep 30, 2018 at 9:55 AM Fernando Santagata <
nando.santag...@gmail.com> wrote:

> What I was pointing out is that the '*' operator outputs an error, and I
> was expecting that, while the '+' doesn't.
> Besides, the '+' delivers the correct result, which apparently indicates
> that the two operators are treated differently.
>
> I was trying to understand whether this behavior is inherent to the Perl 6
> type system or it's just a bug.
>
> On Sun, Sep 30, 2018, 12:27 JJ Merelo  wrote:
>
>> This works:
>>
>> my int32 $a = 3; my int32 $b = 7; say $a * $b # OUTPUT: «21␤»
>>
>> El dom., 30 sept. 2018 a las 11:28, Fernando Santagata (<
>> nando.santag...@gmail.com>) escribió:
>>
>>> Hi,
>>>
>>> I was hunting for a bug in my code, this one:
>>>
>>> my @a := CArray[int32].new: 6,3;
>>> say [+] @a; # it should be "say [+] @a.list;"
>>>
>>> That statement prints "9", while changing the '+' with a '*' it
>>> generates an error, as it should:
>>>
>>> Cannot resolve caller Numeric(NativeCall::Types::CArray[int32]: ); none
>>> of these signatures match:
>>> (Mu:U \v: *%_)
>>>
>>> Is this a bug, an inconsistency, or a necessary evil?
>>>
>>
>> It's difficult to say. Some conversion is taking place somewhere to
>> Numeric, and it's getting stuff it does not like. The type is
>> NativeCall::Types::CArray[int32].new and it's being considered a single
>> item; it's attempting conversion to Numeric. The thing here is that CArray
>> is actually not an Array; it inherits directly from Any:
>>
>> say @a.^mro; # OUTPUT: «((CArray[int32]) (CArray) (Any) (Mu))␤»
>>
>> It does include a `list` for convenience, but it's not, by itself, a
>> list. That operator does not do the conversion, but expects it to be a
>> list, hence the error.
>>
>> Hope this helps
>>
>> JJ
>>
>

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


Re: Could this be any more obscure?

2018-09-28 Thread Brandon Allbery
I'm not sure it's any better than my attempt; it has that "people's eyes
will glaze over" feel to it.

On Fri, Sep 28, 2018 at 9:50 PM Mark Devine  wrote:

> Kudos to the Benevolent Dictator!
>
> I'll have to loop over this a few times, but it's a blast...
>
> Mark
>
> -Original Message-
> From: Larry Wall 
> Sent: Friday, September 28, 2018 21:28
> To: ToddAndMargo 
> Cc: perl6-us...@perl.org
> Subject: Re: Could this be any more obscure?
>
> On Fri, Sep 28, 2018 at 03:50:31PM -0700, ToddAndMargo wrote:
> : On 9/27/18 12:40 AM, Laurent Rosenfeld via perl6-users wrote:
> : > > I am NOT asking it to limit my request to Infinity.
> : >
> : >Yes you are, implicitly. If you don't pass any parameter for
> : >$limit, $limit will take the default value supplied by the
> : >signature, i.e. Inf.
> :
> : True, but that is not what the manual says Inf is.  Lower in this
> : thread I made a suggest addition to the wording of Inf.  Would
> : you mind looking at it and offering your criticism?
>
> Why do you want to burden the definition of what something *is* with all
> the things you can *do* with it?  The former is tractable, while the latter
> is not.
>
> It seems to me that you are applying a different standard to human and
> computer languages here.  In both human and computer languages, what
> something *is* has little to do with what something *does*.  These are
> different abstraction levels.  You're fine with this in English, so trying
> to flatten out all the abstraction levels is tending to work against your
> understanding of computer languages here, I suspect.
>
> The word "knife" is a noun, but if I "knife" someone, I'm using a noun
> (what the word is) as a verb (what the word can do).  Human language is
> full of these borrowings of abstraction level, so much so that linguists
> even have a name for them in general, the "emic vs etic" distinction.
> In non-linguistic terms, "what you said vs what you really meant".
> What it is, vs what it does.
>
> Originally these were coined on the phonetic vs phonemic level, so we see
> lots of places in English where the phonetics don't match up with how they
> are used:
>
> The prince made some prints.
>
> Here you pronounce those words identically on a phonetic level, but on a
> higher phonemic level (or even on a morphophonemic level), "prince" is only
> one morpheme, while "prints" is two morphemes "print" and the plural "s".
> But this etic/emic distinction works at higher levels as well:
>
> Here's a you-can-even-use-a-sentence-as-an-adjective example.
>
> Here the etic description of "you-can-even-use-a-sentence-as-an-adjective"
> is that of a sentence.  That's what it *is*.  But language is flexible
> enough that I can choose (emically) to slot the whole sentence in as a
> adjective.  That's what the sentence can *do*.  (Or that's what you can do
> with a sentence, if you prefer.)  The fact that you can do this takes
> nothing away from what a sentence *is*, because that's at a lower
> abstraction level.
>
> Going up the linguistic stack even further, every time you read a metaphor
> in a poem (or in a newspaper article for that matter), you are using your
> knowledge of English to realize that the poet (or reporter) is relying on
> you, the Gentle Reader, to realize that the writer is using a metaphor.  A
> metaphor is when you say one thing but mean something else by it.  The
> words of a metaphor are what it "is", but the meaning it produces in your
> brain is what it "does".
>
> The fact that the $limit is using a particular value with a particular
> representation in memory ("what the manual says Inf is") has almost nothing
> to do with how we choose to use it metaphorically in an interface, except
> insofar as it's extremely convenient to have a floating-point value that
> happens to compare as larger than any integer you want to name.
> That comparison is a thing that Inf can *do*, which is the abstraction
> level on which the $limit API is working.  The fact that it can be used
> this way is not at all contradictory to the description of what the Inf
> value *is*.
>
> But the description of what it can do really belongs on the many places
> where it can be used in various metaphorical ways, not in the definition of
> what it is.  The floating-point Inf value really has no clue whatsoever
> about all the ways it might be used.  It probably doesn't even realize it
> can be compared with an integer.  :)
>
> Larry
>


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


Re: Could this be any more obscure?

2018-09-28 Thread Brandon Allbery
It only means that in some cases. Consider if you are writing code that
places items in a grid, and you support Inf as a grid coordinate meaning
"not on the grid" which might be represented differently or which might
place it at whatever edge of the grid is relevant (without forcing you to
know the size of the grid, so it's more useful in a general library).

There's no "think simple" that covers all the use cases. And "if it's not
think simple, then remove it" means you do extra work for no good reason
except to make the documentation happy.

On Fri, Sep 28, 2018 at 6:46 PM ToddAndMargo  wrote:

> On 9/28/18 10:37 AM, Brandon Allbery wrote:
> > We're going to have a problem if "infinity" is not allowed in the
> > presence of some programmers. "All values" can mean too many things in
> > too many situations. And I don't think using * works here, quite,
> > precisely because it can mean too many things.
>
> Agreed.
>
> I think the issue is with the wording of Inf:
>
> https://docs.perl6.org/type/Num#index-entry-Inf_%28definition%29-Inf
>   The value Inf is an instance of Num and represents value that's
>   too large to represent in 64-bit double-precision floating
>   point number
>
> Looking at
> https://en.wikipedia.org/wiki/Infinity
> Infinity (symbol: ∞) is a concept describing something
> without any bound or larger than any natural number.
>
> "without any bound" is what Inf is being used for here.
> I see it as "larger than any natural number".  So I
> am probably the one at fault.
>
> When I read the manual, Perl Speak over rules common speak.
> So I was taking Inf's Perl defination literally.
>
> Proposed change for your criticism:
>
>   The value Inf (Infinity) represents "without bound" or
>   "no limit" (meaning "all possible values") when used
>   as an argument.
>
>   Inf when used as an instance of Num and represents a
>   value that's too large to represent in 64-bit double-precision
>   floating point number
>
> What do you think?
>
> -T
>


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


Re: Could this be any more obscure?

2018-09-28 Thread Brandon Allbery
We're going to have a problem if "infinity" is not allowed in the presence
of some programmers. "All values" can mean too many things in too many
situations. And I don't think using * works here, quite, precisely because
it can mean too many things.

On Fri, Sep 28, 2018 at 1:32 PM ToddAndMargo  wrote:

> On 9/26/18 11:34 PM, JJ Merelo wrote:
> >
> >
> > El mié., 26 sept. 2018 a las 23:31, Laurent Rosenfeld via perl6-users
> > (mailto:perl6-us...@perl.org>>) escribió:
> >
> > You can set a limit to the number of items (words) you want to
> > retrieve: you will get only the first $limit words.
> >
> > If you don't supply any limit, Inf can be thought as the default
> > value for the number of items, i.e. there is no limit and the
> > routine will return as many words as it can from the source input.
> >
> >
> > And this is one of the things I love Perl 6 for, its consistency.
> > Infinity is literally no limit. Using it meaning "no limit" is genius.
> > Not "0 in this case means no limit" or "-1 means no limit" or "this
> > constant meaning unavailable" or whatever. Infinity has no limit, we use
> > them as a parameter to imply that argument has no limit.
> >
> > Cheers
> >
> > JJ
>
>
> Hi JJ,
>
> The more I learn about Perl 6, the more I prefer it over Perl 5.
>
> To your list, I might add, everything starts counting from zero
> (Perl5 m/ starts at $1).  So no guessing!
>
> My problem with the default set to Inf is that Inf means a number
> too large for the numbers of bits allocated to the variable to
> handle.
>
> RTFM: https://docs.perl6.org/type/Num#index-entry-Inf_%28definition%29-Inf
>   The value Inf is an instance of Num and represents value that's
>   too large to represent in 64-bit double-precision floating
>   point number (roughly, above 1.7976931348623158e308 for
>   positive Inf and below -1.7976931348623157e308 for negative Inf)
>   as well as returned from certain operations as defined by the
>   IEEE 754-2008 standard.
>
> So how am I suppose to enter that as a value?  What it really means
> is "all of them".  "Inf" is just a poor way of stating "all words"
> as the default.  "A tremendously large numbers of words" is just
> a weird way of saying "all of them".
>
> And yes, I am blanking on how to best clean that up. We have no
> value (that I know of) for "all".
>
> -T
>


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


Re: [perl #133541] Grammer bug vs

2018-09-27 Thread Brandon Allbery
"_" is not an alphabetic character. It's allowed in "alnum" because that is
by intent what is \w in other regex implementations, which includes "_".

On Thu, Sep 27, 2018 at 10:47 PM Vijayvithal 
wrote:

> # New Ticket Created by  Vijayvithal
> # Please include the string:  [perl #133541]
> # in the subject line of all future correspondence about this issue.
> # https://rt.perl.org/Ticket/Display.html?id=133541 >
>
>
> In the attached code, the only difference between the Grammars G0 and G1
> is the defination of token 'type' it is defined as  in one case
> and as  in another.
>
> Since the string being matched is 'sc_in' both the alpha and alnum
> tokens should have captured it. But we see the following result on
> execution
>
> ===  Example==
> Nil
> ===  Example==
> 「sc_in bar」
> ruport => 「sc_in」
> type => 「sc_in」
> alpha => 「s」
> alpha => 「c」
> alpha => 「_」
> alpha => 「i」
> alpha => 「n」
>
>
> Perl Version is
>
> This is Rakudo Star version 2018.06 built on MoarVM version 2018.06
> implementing Perl 6.c.
>
>
>
> --
> Vijayvithal
> Dyumnin Semiconductors
>


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


Re: [perl #133541] Grammer bug vs

2018-09-27 Thread Brandon Allbery via RT
"_" is not an alphabetic character. It's allowed in "alnum" because that is
by intent what is \w in other regex implementations, which includes "_".

On Thu, Sep 27, 2018 at 10:47 PM Vijayvithal 
wrote:

> # New Ticket Created by  Vijayvithal
> # Please include the string:  [perl #133541]
> # in the subject line of all future correspondence about this issue.
> # https://rt.perl.org/Ticket/Display.html?id=133541 >
>
>
> In the attached code, the only difference between the Grammars G0 and G1
> is the defination of token 'type' it is defined as  in one case
> and as  in another.
>
> Since the string being matched is 'sc_in' both the alpha and alnum
> tokens should have captured it. But we see the following result on
> execution
>
> ===  Example==
> Nil
> ===  Example==
> 「sc_in bar」
> ruport => 「sc_in」
> type => 「sc_in」
> alpha => 「s」
> alpha => 「c」
> alpha => 「_」
> alpha => 「i」
> alpha => 「n」
>
>
> Perl Version is
>
> This is Rakudo Star version 2018.06 built on MoarVM version 2018.06
> implementing Perl 6.c.
>
>
>
> --
> Vijayvithal
> Dyumnin Semiconductors
>


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


Re: Could this be any more obscure?

2018-09-26 Thread Brandon Allbery
I often feel like perlmonks is about 80% of what's wrong with perl 5 these
days.

On Wed, Sep 26, 2018 at 10:27 PM ToddAndMargo  wrote:

> On 9/26/18 6:36 PM, The Sidhekin wrote:
> > On Thu, Sep 27, 2018 at 3:14 AM Peter Scott  > > wrote:
> >
> > On 9/26/2018 3:21 PM, ToddAndMargo wrote:
> >  > Do your really think any beginner would be able to figure out
> >  > "words" from the above?
> >
> > If the beginner had studied the metasyntax of function prototypes,
> > probably.
> >
> >
> >Yeah, that's where a beginner needs to begin, in order to learn Perl6
> > from the docs.
> >
> >Syntax, metasyntax, all sorts of basics ...
> >
> > I heard about people
> > who claim to have taught themselves Perl 5 from the Camel instead of
> > the
> > Llama, but they are few and far between, and in any case, most of the
> > Camel contains exposition, if dense.
> >
> >
> >I learned Perl 5 from the man pages.  It was more fun than efficient,
> > but I could easily afford it: It was not (at the time) my job. :)
> >
> >But we're not all wired the same way.  This endeavour looks to me
> > neither fun nor efficient.
> >
> >
> > Eirik
>
>
> Oh my goodness, did you guys ever use "perl monks".  They don't
> usually answer follow up questions and the format is
> excruciatingly difficult to write or follow things in.
>
>
>
> --
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~
>


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


Re: Could this be any more obscure?

2018-09-26 Thread Brandon Allbery
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.

On Wed, Sep 26, 2018 at 10:25 PM ToddAndMargo  wrote:

> On 9/26/18 7:17 PM, Brandon Allbery wrote:
> > No, perldoc only "tells you everything" if you already know perl 5. You
> > do, so you don't see this.
>
> perldocs is wonderful for the beginner.  It is the ONLY thing
> I miss in Perl 6.
>
> I like Perl 5; I adore Perl 6.  I especially love the
> clean up of sub declarations (I write in Top Down) and
> the clean up of regex's.
>
> Start simple, work up to the complex.  I am starting
> to contribute to help this along.  My beginners
> status is perfect for this as I don't miss what other think
> they see because they already know what it is suppose to say.
>
> Oh ya, and in Perl 6 EVERYTHING starts counting from zero,
> unlike Perl 5 (p5's m/ starts at $1).  No guess work and one
> liners to figure it out.
>


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


Re: Could this be any more obscure?

2018-09-26 Thread Brandon Allbery
No, perldoc only "tells you everything" if you already know perl 5. You do,
so you don't see this.

On Wed, Sep 26, 2018 at 10:15 PM ToddAndMargo  wrote:

> On 9/26/18 7:08 PM, Brandon Allbery wrote:
> > English is not a programming language, so it will not help you with
> > understanding what Positional is. Or Callable. Or Mix, or any of the
> > other types and roles in Perl 6. Perl 5 has none of these, so it is
> > never a problem in Perl 5. Instead you have to memorize a bunch of weird
> > special case rules for the things Perl 5 does know about -- and perldoc
> > expects you to have done so. You don't notice because you've already
> > memorized them.
>
> Not an excuse for poor explanations.  Perdocs leaves you knowing
> how to "use" the functions.  Perl 6's does not, unless you
> already know how to use it, then your don't need it.
>
> So rather than grumbling about it, I am going to start
> trying to be part of the solution, rather than just
> grumble about the problem.
>
> This is my latest:
>
>  A booboo and an rfe in contains documentation
>  https://github.com/perl6/doc/issues/2334
>
> Thank you for all the help with this.
>
> -T
>


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


Re: Could this be any more obscure?

2018-09-26 Thread Brandon Allbery
Actually, let's try a simpler one:

pyanfar Z$ 6 'say ([5])[0]'
5

The list [5] understands Positional, and therefore knows about what to do
with the [0]. The parentheses are only because [5][0] looks a bit strange;
but that one works the same way.

The same is true of the list that words() produces. words() doesn't need to
know that, it just gives you a list. Positional describes the "indexable"
attribute of a list.
(If you look up List in the type documentation, you will see other roles
like Iterable that lists know about.)

On Wed, Sep 26, 2018 at 10:11 PM Brandon Allbery 
wrote:

> That's not helping. What didn't you understand? Are you still expecting
> that it is words() that must know all the details of what a list is,
> because a list can't know what itself is?
>
> On Wed, Sep 26, 2018 at 10:09 PM ToddAndMargo 
> wrote:
>
>> On 9/26/18 7:04 PM, Brandon Allbery wrote:
>> > It doesn't. It just improves error messages.
>> >
>> > words() produces a list-like thing; that's what really matters, because
>> > list-like things do the Positional role. Declaring it up front lets
>> Perl
>> > 6 give you an error message early if you use the result in the wrong
>> way
>> > or if the actual implementation of words() doesn't produce something
>> > that does the Positional role.
>> >
>> > pyanfar Z$ 6 'say (sub { [5] })()[0]'
>> > 5
>> >
>> > I didn't declare the anonymous sub as producing a Positional; it just
>> > returns a List. I then invoke it with (), and apply [] to the resulting
>> > List. It's the fact that it produced a List that matters; any List or
>> > Seq or Array or Buf, etc. can be []-ed,because they all do the
>> > Positional role that defines [].
>>
>> Uhhh okay.
>>
>
>
> --
> brandon s allbery kf8nh
> allber...@gmail.com
>


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


Re: Could this be any more obscure?

2018-09-26 Thread Brandon Allbery
That's not helping. What didn't you understand? Are you still expecting
that it is words() that must know all the details of what a list is,
because a list can't know what itself is?

On Wed, Sep 26, 2018 at 10:09 PM ToddAndMargo  wrote:

> On 9/26/18 7:04 PM, Brandon Allbery wrote:
> > It doesn't. It just improves error messages.
> >
> > words() produces a list-like thing; that's what really matters, because
> > list-like things do the Positional role. Declaring it up front lets Perl
> > 6 give you an error message early if you use the result in the wrong way
> > or if the actual implementation of words() doesn't produce something
> > that does the Positional role.
> >
> > pyanfar Z$ 6 'say (sub { [5] })()[0]'
> > 5
> >
> > I didn't declare the anonymous sub as producing a Positional; it just
> > returns a List. I then invoke it with (), and apply [] to the resulting
> > List. It's the fact that it produced a List that matters; any List or
> > Seq or Array or Buf, etc. can be []-ed,because they all do the
> > Positional role that defines [].
>
> Uhhh okay.
>


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


Re: Could this be any more obscure?

2018-09-26 Thread Brandon Allbery
On Wed, Sep 26, 2018 at 10:04 PM ToddAndMargo  wrote:

> I presume you have P5's perldocs installed.  Pick
> out any functions (perldoc -f name) and take
> a look at how extraordinarily simple their explanations
> are to understand.  You almost never have to ask for help.
>  From my two postings on "words" you can tell the difference
> in understanding.
>

Perl 5 barely has types, so there's nothing to document.

Perl 6 has a whole bunch of types. You will need to learn to look up any
type that you do not already know.

English is not a programming language, so it will not help you with
understanding what Positional is. Or Callable. Or Mix, or any of the other
types and roles in Perl 6. Perl 5 has none of these, so it is never a
problem in Perl 5. Instead you have to memorize a bunch of weird special
case rules for the things Perl 5 does know about -- and perldoc expects you
to have done so. You don't notice because you've already memorized them.

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


Re: Could this be any more obscure?

2018-09-26 Thread Brandon Allbery
It doesn't. It just improves error messages.

words() produces a list-like thing; that's what really matters, because
list-like things do the Positional role. Declaring it up front lets Perl 6
give you an error message early if you use the result in the wrong way or
if the actual implementation of words() doesn't produce something that does
the Positional role.

pyanfar Z$ 6 'say (sub { [5] })()[0]'
5

I didn't declare the anonymous sub as producing a Positional; it just
returns a List. I then invoke it with (), and apply [] to the resulting
List. It's the fact that it produced a List that matters; any List or Seq
or Array or Buf, etc. can be []-ed,because they all do the Positional role
that defines [].


On Wed, Sep 26, 2018 at 9:51 PM ToddAndMargo  wrote:

> On 9/26/18 6:31 PM, ToddAndMargo wrote:
> > On 9/26/18 6:18 PM, Curt Tilmes wrote:>
> >  >  > The methods don't take [].  You are calling [] on the thing
> > that the
> >  >  > methods return.
> >
> >>>
> >>> Yes, I know.  And it is human readable too.  It is one of the
> >>> many reasons I adore Perl 6.
> >>>
> >>> Where in
> >>>  multi method words(Str:D $input: $limit = Inf --> Positional)
> >>> does it state that "words" will do that?  Not all methods will.
> >>> So it need to be stated when they will.
> >>>
> >>>
> >
> >
> >
> >  > The part where it says "--> Positional" says the thing that gets
> >  > returned is Positional.
> >  >
> >  > A Positional thing has all sorts of methods and operators you can use,
> >  > including []
> >  >
> >  > Not all methods will, of course.  Only those that say "--> Positional"
> >  > return a Positional that acts like that.
> >  >
> >  > Curt
> >
> > Hi Curt,
> >
> > Perfect! Thank you!
> >
> > So all methods that respond with --> Positional will accept []
> >
> > Awesome!
> >
> > -T
>
>
>
> I do believe the reason I spaced on this was that when I see "-->"
> what goes through my head is "this is the value(s) returned".
> I had not idea it would reflect backwards and affect the method.
>
> There should be a better way of stating this.
>


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


Re: Could this be any more obscure?

2018-09-26 Thread Brandon Allbery
Additionally: Perl 5 docs don't run into this because perl 5 has only 3
types: scalar, list, hash.

Perl 6 has lots of types, each of which has its own behavior. We use roles
to package up common behaviors. Positional is the role for "can be indexed"
/ "understands []". Don't just assume you know what Positional is because
you know its English meaning; look at what it actually does, and you will
find the [] documentation.

On Wed, Sep 26, 2018 at 9:13 PM Peter Scott  wrote:

> On 9/26/2018 3:21 PM, ToddAndMargo wrote:
> >
> > I use words all the time.  I never would have figured it out
> > from
> >
> > multi method words(Str:D $input: $limit = Inf --> Positional)
> >
> > Do your really think any beginner would be able to figure out
> > "words" from the above?
>
> If the beginner had studied the metasyntax of function prototypes,
> probably.  But this is not necessarily for beginners, this is reference
> documentation, which has to serve a purpose unencumbered by pedagogical
> weight.  This documentation is not a tutorial, it is autogenerated.  You
> are relatively unique in insisting that the reference documentation also
> function as a beginners' roadmap, so you are going to experience this
> kind of frustration repeatedly.
>
> I taught Perl 5 trainings for many years in addition to authoring books,
> videos, and courses on same, and the difference between what is best for
> learning and what is best for reference is stark.  I heard about people
> who claim to have taught themselves Perl 5 from the Camel instead of the
> Llama, but they are few and far between, and in any case, most of the
> Camel contains exposition, if dense. You're looking just at something
> corresponding to the list of functions.  I honestly think you'll get
> further forcing yourself to plow through the new Learning Perl 6 book
> than these random access forays into reference specs.  brian just spent
> two years of intense effort arranging it to fit precisely the graduated
> path your questions tell me you need.
>


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


Re: Could this be any more obscure?

2018-09-26 Thread Brandon Allbery
On Wed, Sep 26, 2018 at 9:03 PM ToddAndMargo  wrote:

> Where in
> multi method words(Str:D $input: $limit = Inf --> Positional)
> does it state that "words" will do that?  Not all methods will.
> So it need to be stated when they will.\
>

In the part that says "Positional". You have already been told this.

Someone please create one page with all of perl 6 documentation in it, so
the documentation for words() includes the documentation for Positional
includes the documentation for methods includes the documntation explaining
how perl 6 works etc. Obviously this is the only way to "properly" document
anything, you must include all of the documentation for perl 6 on every
page because CALL FOUL if you expect someone to go see what a Positional
is, or the notion that a Positional might be capable of accepting a []
method call, or someone might pass this method a Str so we'd better explain
what a Str is, etc.

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


Re: Could this be any more obscure?

2018-09-26 Thread Brandon Allbery
On Wed, Sep 26, 2018 at 8:49 PM ToddAndMargo  wrote:

>
> $ p6 '"a b c d e".words[ 2, 4 ].say;'
> (c e)
>
> or
>
> $ p6 '"a b c d e".words()[ 2, 4 ].say;'
> (c e)
>
> I am selecting the 2nd and 4th word starting from zero.  Inside
> the brackets I am asking it to select th e 2nd and 4th words for me.
>
> I am NOT asking it to limit my request to Infinity.
>
>
Correct. You put them inside the [ ]. They belong to the [ ] role of
Positional.
The words function knows nothing whatsoever about this. It belongs to
Positional.

If you put it inside the parentheses instead of the brackets, it belongs to
the Callable, and will be given to words(). Now it is applied as the $limit
on how many times to split the string.

Where does it state that
>
> $ p6 '"a b c d e".words(3).say;'
> (a b c)
>
> means the first three words, starting at zero?
>

At least three of us have told you that this is $limit, because it is in
the parentheses instead of in the brackets.
But you want words() to have a $selection there instead, so words() can be
a list for you instead of letting the list be a list.
Why is it so important that words() pretend to be a list, when we have
lists that know how to be lists?
Why is it so important that you not have to find out what a list is, but
instead that words() must pretend that it is a list?

Nobody understands why you insist that lists are wired into the functions
that produce them and can't possibly know that they can be indexed. And
that we must document every function that produces a listas actally itself
being a list, including magical $selection parameters, when that is what
lists are for. What do you think lists are for, if words() and lines() have
to be fake lists to work instead of producing real lists?

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


Re: Could this be any more obscure?

2018-09-26 Thread Brandon Allbery
I question "actually do RTFM", because you apparently think words() has to
not only explain in complete detail what "Positional" means, but also must
be rewritten to perform the Positional role itself via a $selection
parameter instead of letting the Positional role do the job for which it
exists.

On Wed, Sep 26, 2018 at 6:22 PM ToddAndMargo  wrote:

> On 9/26/18 3:12 PM, Brandon Allbery wrote:
> > I told you that. Others told you that. You ignored it and asked the same
> > question again, because what we said that exlains what words() is doing
> > doesn't fit how you've decided words() must work.
> >
> > No amount of documentation can fix "I think the accelerator is the brake
> > pedal, and if it's not then you broke it".
>
> I don't mean to frustrate you.
>
> I am trying to come up with an understandable method of
> writing out the multi method that I can add constructive
> comments to the documentation as an RFE, rather than just
> grumbling at its obscurity.
>
> I use words all the time.  I never would have figured it out
> from
>
>  multi method words(Str:D $input: $limit = Inf --> Positional)
>
> Do your really think any beginner would be able to figure out
> "words" from the above?
>
> -T
>
> Some of us actually do RTFM.
>


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


Re: Could this be any more obscure?

2018-09-26 Thread Brandon Allbery
I told you that. Others told you that. You ignored it and asked the same
question again, because what we said that exlains what words() is doing
doesn't fit how you've decided words() must work.

No amount of documentation can fix "I think the accelerator is the brake
pedal, and if it's not then you broke it".

On Wed, Sep 26, 2018 at 6:09 PM ToddAndMargo  wrote:

> On 9/26/18 2:45 PM, Brandon Allbery wrote:
> > And I'm trying to figure out how to explain $limit since the one
> > everyone else has used apparently means nothing whatsoever. Unless
> > you've just been ignoring those as irrelevant, because it's not whatever
> > you mean by "$selection" that nobody else can figure out.
>
> I know how to use the function and use it all the time.
>
> multi method words(Str:D $input: $limit = Inf --> Positional)
>
> Why are they using the word "limit" and the type "Inf"?
>
> And how is this suppose to explain how to actually use the method?
>
> The only thing I have come up with so far is that they are
> trying to tell you that there is an infinite number of
> selections.  Again, not telling you how to use the method.
>


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


Re: words[] question

2018-09-26 Thread Brandon Allbery
We really are not communicating at all, are we?

It says "--> Positional". Positional is a role specifying what to do with
[]. Positional is what knows what to do with [], so words() and lines() and
everything else that produces a Positional doesn't have to know that.
This is more or less the *definition* of Positional. It's not up to the
documentation of words() to also tell you the documentation of Positional;
it told you to look there.

And there is more to Positional than just knowing what to do with [], and
that also is not something words() or its documentation should tell you. Or
does every documentation page have to incorporate the whole Perl 6
documentation? ("You might decide to pass this a Str, so I guess I have to
explain in detail what a Str is now just in case"?)

On Wed, Sep 26, 2018 at 6:05 PM ToddAndMargo  wrote:

> On 9/26/18 2:40 PM, Brandon Allbery wrote:
> > Do you really think every function that produces a "list" has built into
> > it secret knowledge of how you would index a list? They just produce a
> > "Positional" or "Seq" or "List", etc. and *those* know what to do with
> > []. The function doesn't even need to say it's doing that; that's to
> > produce better error messages, not "wire what a list is into me".
>
> Hi Brandon,
>
> I know how to use the function and use it all the time.  My
> frustration is with the documentation.
>
> How did this
>
>   multi method words(Str:D $input: $limit = Inf --> Positional)
>
> get to what you describe above?
>
> Yours in confusion,
> -T
>


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


Re: Could this be any more obscure?

2018-09-26 Thread Brandon Allbery
What do you believe your $selection should mean?

And I'm trying to figure out how to explain $limit since the one everyone
else has used apparently means nothing whatsoever. Unless you've just been
ignoring those as irrelevant, because it's not whatever you mean by
"$selection" that nobody else can figure out.

Or is this still "words, and every other function that produces a list, is
obviously also what indexes a list, therefore you pass into it the index
you want from it"? How do you understand map() or grep() to work, if
words() has to produce not a list but a specific item from that list? Call
it once for every word in the list?

On Wed, Sep 26, 2018 at 5:39 PM ToddAndMargo  wrote:

> On 9/26/18 10:47 AM, The Sidhekin wrote:
> > On Wed, Sep 26, 2018 at 8:58 AM Todd Chester  > > wrote:
> >
> > Hi All,
> >
> > Over on
> > https://docs.perl6.org/routine/words
> > I see
> >
> >  multi method words(Str:D $input: $limit = Inf --> Positional)
> >
> > HOW IN THE WORLD did they convert `$limit = Inf` into an
> > array index!?!?!
> >
> >
> >It's not.  It's a limit:
> >
> > eirik@greencat[19:41:18]~$ perl6 -e '.say for "foo bar baz
> qux".words(2)'
> > foo
> > bar
> > eirik@greencat[19:41:29]~$
> >
> >I see from your other email that you're using square brackets.
> > That's what makes a zero-based index:
> >
> > eirik@greencat[19:41:29]~$ perl6 -e '.say for "foo bar baz
> qux".words[2]'
> > baz
> > eirik@greencat[19:43:00]~$
> >
> >But this index is not an argument to the words method.  It is an
> > argument to the .[ ] postcircumfix.
> >
> >That these are different things is perhaps more easily seen when
> > they're both present:
> >
> > eirik@greencat[19:45:54]~$ perl6 -e '.say for "foo bar baz
> > qux".words(3)[*-1]'
> > baz
> > eirik@greencat[19:45:59]~$
> >
> >Here, it may be clearer that the $limit is 3, and the index is *-1.
> >
> >
> > Eirik
>
>
> Hi Eirik,
>
> Thank you for the explanation.
>
> I think I did  not make myself clear.  I do know how to
> use the function and I use it all the time.
>
> What I don't understand is:
>
>   multi method words(Str:D $input: $limit = Inf --> Positional)
>
> Specifically "$limit = Inf".  Why are we using "$limit" instead
> of "$selection" and why are we throwing "Inf" into the mix
> as it is a "type".  "Types" are written like "Str:D" and come
> before the variable, not after.  (I know the ":D" means "defined".)
>
> And where is it stated what goes in the () and what goes
> in the []?
>
> Yours in frustration,
> -T
>


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


Re: words[] question

2018-09-26 Thread Brandon Allbery
You're still assuming they're the "same thing"in some sense.

The type of the () postfix operator says it applies to a function or method
(more specifically, to something that supports the Callable role), thus to
"words" itself.
The type of the [] postfix operator says it applies to something that
supports the Positional role; as "words" produces a Positional, the []
applies to the *result* of words.

"words" itself doesn't see or know about either of them. It is invoked by
the () postfix, and its result is processed by the [] postfix.

Do you really think every function that produces a "list" has built into it
secret knowledge of how you would index a list? They just produce a
"Positional" or "Seq" or "List", etc. and *those* know what to do with [].
The function doesn't even need to say it's doing that; that's to produce
better error messages, not "wire what a list is into me".

On Wed, Sep 26, 2018 at 5:32 PM ToddAndMargo  wrote:

> On 9/26/18 11:42 AM, Larry Wall wrote:
> > On Wed, Sep 26, 2018 at 01:16:26PM -0400, Parrot Raiser wrote:
> > : Would it be correct to say:
> > :  [ ] aka square brackets, always surround the subscript of an array or
> > : list, i.e. here "n: is an integer,  [n] always means the nth item,
> > : while
> > : ( ), round brackets or parentheses, separate and group items to
> > : control processing order, and identify subroutine calls, surrounding
> > : the argument list, if any?
> >
> > I'd say there's a bit of confusion here between different syntactic
> > categories.  Your first definition is assuming only postfix position
> > (making [] a "postcircumfix"), while your second definition includes the
> > use of () in both term position and postfix position.  In term position,
> > yes, parentheses control the processing order and group things, but
> > [] also has a term-position interpretation of its own, which is as an
> > array composer (but not a subscript).  In postfix position, [] is always
> > a subscript as you indicated, but () is only for passing arguments
> > to something (and forcing a function call if that something might be
> > construed as a different keyword without the parens).  Any grouping
> > behavior is incidental to the argument processing, and in fact many
> > constructs you can use in normal grouping parens are illegal in an
> > argument list:
> >
> >  > p6 'say abs(42 or 43)'
> >  ===SORRY!=== Error while compiling -e
> >  Unable to parse expression in argument list; couldn't find final
> ')' (corresponding starter was at line 1)
> >  at -e:1
> >  --> say abs(42⏏ or 43)
> >
> > but in term position that's fine since the inside is a whole statement:
> >
> >  > p6 'say abs (42 or 43)'
> >  42
> >
> > The latter cannot be taken as a postfix because of the space. (Unless
> > you use Tuxic, which confuses this intentionally. :)
> >
> > The three main syntax categories you have to be able to track (and
> > it's much easier to track in Perl 6 than in Perl 5), are:
> >
> >  1) when you're expecting a term
> >  2) when you're expecting a postfix (or infix if there's no postfix)
> >  3) when you're expecting only an infix
> >
> > The careful distinction of which category the grammar engine is expecting
> > is critical to understanding any version of Perl, whether 5 or 6.
> > You can't adequately describe any random syntax in Perl without first
> > nailing down which of the main grammar rules is going to be parsing it.
> >
> > Well, I've probably said more than enough.  :)
> >
> > Larry
> >
>
> Hi Larry,
>
> Wonderful explanation!  Thank you!
>
> Followup question.  I am confused.  How did they get from
>
>   multi method words(Str:D $input: $limit = Inf --> Positional)
>
> to what goes in the () and what goes in the []?
>
> And why are they using the term "$limit" instead of "$selection"?
>
> Yours in confusion,
> -T
>
>
>
> --
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~
>


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


Re: Could this be any more obscure?

2018-09-26 Thread Brandon Allbery
No, that's not it either. words is "split at whitespace until you've made
$limit chunks". It doesn't know or care what you do afterward with the Seq.
And the [] are afterward, they apply to the Seq, not to words() which
doesn't even know about them.

On Wed, Sep 26, 2018 at 5:19 PM ToddAndMargo  wrote:

> >> On Wed, Sep 26, 2018 at 2:57 AM Todd Chester  >> multi method words(Str:D $input: $limit = Inf --> Positional)
>
>
> On 9/26/18 7:21 AM, Brandon Allbery wrote:
>
> > $limit sets a limit on how many words it will make. Inf means there's no
> > limit. Your assumption that it must be some kind of array index doesn't
> > make a lot of sense; this doesn't index at all, it splits at whitespace
> > until it's got the number of chunks you told it to make, indexing the
> > result is your problem. Small pieces of functionality, not "god
> > functions" that try to do everything you can possibly think of.
>
> Hi Brandon,
>
> So, "$limit = Inf" means that I can put an infinite number of
> stuff in the [] or ()
>
> p6 '"a b c d e".words(3)[2,4].say;'
> (c Nil)
>
> $ p6 '"a b c d e".words(3).say;'
> (a b c)
>
>
> I really think that could be written better.
>
> First off the parameter is not a "limit".  It is
> a selection.
>
> And second, "Inf" is a "type", meaning "infinity" or larger
> than Perl's memory allocation can handle.  It is confusing
> to use it to state that there can be any number of selections
> in the parameter.
>
> $ p6 '"a b c d e".words()[2,4,1,3,3,3,3,20].say;'
> (c e b d d d d Nil)
>
> It also does not tell that the parameter(s) is/are integers
> or what happens if you supply a sting (error) or a real (it
> truncates):
>
>  $ p6 '"a b c d e".words()["a"].say;'
>  Cannot convert string to number: base-10 number must begin
>  with valid digits or '.' in '⏏a' (indicated by ⏏)
>  in block  at -e line 1
>
> $ p6 '"a b c d e".words()[ 2.5 ].say;'
> c
>
> Third, it does not state the difference between using () and [].
> Or how to mix and match them.
>
> $ p6 '"a b c d e".words(3).say;'
> (a b c)
>
> Where (3) gives you the first three words
>
> -T
>


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


Re: Could this be any more obscure?

2018-09-26 Thread Brandon Allbery
You're imposing a shape on this, then getting angry at us when it turns out
to be wrong. I'm sorry nobody could read your mind ahead of time to find
out the "proper" way to shape it.

$limit sets a limit on how many words it will make. Inf means there's no
limit. Your assumption that it must be some kind of array index doesn't
make a lot of sense; this doesn't index at all, it splits at whitespace
until it's got the number of chunks you told it to make, indexing the
result is your problem. Small pieces of functionality, not "god functions"
that try to do everything you can possibly think of.

On Wed, Sep 26, 2018 at 2:57 AM Todd Chester  wrote:

> Hi All,
>
> Over on
>  https://docs.perl6.org/routine/words
> I see
>
> multi method words(Str:D $input: $limit = Inf --> Positional)
>
> HOW IN THE WORLD did they convert `$limit = Inf` into an
> array index!?!?!
>
> https://docs.perl6.org/type/Num#Inf
> And `Inf` means a number larger than Perl can handle or Infinity.
> What does that have to do with ANYTHING!?
>
> Yours in confusion,
> -T
>
> And the worst part is that I know how to use "words" and use it
> frequently.  And the documentation is a nightmare to understand.
>
> Link to Positional:
> https://docs.perl6.org/type/Positional
> Role for objects which support indexing them using
> postcircumfix:«[ ]» (usually list-like objects).
> Example types with Positional role include List,
> Array, Range, and Buf.
>
> I like him using `Str:D $input:` rather than just `Str:D:`
> and it is more intuitive
>


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


Re: extending built-in classes

2018-09-24 Thread Brandon Allbery
There's a certain aspect of "there is nothing so permanent as a temporary
hack" here.

On Tue, Sep 25, 2018 at 12:19 AM Joseph Brenner  wrote:

> Larry Wall  wrote:
>
> > Joseph Brenner wrote:
> >> Sounds good, thanks.
>
> >   Well, yes, *sounds* good.  :-)
> >   Monkey patching is allowed but discouraged in Perl 6, because Ruby.
>
> But I *like* being evil.
>
> But as I was trying to make clear, it's not something I'm planning on
> using in production (unlike Ruby).
>
>
>
>

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


Re: extending built-in classes

2018-09-22 Thread Brandon Allbery
"use MONKEY-TYPING;" and then you have "augment"
https://docs.perl6.org/syntax/augment.html

On Sat, Sep 22, 2018 at 2:33 PM Joseph Brenner  wrote:

> I was just wondering if there's any way to extend an existing
> class in perl 6.  I'd like to be able to do things like drop
> a custom debugging method in Any that would then be available
> on everything.
>
> Note: I'm talking about adding something to an existing class
> ("monkeypatching") as opposed to subclassing.  In perl 5 land you
> can just say "package Whatever;" again and re-open an existing
> package.  With perl 6 saying "class Whatever" a second time would
> be a "Redeclaration" error.
>
>
>

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


Re: Ping Larry and Friends: Need NativeCall help

2018-09-18 Thread Brandon Allbery
I feel like https://github.com/xmonad/xmonad/issues/70 all over again. It's
indeed not just Perl 6. Or C, for that matter.

On Tue, Sep 18, 2018 at 7:41 PM ToddAndMargo  wrote:

> On 9/18/18 6:32 AM, Richard Hainsworth wrote:
> > Have you looked at the documentation for nativecall? It has a tutorial
> > example on how to access a c function from a standard library.
> >
> > I wrote that little bit. It should answer most of your questions.
> >
> > Richard
>
> Hi Richard,
>
> Yes I did read the documentation, but it was months ago.  Have
> you updated it?
>
> I sometimes will pick out a difficult problem
> as an exercise to teach me how to use things.
> Just dive in.
>
> So far I have got GetXDisplay to work.  XGetWindowAttributes
> seized up my computer and I had to press POR (power on reset).
> So, I have erased what I did so I would not accidentally run
> it again and seize up again.
>
> So I though I would try again, but on asking the "C" guys
> what was going on with the call.  They told me that X11 calls are
> notoriously difficult to access, even from "C".  So I am giving up
> again.  There will be other problems to torment me.  And I
> am liking GDM better than X11 anyway, so I should put my efforts
> there instead.
>
> By the way, I noticed that the Xlib example for XGetWindowAttributes
> left a ton of stuff off:
>
> $ x-windows-list.pl6
> 00 0xa044fe   xfce4-panel - xfce4-panel
> 01 0xa044fb   xfce4-panel - xfce4-panel
> 02 0xa03aab   xfce4-panel - xfce4-panel
> 03 0x3800106  firefox - Firefox
> 04 0x3e000c6  thunderbird - Thunderbird
> 05 0x600122   xfwm4 - xfwm4
> 06 0x600141   <> - <>
> 07 0x600142   <> - <>
> 08 0x600143   <> - <>
> 09 0x600144   <> - <>
> 10 0x6008a4   <> - <>
> 11 0x6008f6   <> - <>
> 12 0x6008cd   <> - <>
> 13 0x611e48   <> - <>
> 14 0x611cb7   <> - <>
> 15 0x600d68   <> - <>
> 16 0x60b8af   <> - <>
> 17 0x6009b4   <> - <>
>
> So apparently, he had issues with the call too.
>
> Anyway, I will concentrate on GDM instead.  And
> need to stop procrastinating on my Federal Taxes.
>
> Thank you for the write back,
> -T
>


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


Re: Please explain this to me

2018-09-16 Thread Brandon Allbery
Binding, iirc. You are binding a value directly instead of making a box to
assign it to.

On Mon, Sep 17, 2018 at 1:47 AM ToddAndMargo  wrote:

> >> On Sun, Sep 16, 2018 at 9:02 PM ToddAndMargo  >> <mailto:toddandma...@zoho.com>> wrote:
> >>
> >> On 09/16/2018 05:58 PM, Curt Tilmes wrote:
> >>  > Read this:
> >>  >
> >>
> https://perl6advent.wordpress.com/2017/12/02/perl-6-sigils-variables-and-containers/
> >>  >
> >>  > Then go back and read it again.  It took me several times, and
> >> I'm still
> >>  > not sure I get it all :)
> >>
> >> I am spacing on the difference between
> >>
> >>   my $foo  = 42; and
> >>   my $foo := 42;
> >>
> >> To add insult to injury, I come from Modula2, where
> >> `:=` is `=` in Perl.
> >>
> >> -T
>
>
> On 9/16/18 9:06 PM, Brandon Allbery wrote:
> > If you say "my $foo = 42", you are saying that $x is a box, and you are
> > putting 42 into it. You can put something else into that box later.
> >
> > If you say "my $foo := 42", you are saying that $x is 42 itself, not a
> > box containing 42. You can think of it as a constant of sorts. Because
> > it's not a box, you can't change what's in the nonexistent box later.
> >
> >  From here on it gets trickier, because there are things that can use
> > the box instead of what the box contains, notably Hash elements, and
> > which can then be changed by changing what's in the box directly instead
> > of by changing the Hash element.
> >
>
> Does `:=` have an official name?
>
> So, kind of like a constant you that can sometimes change.
>
> What would be the use of such?
>
>
> $ p6 'constant t=1.414; dd t;'
> 1.414
>
> $ p6 'my $t := 1.414; dd $t;'
> 1.414
>
> $ p6 'my $t := 1.414; $t += 1; dd $t;'
> Cannot assign to an immutable value
>in block  at -e line 1
>
> $ p6 'my $t := 1.414; $t := 4.14; dd $t;'
> 4.14
>
> $ p6 'my $t := 1.414; say $t + 9;'
> 10.414
>


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


Re: metamorphosis or alchemy?

2018-09-16 Thread Brandon Allbery
Sort of. A role is a "package" of components available to build classes
from. This allows someone to write a sub or method that works for any kind
of number by using the role instead of having to write the same thing over
and over for every numeric class, or every class representing a non-complex
number, etc. There is similarly a role packaging up various operations
common to all string-like types, called Stringy.

On Mon, Sep 17, 2018 at 12:03 AM ToddAndMargo  wrote:

> On 9/16/18 8:51 PM, Brandon Allbery wrote:
> > You're assuming "Real" means "a float of some kind". It's not; it
> > defines all the operations in common over non-Complex numbers (Int, Rat,
> > Num, etc.). What you are looking for, Perl 6 calls Num.
>
> https://docs.perl6.org/type.html:
> RealroleNon-complex number
>
> https://en.wikipedia.org/wiki/Real_number
>
>   In mathematics, a real number is a value of a continuous
>   quantity that can represent a distance along a line. The
>   adjective real in this context was introduced in the 17th
>   century by René Descartes, who distinguished between real
>   and imaginary roots of polynomials. The real numbers
>   include all the rational numbers, such as the integer −5
>   and the fraction 4/3, and all the irrational numbers, such
>   as √2 (1.41421356..., the square root of 2, an irrational
>   algebraic number). Included within the irrationals are
>   the transcendental numbers, such as π (3.14159265...). In
>   addition to measuring distance, real numbers can be used
>   to measure quantities such as time, mass, energy, velocity,
>   and many more.
>
> So Rat is a subset of Real.
>
> And if I want something specific, I have to call out
> a "class", not a "Role".  A "Role" is a superset of "classes".
> And I will get the proper class picked out of the subsets
> when I assign something to the variable.  I will only
> throw an error is I asn something that is not in tne subsets.
>
>  Ratclass Rational number (limited-precision)
>
> Okay, class dismissed.
>
> Thank you.  You guys have been very patient with me.
>
> -T
>


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


Re: Please explain this to me

2018-09-16 Thread Brandon Allbery
If you say "my $foo = 42", you are saying that $x is a box, and you are
putting 42 into it. You can put something else into that box later.

If you say "my $foo := 42", you are saying that $x is 42 itself, not a box
containing 42. You can think of it as a constant of sorts. Because it's not
a box, you can't change what's in the nonexistent box later.

>From here on it gets trickier, because there are things that can use the
box instead of what the box contains, notably Hash elements, and which can
then be changed by changing what's in the box directly instead of by
changing the Hash element.

On Sun, Sep 16, 2018 at 9:02 PM ToddAndMargo  wrote:

> On 09/16/2018 05:58 PM, Curt Tilmes wrote:
> > Read this:
> >
> https://perl6advent.wordpress.com/2017/12/02/perl-6-sigils-variables-and-containers/
> >
> > Then go back and read it again.  It took me several times, and I'm still
> > not sure I get it all :)
>
> I am spacing on the difference between
>
>  my $foo  = 42; and
>  my $foo := 42;
>
> To add insult to injury, I come from Modula2, where
> `:=` is `=` in Perl.
>
> -T
>


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


Re: metamorphosis or alchemy?

2018-09-16 Thread Brandon Allbery
Also, going by math calling the "real numbers" misses that math treats
integers as a subset of real numbers; there is no hard distinction between
them in math. Computers need hard distinctions here because integral,
rational, and floating point numbers must be stored in different ways,
unless they take the PHP / Javascript solution (storing them all as strings
or floating point, respectively). Perl 6's Real is a role that the actual
types "does" if they are compatible with it.

If you want to do the Perl 5-ish thing where it hid the differences (and
sometimes promoted an integral value to floating without asking, never to
return), use the Real role as a type to hide the difference between them.
If you want to be specific, use the correct type.

On Sun, Sep 16, 2018 at 11:51 PM Brandon Allbery 
wrote:

> You're assuming "Real" means "a float of some kind". It's not; it defines
> all the operations in common over non-Complex numbers (Int, Rat, Num,
> etc.). What you are looking for, Perl 6 calls Num.
>
> On Sun, Sep 16, 2018 at 8:53 PM ToddAndMargo 
> wrote:
>
>> Hi All,
>>
>> I am confused, again:
>>
>>
>> $ p6 'my $x=3; dd $x'
>> Int $x = 3
>> Makes sense
>>
>>
>> $ p6 'my $x; dd $x'
>> Any $x = Any
>> Makes Sense
>>
>> $ p6 'my Real $x; dd $x'
>> Real $x = Real
>> makes sense
>>
>> $ p6 'my Real $x = 3; dd $x'
>> Int $x = 3
>> What  Integer ?  Did I or did I not just tell it
>> is was a "Real" ?
>>
>> :'(
>>
>> -T
>>
>
>
> --
> brandon s allbery kf8nh
> allber...@gmail.com
>


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


Re: metamorphosis or alchemy?

2018-09-16 Thread Brandon Allbery
You're assuming "Real" means "a float of some kind". It's not; it defines
all the operations in common over non-Complex numbers (Int, Rat, Num,
etc.). What you are looking for, Perl 6 calls Num.

On Sun, Sep 16, 2018 at 8:53 PM ToddAndMargo  wrote:

> Hi All,
>
> I am confused, again:
>
>
> $ p6 'my $x=3; dd $x'
> Int $x = 3
> Makes sense
>
>
> $ p6 'my $x; dd $x'
> Any $x = Any
> Makes Sense
>
> $ p6 'my Real $x; dd $x'
> Real $x = Real
> makes sense
>
> $ p6 'my Real $x = 3; dd $x'
> Int $x = 3
> What  Integer ?  Did I or did I not just tell it
> is was a "Real" ?
>
> :'(
>
> -T
>


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


Re: Need help with a variable inside a regex

2018-09-15 Thread Brandon Allbery
To interpolate a variable as a regex instead of as a string literal, you
need to wrap it in < >.

On Sat, Sep 15, 2018 at 4:09 AM ToddAndMargo  wrote:

> On 09/15/2018 12:42 AM, ToddAndMargo wrote:
> > Hi All,
> >
> > I am truing to use a variable inside a regex.
> >
> > This work (without the variable):
> > $ p6 'my $x="6937-2.2.19882.exe"; if $x ~~ m/ .*? <<:\N**4>>  "-"
> > (.*?) ".exe" / {say "yes";}'
> > yes
> >
> > I want to turn `<<:\N**4>>` into a variable:
> >
> >
> > $ p6 'my $x="6937-2.2.19882.exe"; my $i="<<:\\N**4>>"; if $x ~~ m/
> > .*? $i  "-" (.*?) ".exe" / {say "yes";}else{say "No"}; say "$i";'
> >
> > No
> > <<:\N**4>>
> >
> > The double \\ is to get it past bash
> >
> >
> > What am I doing wrong?
> >
> > Many thanks,
> > -T
>
> never mind.  It got just a bit too goofy.  I switched
> to .contains and sent myself a tag as to when the
> first bunch was a random 4 digit number.
>
>
>
> --
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~
>


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


Re: .kv ?

2018-09-14 Thread Brandon Allbery
But the point of this is the method is saying up front that it must be
given a variable that is defined; it's not waiting to test it or possibly
just bomb out later. This produces better error messages (the user doesn't
have to know about what's going on inside the method, the error cites the
method itself and not something buried in its guts) and in theory can make
things faster (this may not happen yet).

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

> On 09/14/2018 07:16 PM, Brad Gilbert wrote:
> > The author greatly appreciates the time spent on writing this critique.
> >
> > (I'm the author)
> >
> > Responses written inline
> >
> > On Fri, Sep 14, 2018 at 4:55 PM ToddAndMargo 
> wrote:
> >>
> >> On 09/14/2018 09:26 AM, Brad Gilbert wrote:
> >>> You can read https://en.wikipedia.org/wiki/Option_type for more
> information
> >>>
> >>> Tell me if you find any of the Perl 6 section confusing.
> >>> https://en.wikipedia.org/wiki/Option_type#Perl_6
> >>>
> >>
> >> Hi Brad,
> >>
> >> I had to read to top over very slowly.  Part of the issue was
> >> that I was not taught to read correctly.  (I was taught
> >> "Look See", instead of "Phonics").  I kept seeing other words,
> >> other than "nullable" and "non-nullable".  Eventually, I forced
> >> myself to use phonics and the words made sense.  This is not the
> >> authors problem, but mine alone.
> >
> > Yeah I remember thinking at the time that "non-nullable"
> > might be confusing.
> >
> > When I read, I "hear" the words. (usually in my voice)
> >
> > I will try to take into consideration to not use confusables
> > in the future.
> >
> >>"There are as many null values as there are types, that
> >>is because every type is its own null. So all types are
> >>also their own option type."
> >>
> >> Well stated.  Chuckle, in Modula2 a null is always 0H.
> >
> > If I remember correctly, the only reason I wrote it was
> > so that I could write down those two sentences.
> >
> > I think I even said them out loud to myself.
> >
> >>'To opt into a non-nullable version of a type add the :D
> >>"smiley" to it."
> >>
> >> This is confusing.  And I don't think correct, but I could be wrong.
> >
> > I stayed with the language that is on the rest of the page.
> >
> > It is correct, but it needs some further refinement/clarification.
> >
> > Really I should throw it out, and come up with a new sentence.
> >
> >> Curt stated it a lot better:
> >>
> >> If I say "my Int $x",
> >> $x is now an Int, but an undefined Int.
> >>
> >> If I say "my Int $x = 42",
> >> $x is an Int, but set to a defined value, 42.
> >>
> >> ":D" means that the variable is "defined".  "non-nullable" is
> >> a confusing way to state it.
> >
> > That is not *exactly* what :D means.
> > It means it can only ever be a defined value of that type or subtype.
> >
> > Curt was talking about something slightly different than what that
> > sentence talks about.
> >
> > Perhaps I could have written:
> >
> >  “To exclude null values, a :D "smiley" can be added.”
> >
> > I will think about this further when I am less tired.
> >
> >> It is also possible to opt into a type that is only
> >> ever a nullable using the :U "smiley".
> >>
> >> Curt's description is explains this perfectly. "is only
> >> ever a nullable" is confusing.  ":U" means that the
> >> variable has not got anything assigned to it yet.
> >
> > No, :U means it can **never** have anything other than a null assigned
> to it.
> >
> > Your statement was incorrect the moment you added "yet" instead of
> "ever".
> >
> > This is part of the reason I asked for your input.
> > I wanted to know exactly where your thoughts diverged, and
> > where I was less than clear.
> >
> > Now that I know both, I can hopefully make it so that people
> > who think and read like you do can understand it better.
> >
> >> To me ":D" means that the variable has something assigned to
> >> and ":U" means that the variable has yet to have anything
> >> assigned to it.
> >
> >  my Any:U $t;
> >  $t = Int;
> >  $t = Str;
> >  $t = 42;  # error
> >
> > Again "yet" is the wrong word.
> >
> >> If I were to rewrite this, I'd reverse D and U as that
> >> is the way they evolve.  All variables start out as :U.
> >>
> >>To designate a variable that does not have a value assigned
> >>to it yet and is still in the null state, use the :U designation.
> >>
> >>To designate a variable that must have a value assigned
> >>to it (not be in the null state), use the :D designation
> >
> > I described :D first as that is more useful than :U
> >
> > It is easier to describe.
> > It is also the default for the rest of the languages on the page.
> >
> > After describing :D, it then becomes easier to describe :U
> > as it is exactly opposite
> >
> > I may use your description of :D, at least as inspiration.
> >
> > I will look into this further when I am less

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: Can methods have multiple inputs?

2018-09-14 Thread Brandon Allbery
In that case, you're not giving it two items; you are giving it a single
List that happens to have two items within it. A method has one invocant.
If you are invoking method foo on that, its invocant is a List.

> my $a; my $b; say ($a, $b).^name
List


On Fri, Sep 14, 2018 at 6:47 PM ToddAndMargo  wrote:

> Hi All,
>
> Can a method be given multiple inputs?
>
>  ( $a, $b ).foo
>
> and how would the docs write it?
>
>  method foo(Any:D Any:D:  -->Bool)
>
> Is there a comma or a space between the two "any"'s?
>
> Many thanks,
> -T
>


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


Re: .kv ?

2018-09-14 Thread Brandon Allbery
They do different things if it's defined vs. if it's undefined. This is
preferred to having an if-then test in a single implementation, if they're
different enough that you're really writing two functions anyway.

And List is supposed to be vague there. At the level of Any, it can be a
list of anything. To be more specific about the result, you need an
implementation on specific types instead of on Any; but most of those
implementations would be doing exactly the same thing, only the signature
being different. Which is silly and wasteful and makes the computer dig
though a sea of identical functions for no reason.

On Fri, Sep 14, 2018 at 6:41 PM ToddAndMargo  wrote:

> On 09/14/2018 03:10 PM, Brandon Allbery wrote:
> > On Fri, Sep 14, 2018 at 5:56 PM ToddAndMargo  > <mailto:toddandma...@zoho.com>> wrote:
> >
> >'To opt into a non-nullable version of a type add the :D
> >"smiley" to it."
> >
> > This is confusing.  And I don't think correct, but I could be wrong.
> > Curt stated it a lot better:
> >
> > If I say "my Int $x",
> > $x is now an Int, but an undefined Int.
> >
> > If I say "my Int $x = 42",
> > $x is an Int, but set to a defined value, 42.
> >
> > ":D" means that the variable is "defined".  "non-nullable" is
> > a confusing way to state it.
> >
> >
> > Not exactly. "Defined" is a "now" thing; "non-nullable", via type
> > smileys, is an "always" thing. It is defined now, and it can never be
> > undefined.
> >
> > To me ":D" means that the variable has something assigned to
> > and ":U" means that the variable has yet to have anything
> > assigned to it.
> >
> > If I were to rewrite this, I'd reverse D and U as that
> > is the way they evolve.  All variables start out as :U.
> >
> >
> > This is the same misunderstanding: what is now, is not guaranteed to be
> > so in the future. :U and :D provide such guarantees. Merely being
> > defined or undefined right now says nothing about the future.
>
>
> Hi Brandon,
>
> Thank you!
>
> My use for the "smileys" is in methods definitions.  It tells me
> that the variable has to have a value or a null.
>
> For instance:
>  multi method kv(Any:U:  -->List)
>  multi method kv(Any:D:  -->List)
>
> is their way of saying I can use either.
>
> Question,  why don't they just say?
>  method kv(Any:  -->List)
>
> And "List" is really vague, as in what kind of list?
>
> -T
>


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


Re: $? and $! equivalents

2018-09-14 Thread Brandon Allbery
Magic variables make multiple threads impossible, which is why perl 5 is
stuck with ithreads: what happens if two threads each "run" something at
around the same time?

In Perl 6, you have a Proc object for each subprocess, and can query it for
its status and/or result code; for things like sub run, the Proc should be
the return value.

On Fri, Sep 14, 2018 at 6:08 PM Parrot Raiser <1parr...@gmail.com> wrote:

> This is probably going to be a forehead-slapper, but I can't find a
> reference in either perlintro.com or http://docs.perl6.org/
> (5to6-perlfunc or top-down)  for the equivalents of $? and $! in
> P6.What are they?
>
> I want to be able to "run" or "shell" programs, then examine return
> codes and errors. (The immediate case is to see if a program name is
> already in use by running  "which $progname". )
>


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


Re: .kv ?

2018-09-14 Thread Brandon Allbery
On Fri, Sep 14, 2018 at 5:56 PM ToddAndMargo  wrote:

>   'To opt into a non-nullable version of a type add the :D
>   "smiley" to it."
>
> This is confusing.  And I don't think correct, but I could be wrong.
> Curt stated it a lot better:
>
>If I say "my Int $x",
>$x is now an Int, but an undefined Int.
>
>If I say "my Int $x = 42",
>$x is an Int, but set to a defined value, 42.
>
> ":D" means that the variable is "defined".  "non-nullable" is
> a confusing way to state it.
>

Not exactly. "Defined" is a "now" thing; "non-nullable", via type smileys,
is an "always" thing. It is defined now, and it can never be undefined.


> To me ":D" means that the variable has something assigned to
> and ":U" means that the variable has yet to have anything
> assigned to it.
>
> If I were to rewrite this, I'd reverse D and U as that
> is the way they evolve.  All variables start out as :U.
>

This is the same misunderstanding: what is now, is not guaranteed to be so
in the future. :U and :D provide such guarantees. Merely being defined or
undefined right now says nothing about the future.

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


Re: ->

2018-09-14 Thread Brandon Allbery
And then you discover <->.

On Fri, Sep 14, 2018 at 5:10 PM Parrot Raiser <1parr...@gmail.com> wrote:

> Obviously, discussions about "->" will be easier if it has a name. How
> about "lance", or, if you want to be less martial, "poker'?
>


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


Re: ->

2018-09-14 Thread Brandon Allbery
Pick a glyph, any glyph….

On Fri, Sep 14, 2018 at 4:54 PM ToddAndMargo  wrote:

> On 09/14/2018 01:09 PM, Mike Stok wrote:
> >
> >
> >> On Sep 14, 2018, at 4:03 PM, ToddAndMargo 
> wrote:
> >>
> >> On 09/14/2018 01:00 PM, Larry Wall wrote:
> >>>
> >>>  "-> is how we spell λ in Perl 6"
> >>> Larry
> >>
> >>
> >> Hysterical!  Thank you!
> >
> > I would like to think
> https://kwangyulseo.com/2015/06/23/the-origin-of-notation-λ-in-lambda-calculus/
> is the truth.
>
> “Why in the world, did you choose lambda as your operator?”
> Church’s response: “eeny meeny miny moe”.
>
> :-D
>


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


Re: ->

2018-09-14 Thread Brandon Allbery
It's still reading the block signature (parameters and return type) that it
expects after the ->, until it sees the start of the block/closure.

Think of what follows it as a sub declaration without the sub name or
parentheses. A semicolon there says that what follows are optional
parameters, so it's expecting either a parameter name, or a type to give to
the following parameter name.

On Fri, Sep 14, 2018 at 4:16 PM ToddAndMargo  wrote:

> On 09/14/2018 12:27 PM, ToddAndMargo wrote:
> > Hi All,
> >
> > I use `->` all the time.  What is its official name?
> >
> > for @x.kv -> $I, $Line {...}
> >
> > Many thanks,
> > -T
>
> Me thinks I am pushing "pointy" here!
>
> #!/usr/bin/env perl6
> sub Stooges() { return ( "Larry", "Curley", "Moe" ); }
> my $x; my $y; my $z;
>
> # ($x, $y, $z ) = Stooges;
> Stooges -> $x, $y, $z;
> say "$x  $y  $z";
>
>
> $ Lambda.Test.pl6
> ===SORRY!=== Error while compiling /home/linuxutil/./Lambda.Test.pl6
> Invalid typename 'say' in parameter declaration.
> at /home/linuxutil/./Lambda.Test.pl6:10
> --> say⏏ "$x  $y  $z";
>
>
> Am I missing something here, or did I just get a little
> too creative for my own good?
>
> Many thanks,
> -T
>


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


Re: ->

2018-09-14 Thread Brandon Allbery
It's part of a "pointy block". But this doesn't seem to be documented
directly as such, it's only mentioned at
https://docs.perl6.org/language/control#for .

On Fri, Sep 14, 2018 at 3:28 PM ToddAndMargo  wrote:

> Hi All,
>
> I use `->` all the time.  What is its official name?
>
> for @x.kv -> $I, $Line {...}
>
> Many thanks,
> -T
>


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


Re: Please explain this to me

2018-09-11 Thread Brandon Allbery
I'd like to point out that Todd is from Perl 5, which doesn't distinguish
between subs and methods because its built-in OO is a minimalist hack. An
introduction to true objects might be in order.

On Tue, Sep 11, 2018 at 8:34 AM Simon Proctor 
wrote:

> Also Todd I gave a talk on signatures types and multi methods at The Perl
> Conference this year.
>
> https://www.youtube.com/watch?v=Sy-qb5nXKyc&t=8606s
>
> That should be just before the start.
>
>
> https://www.slideshare.net/SimonProctor8/perl6-signatures-types-and-multicall
>
> Slides are here.
>
> Hope this helps.
>
> Simon
>
> On Tue, 11 Sep 2018 at 13:05 Simon Proctor 
> wrote:
>
>> 1) why is it a "method" and not a "function"?
>>
>> methods are all on instance of a Class (or Role) they can locally access
>> the instances data via self or $ or ... see below.
>>
>> 1-1/2) why is there a color after a$?  What happens to $a?
>>
>> You can as an extra option give your instance object a different name,
>> you seperate that from the rest of the args with a :
>>
>> 2) What is an "invocant"?  Does it mean I can access it
>> by placing it after something with a dot?  Sort of
>> like
>>  contains("abc", "b")
>>  "abc".contians("b")
>>
>> The incovant is the object you invoke the method on. It's the thing that
>> gets assigned to self, $ (and whatever else you want to call it)
>>
>> 3) What makes the "invocant" special over the other second
>> and third parameters?
>>
>> See about
>>
>>  > class Foo {
>>
>> 4) I see no class called "Foo" over on
>> https://docs.perl6.org/type.html
>>
>> That's a class being defined for this example
>>
>> 5) Are they creating a new class?  If so, why?
>>
>> To make an example
>>
>>  >method whoami($me:) {
>>
>> 6) where is @b and %c?
>>
>> In this case thet aren't being passed.
>>
>>
>>  >"Well I'm class $me.^name(), of course!"
>>
>> 7) why is there a caret in front of "name"?
>>
>> There are certain Meta Object methods that are access with a ^ infront of
>> the name. I'd need to check the exact definition though.
>>
>> Please note the Perl5 docs have had decades of people working on them the
>> Perl6 ones less so. There's bound to be some difference in scope.
>>
>> On Tue, 11 Sep 2018 at 12:11 ToddAndMargo  wrote:
>>
>>> On 09/11/2018 03:30 AM, JJ Merelo wrote:
>>> > Also, "is no help whatsoever" is no help whatsoever. Saying what part
>>> of
>>> > it is not clear enough, or could be explained better, is.
>>> >
>>>
>>> Well now,
>>>
>>>  >  method ($a: @b, %c) {};   # first argument is the invocant
>>>
>>> 1) why is it a "method" and not a "function"?
>>>
>>> 1-1/2) why is there a color after a$?  What happens to $a?
>>>
>>> 2) What is an "invocant"?  Does it mean I can access it
>>> by placing it after something with a dot?  Sort of
>>> like
>>>  contains("abc", "b")
>>>  "abc".contians("b")
>>>
>>> 3) What makes the "invocant" special over the other second
>>> and third parameters?
>>>
>>>  > class Foo {
>>>
>>> 4) I see no class called "Foo" over on
>>> https://docs.perl6.org/type.html
>>>
>>> 5) Are they creating a new class?  If so, why?
>>>
>>>  >method whoami($me:) {
>>>
>>> 6) where is @b and %c?
>>>
>>>  >"Well I'm class $me.^name(), of course!"
>>>
>>> 7) why is there a caret in front of "name"?
>>>
>>>  >}
>>>  >  }
>>>  >
>>>  >
>>>  >  say Foo.whoami; # OUTPUT: «Well I'm class Foo, of course!␤»
>>>
>>> 8) no clue how they got there
>>>
>>>
>>> JJ, have you ever used Perl 5's perldocs?  They are a bazillion
>>> times easier to understand than Perl 6's.
>>>
>>> Thank you for the help with this?
>>>
>>> -T
>>>
>> --
>> Simon Proctor
>> Cognoscite aliquid novum cotidie
>>
> --
> Simon Proctor
> Cognoscite aliquid novum cotidie
>


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


Re: 3 kinds of yadda

2018-09-10 Thread Brandon Allbery
Bash is treating ! as the history substitution character, and either
erroring out or substituting a previous command line. ^ has related
behavior at the start of a line.

... is specially recognized by the compiler, for example treating a class
stubbed with ... as a forward declaration. I don't know if !!! is similar.

On Mon, Sep 10, 2018 at 3:05 PM Parrot Raiser <1parr...@gmail.com> wrote:

> There are 3 kinds of yadda, yadda operator:
>
> !!! dies with a message: Stub code executed
>   in block  at yad1 line 2
>
> ... dies with an identical message
>
> ??? produces the message, but continues operating.
>
> The only difference I can find between !!! and ... is that !!!
> produces bizarre behaviour  when run from the command line. (Bash
> appears to be editing the code before P6 sees it.)
>
> What is supposed to be the difference between !!! and ...? (And bonus
> points if you can explain what bash is doing.)
>


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


Re: Is Proxy a first class part of P6 or not?

2018-09-05 Thread Brandon Allbery
The real problem is that, in the absence of Proxy, rakudo can optimize a
bunch of things away because it knows it has full control of the value. But
if it encounters a Proxy, it has to assume that the Proxy might be
manipulating state outside of the current thread, or even outside of
rakudo, that might change at any time.

Consider something like Perl 5's tied hashes used for database access.
Rakudo can't tell the database to freeze a row across multiple operations,
and including a transaction API would make Proxy even slower. And wouldn't
work across multiple expressions/statements without making it clunky enough
that you'd be better off just using the database API.

On Wed, Sep 5, 2018 at 9:56 AM Ralph Mellor  wrote:

> This is the first in a series of a half dozen responses to Vadim's
> AttrX::Moo post that replace a couple earlier failed attempts to post here.
> I apologize if there end up being repeats or my following up with several
> responses is inappropriate.
>
> Hi Vadim. I'm making this my first post because it assumes the approach
> you've taken is the thing to focus on first. But imo some of my later posts
> will be much more important and may render this one moot. Please bear this
> in mind as you read this. I expect to have posted all the posts within the
> next hour if this one gets through.
>
> > First of all, I wanted to make the module as transparent for a user a
> possible. It basically means that one should not be worried much about
> using 'is mooish' trait and what side effects would it cause to his code.
>
> That sounds simple and wise.
>
>
> > This is why Proxy is used as an attribute container. It allows for using
> of auto-generated accessors or user-provided ones without extra headache of
> how to deal with conflicts. It's being said that Proxy is problematic in
> many aspects, but it would be eventually fixed, wouldn't it? So far it does
> the job for me.
>
> The primary problem I was alluding to is that, at least last time I
> investigated, Proxy semantics reserve the right to repeat FETCH calls
> multiple times per single read and likewise STORE calls per single write
> and in reality this happens a lot, or at least used to.
>
> I think the number of repeats was improved in recent years but that repeat
> calls were not entirely eliminated. To the degree this might be considered
> something to be fixed, I think it's been known for 5-10 years and, aiui (as
> I understand it), there's no urgency felt, nor or even a long term
> commitment, to fully fixing it.
>
> There are also some reported bugs on RT
> https://rt.perl.org/Public/Search/Simple.html?q=proxy and GH
> https://github.com/rakudo/rakudo/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+proxy+
>
> That said, P6 is driven forward by its users interacting with the
> community and/or ecosystem. If you create test cases covering functionality
> that matters to you and/or your company and get them added to roast, the
> suite of tests that officially define P6, you can directly and formally
> influence prioritizing of attention to P6's and Rakudo's capabilities and
> bugs.
>
>
> > What is confusing me is that it's the second time I get advised against
> use of Proxy because of its problems. Is it a first-class member of Perl6
> class family or is it just a play toy?
>
> Aiui it's first class.
>
> Current Proxy semantics are that it is allowed to repeat FETCHs and/or
> STOREs multiple times per single read and/or write.
>
> That's fine for some things and a pain for others.
>
> Perhaps this limitation, in combination with P6 being slow, has led to
> less use of it than might be expected and that in turn has led to low
> pressure on fixing the bugs listed earlier. That's just speculation on my
> part though.
>
>
> --
> raiph
>


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


Re: Handing over control

2018-09-03 Thread Brandon Allbery
And the "exit" should be redundant in that case.

On Mon, Sep 3, 2018 at 1:29 PM Parrot Raiser <1parr...@gmail.com> wrote:

> But this:
>
> perl6 -e 'shell("vim sample"); exit'
>
> behaves acceptably.
>
> On 9/3/18, Parrot Raiser <1parr...@gmail.com> wrote:
> > Is Windows really that brain-dead? Pity it has to sabotage everyone else.
> >
> > This invokes vim successfully, but leaves an ugly error message around:
> >
> > perl6 -e 'exit shell("vim sample")'
> > No such method 'Int' for invocant of type 'Proc'
> >   in block  at -e line 1
> >
> >
> > On 9/3/18, Brandon Allbery  wrote:
> >> It's not basic: Windows doesn't have it at all, it has to be simulated.
> >> The
> >> intent is that system dependent things like that should be external to
> >> the
> >> core.
> >>
> >> On Mon, Sep 3, 2018 at 12:56 PM Parrot Raiser <1parr...@gmail.com>
> wrote:
> >>
> >>> Thanks for the reply.  That didn't show up with any search string I
> >>> could contrive.
> >>> It's disappointing to lose a basic ability like handing over control
> >>> to another program.
> >>>
> >>> On 9/3/18, Elizabeth Mattijsen  wrote:
> >>> > https://docs.perl6.org/language/5to6-perlfunc#exec
> >>> >
> >>> >> On 3 Sep 2018, at 18:41, Parrot Raiser <1parr...@gmail.com> wrote:
> >>> >>
> >>> >> In Perl 5, a program can hand over control to another with exec:
> >>> >> https://perldoc.perl.org/functions/exec.html
> >>> >> e.g  perl -e 'exec vim'  opens up vim
> >>> >>
> >>> >> What's the Perl 6 equivalent?
> >>> >
> >>>
> >>
> >>
> >> --
> >> brandon s allbery kf8nh
> >> allber...@gmail.com
> >>
> >
>


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


Re: Handing over control

2018-09-03 Thread Brandon Allbery
fork/exec is a Unix-specific idiom.

shell throws (well, produces a Failure that is thrown when sunk), so you
don't need the exit.

On Mon, Sep 3, 2018 at 1:10 PM Parrot Raiser <1parr...@gmail.com> wrote:

> Is Windows really that brain-dead? Pity it has to sabotage everyone else.
>
> This invokes vim successfully, but leaves an ugly error message around:
>
> perl6 -e 'exit shell("vim sample")'
> No such method 'Int' for invocant of type 'Proc'
>   in block  at -e line 1
>
>
> On 9/3/18, Brandon Allbery  wrote:
> > It's not basic: Windows doesn't have it at all, it has to be simulated.
> The
> > intent is that system dependent things like that should be external to
> the
> > core.
> >
> > On Mon, Sep 3, 2018 at 12:56 PM Parrot Raiser <1parr...@gmail.com>
> wrote:
> >
> >> Thanks for the reply.  That didn't show up with any search string I
> >> could contrive.
> >> It's disappointing to lose a basic ability like handing over control
> >> to another program.
> >>
> >> On 9/3/18, Elizabeth Mattijsen  wrote:
> >> > https://docs.perl6.org/language/5to6-perlfunc#exec
> >> >
> >> >> On 3 Sep 2018, at 18:41, Parrot Raiser <1parr...@gmail.com> wrote:
> >> >>
> >> >> In Perl 5, a program can hand over control to another with exec:
> >> >> https://perldoc.perl.org/functions/exec.html
> >> >> e.g  perl -e 'exec vim'  opens up vim
> >> >>
> >> >> What's the Perl 6 equivalent?
> >> >
> >>
> >
> >
> > --
> > brandon s allbery kf8nh
> > allber...@gmail.com
> >
>


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


Re: Handing over control

2018-09-03 Thread Brandon Allbery
It's not basic: Windows doesn't have it at all, it has to be simulated. The
intent is that system dependent things like that should be external to the
core.

On Mon, Sep 3, 2018 at 12:56 PM Parrot Raiser <1parr...@gmail.com> wrote:

> Thanks for the reply.  That didn't show up with any search string I
> could contrive.
> It's disappointing to lose a basic ability like handing over control
> to another program.
>
> On 9/3/18, Elizabeth Mattijsen  wrote:
> > https://docs.perl6.org/language/5to6-perlfunc#exec
> >
> >> On 3 Sep 2018, at 18:41, Parrot Raiser <1parr...@gmail.com> wrote:
> >>
> >> In Perl 5, a program can hand over control to another with exec:
> >> https://perldoc.perl.org/functions/exec.html
> >> e.g  perl -e 'exec vim'  opens up vim
> >>
> >> What's the Perl 6 equivalent?
> >
>


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


Re: string to integer?

2018-08-07 Thread Brandon Allbery
"dd" is a built in Data::Dumper, in Perl 5 terms, not a conversion routine.
I wanted it to show clearly the types, but it's not as clear as it might
have been because I was dumping expressions instead of variables (where it
would have shown name and type as well).

On Tue, Aug 7, 2018 at 3:03 AM ToddAndMargo  wrote:

> >> On Mon, Aug 6, 2018 at 4:59 PM ToddAndMargo  >> <mailto:toddandma...@zoho.com>> wrote:
> >>
> >> Hi All,
> >>
> >> How do I assign a string that looks like an integer
> >> into an interger?
> >>
> >> $str = "601"  -- > $int = 601
> >>
> >>
> >> Many thanks,
> >> -T
>
> On 08/06/2018 02:01 PM, Brandon Allbery wrote:
> > Prefix + numifies, prefix ~ stringifies.
> >
> > pyanfar Z$ 6 'my Str $a = "5"; dd +$a'
> > 5
> > pyanfar Z$ 6 'my Int $a = 5; dd ~$a'
> > "5"
> >
> >
>
> What is this all about?
>
> $ p6 'my Int $y = 7; my Str $x = dd ~$y; say $x'
> "7"
> (Str)
>
> Why does it say "(Str)"?  The confirmation is nice, but
> why is it printing out?
>
>
> And why does this error out?
>
> $ p6 'my Int $y = 7; my Str $x = dd ~$y; say "$x"'
> "7"
> Use of uninitialized value $x of type Str in string context.
> Methods .^name, .perl, .gist, or .say can be used to stringify it to
> something meaningful.
>in block  at -e line 1
>


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


Re: string to integer?

2018-08-06 Thread Brandon Allbery
Prefix + numifies, prefix ~ stringifies.

pyanfar Z$ 6 'my Str $a = "5"; dd +$a'
5
pyanfar Z$ 6 'my Int $a = 5; dd ~$a'
"5"


On Mon, Aug 6, 2018 at 4:59 PM ToddAndMargo  wrote:

> Hi All,
>
> How do I assign a string that looks like an integer
> into an interger?
>
> $str = "601"  -- > $int = 601
>
>
> Many thanks,
> -T
>


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


Re: need regex help

2018-08-03 Thread Brandon Allbery
That document also says that _ is considered a letter (that is, is matched
by :
https://docs.perl6.org/language/regexes#Predefined_Character_Classes), so
that's the same thing as . I observed that earlier as well.

On Fri, Aug 3, 2018 at 2:37 PM Parrot Raiser <1parr...@gmail.com> wrote:

> If I've interpreted this
>
> https://docs.perl6.org/language/regexes#Enumerated_character_classes_and_ranges
> correctly,
>
> ^ is "start of string"
> +alnum means "in the alphanumeric set"
> -alpha   means "not in the purely alphabetic set"
> i.e. <+alnum -alpha> means "alphanumeric but not a letter", i.e 0-9_
> + is "one or more of the preceding set"
> $ is "end of string"
>
> On 8/3/18, ToddAndMargo  wrote:
> > On 08/02/2018 05:18 AM, Timo Paulssen wrote:
> >> Is this what you want?
> >>
> >> perl6 -e 'say "12345" ~~ /^<+alnum -alpha>+$/'
> >> 「12345」
> >>
> >> perl6 -e 'say "123a45" ~~ /^<+alnum -alpha>+$/'
> >> Nil
> >>
> >> HTH
> >>- Timo
> >>
> >
> > What does the following do?
> >
> >   +alnum   (why does it need the "+"?)
> >   -alpha   (I presume "-" means negate?)
> >   +$
> >
> > Many thanks,
> > -T
> >
>


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


Re: need regex help

2018-08-01 Thread Brandon Allbery
Set operations have to be inside the <>. You want something like:
/<[alnum-alpha]>/.

That said, this would be the same as //, I think? Please describe in
words what you intended with that regex. (I suspect /<[alpha]>/ is what you
really want, based on your earlier statement.)

On Thu, Aug 2, 2018 at 12:57 AM ToddAndMargo  wrote:

> Hi All,
>
> If there are any letter in the string, I want it to fail
>
>
>
> $ p6 'my $x="9.0v1"; if $x~~/<+alnum>-[]>/ {say "Y";}'
> ===SORRY!===
> Unrecognized regex metacharacter - (must be quoted to match literally)
> at -e:1
> --> my $x="9.0v1"; if $x~~/<+alnum>⏏-[]>/ {say "Y";}
> Unable to parse regex; couldn't find final '/'
> at -e:1
> --> my $x="9.0v1"; if $x~~/<+alnum>-⏏[]>/ {say "Y";}
>
>
>
> What am I doing wrong?
>
> Many thanks,
> -T
>


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


Re: What does ^parents really tell you?

2018-07-29 Thread Brandon Allbery
I think you want ^mro?

On Sun, Jul 29, 2018 at 1:28 PM 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?
>


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


Re: return code?

2018-07-28 Thread Brandon Allbery
Yes, that's what I was addressing: you can tell run() to do that, keeping
stderr separate with :err(). qxx does that internally.

On Sat, Jul 28, 2018 at 4:12 PM ToddAndMargo  wrote:

> On 07/28/2018 12:56 PM, Brandon Allbery wrote:
> > You can control where run() sends things.
>
> Hi Brandon,
>
> I adore the run command.
>
> In this particular instance (curl's progress meter, which is
> written to STDERR), I want STDERR to write to the shell, but
> want to collect STDIN and the return code.
>
> curl ; echo $?
>
> will send both to STDIN, which I can easily deal with.
>
> -T
>


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


Re: > vs gt

2018-07-28 Thread Brandon Allbery
If you really want a headache, go look at the revision history for vercmp()
in the RPM repo.

On Sat, Jul 28, 2018 at 4:08 PM ToddAndMargo  wrote:

> On 07/28/2018 08:26 AM, Brandon Allbery wrote:
> > I think you can use Version.new on that and compare them reasonably
> > directly? That said, comparison of version numbers is a bit of a
> > minefield for exactly this reason: not everyone agrees on when to use
> > string vs.  numeric comparison, or what to do when one is numeric and
> > the other isn't.
>
> Hi Brandon,
>
> I wrote my own routine to test if a revision is greater
> than a prior revision.  It took two years of thinking
> and refining and recently moved it from Perl 5 to Perl 6.
>
> I am working on my program to go the web and update various
> programs I support at customer's sites.
>
> You are right about the mine field.  Delimiter variations
> I have to deal with are
>
> 1_2_3_4
> 1.2.4-4
> 1.2.3_4
> 1a10
> 1b10
> 1rc10
> 8u123  (freaking Java)
> and so on and so forth.
>
> and is 1.2.3 newer than 1.2.3.0, etc.?  (I tag them as identical.)
>
> First I take a,b and rc and adjust them
>  2.3a5  --> 2.2.4997
>  2.3b5  --> 2.2.4998
>  2.3rc5 --> 2.2.4999
>
> Then I do is to first bust both strings into dot only
> delimiters.
>
> Next I create number arrays out of each.  Then I make sure
> both array have the same number of cell by back filling
> the short array with zeros.
>
> And finally, I loop across both arrays at the same
> time to find if the revision is newer.
>
> As I said, it took me two years of thinking and refining.
> If anyone want to see this code, drop me a line.  I'd
> love to share what I have been up to for the last two years!
>
> -T
>


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


Re: return code?

2018-07-28 Thread Brandon Allbery
You can control where run() sends things. See the :out and :err named
parameters. I think :err($*ERR) is what you want here, although you might
also want :err($*OUT) which effectively redirects its stderr to rakudo's
stdout. (That said, I don't know if it processes those in the right order;
it could be like the difference between >foo 2>&1 and 2>&1 >foo in shell.
There have been a number of odd confusions in the history of that code.)

On Sat, Jul 28, 2018 at 3:52 PM ToddAndMargo  wrote:

> >> On Sat, Jul 28, 2018 at 4:37 AM, ToddAndMargo  >> > wrote:
> >>
> >> Hi All,
> >>
> >> How do I get the bash return code ("$?") from
> >> the following?
> >>
> >> $ReturnStr = qqx ( curl $TimeOutStr -L $Url -o $FileName ).lines;
> >>
> >>
> >> Many thanks,
> >> -T
> >>
>
>
> On 07/28/2018 06:14 AM, Paul Procacci wrote:
> > I'm not sure about qqx because I too am a fledgling perl6 programmer,
> > but the run routine returns a Proc object that has an exitcode method.
> >
> > 
> > my $proc = run 'ls', 'dir!';
> > $proc.exitcode.say;
> > 
> >
> > Right in the documentation the following is stated as well:
> >
> > "See alsorun andProc::Async
> > for better ways to execute
> > external commands. "
>
>
> Hi Paul,
>
> I adore the run command and use it very frequently.
>
> I this instance, I actually want to write STDERR to the
> shell and only capture STDIN and the exit code.
> I am trying to get "curl" to show its progress meter,
> which writes to STDERR.
>
> So far I have
> $ p6 'my $x="cat /etc/hosts; echo \$\?"; my $y = qqx ( $x ); say "$y";'
>
> which sends STDIN and the exit code to $y, which I can deal with.
>
> Thank you for the help!
>
> -T
>


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


Re: > vs gt

2018-07-28 Thread Brandon Allbery
I think you can use Version.new on that and compare them reasonably
directly? That said, comparison of version numbers is a bit of a minefield
for exactly this reason: not everyone agrees on when to use string vs.
numeric comparison, or what to do when one is numeric and the other isn't.

On Sat, Jul 28, 2018 at 2:41 AM ToddAndMargo  wrote:

> On 07/27/2018 11:27 PM, ToddAndMargo wrote:
> >>> On Sat, Jul 28, 2018 at 1:54 AM ToddAndMargo  >>> <mailto:toddandma...@zoho.com>> wrote:
> >>>
> >>> Hi All,
> >>>
> >>> Why does this work:
> >>>
> >>>  if $CurlStr.chars > 200 {
> >>>
> >>> But this does not?
> >>>
> >>>  if $CurlStr.chars gt 200 {
> >>>
> >>> 79 was not larger than 200 
> >>>
> >>>
> >>> Many thanks,
> >>> -T
> >>>
> >
> > On 07/27/2018 10:57 PM, Brandon Allbery wrote:
> >>  > is numeric comparison: (79 > 200) is false. gt is string
> >> comparison: ("79" > "200") is true because "7" is lexically larger
> >> than "2".
> >
> > so "7" was larger than "2".
> >
> > mumble, mumble
> >
> >
> > Thank you for the second pair of eyes!
> >
> > -T
>
> I had been dealing with revision numbers (2.3.4-1234),
> which are all stings, for hours and did not realize
> I had an actual number!
>
>
> --
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~
>


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


Re: > vs gt

2018-07-27 Thread Brandon Allbery
> is numeric comparison: (79 > 200) is false. gt is string comparison:
("79" > "200") is true because "7" is lexically larger than "2".


On Sat, Jul 28, 2018 at 1:54 AM ToddAndMargo  wrote:

> Hi All,
>
> Why does this work:
>
> if $CurlStr.chars > 200 {
>
> But this does not?
>
> if $CurlStr.chars gt 200 {
>
> 79 was not larger than 200 
>
>
> Many thanks,
> -T
>


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


Re: -c bug to report

2018-07-25 Thread Brandon Allbery
There's been discussion about having -c run the optimize stage as well,
since some information needed for full checking doesn't exist in a useful
form until then.

On Wed, Jul 25, 2018 at 2:49 PM ToddAndMargo  wrote:

> Hi Simon,
>
> Maybe I am trying to get "-c" to do too many things.
>
> What I would like it to do is to check everything right up to but not
> actually run the program.
>
> -T
>
>
> On 07/25/2018 02:27 AM, Simon Proctor wrote:
> > Problem is that's not a syntax error as such. Running with stage stats
> > you can see where -c stop and where the error is thrown.
> >
> > (I'm sure someone with deeper VM understanding can explain is better).
> >
> > perl6 --stagestats -e 'sub foo($a, $b) { say "Hmm" };foo(1,2,"3")'
> > Stage start  :   0.000
> > Stage parse  :   0.116
> > Stage syntaxcheck:   0.000
> > Stage ast:   0.000
> > Stage optimize   : ===SORRY!=== Error while compiling -e
> > Calling foo(Int, Int, Str) will never work with declared signature ($a,
> $b)
> > at -e:1
> > --> sub foo($a, $b) { say "Hmm" };⏏foo(1,2,"3")
> > perl6 --stagestats -ce 'sub foo($a, $b) { say "Hmm" };foo(1,2,"3")'
> > Stage start  :   0.000
> > Stage parse  :   0.110
> > Stage syntaxcheck: Syntax OK
> >
> >
> >
> > On Wed, 25 Jul 2018 at 09:26 ToddAndMargo  > > wrote:
> >
> > Dear Developers,
> >
> > $ perl6 -v
> > This is Rakudo version 2018.05 built on MoarVM version 2018.05
> > implementing Perl 6.c.
> >
> > `Perl6 -c xxx.pl6` passes
> >
> >if IsCurrentRevNewer ( $OldRev, $NewRev, $SubName, "no",
> > "quiet" )
> >
> > when the sub it calls only has three variables in it header, not
> five:
> >
> >sub IsCurrentRevNewer(
> >   $Caller,  # who called this function
> >   $LatestRev,   # Latest Revision
> >   $OldRev ) {   # Old Revision
> >
> >
> > -T
> >
> > --
> > Simon Proctor
> > Cognoscite aliquid novum cotidie
>
>
> --
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~
>


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


Re: MAIN subroutine

2018-07-19 Thread Brandon Allbery
I should mention something less obvious as well: a declaration both
manipulates symbols known to the compiler, and usually causes allocation of
storage at runtime; and for classes, composition has runtime components.
Among other things that must be split between compile-time and runtime. So
it's not just explicit initialization that relies on this.


On Thu, Jul 19, 2018 at 5:48 PM Brandon Allbery  wrote:

> Consider that "declarations" are actually executable code. They have
> compile-time meaning, but many also have runtime meaning. This is most
> obvious when it's a variable with an initializer: the initialization is at
> runtime, not compile time. Which means MAIN has to run after all such, or
> variables won't be initialized properly.
>
> Most commonly you would not combine a MAIN sub with non-declaring code.
>
> On Thu, Jul 19, 2018 at 5:32 PM Laurent Rosenfeld via perl6-users <
> perl6-us...@perl.org> wrote:
>
>> Hi folks,
>>
>> The documentation for the MAIN sub says that "the sub with the special
>> name MAIN is executed after all relevant phasers."
>>
>> My understanding is that MAIN automatically executes before any code
>> other than phasers happening at compile time or at the end or right after
>> the end of compilation. It seems that this is not the case. It seems that
>> my perception is wrong and that code not belonging to any sub is executed
>> before MAIN.
>>
>> For example, take this code:
>>
>> sub execute_after_main(Str $string) {
>> say "this $string after MAIN?";
>> }
>> execute_after_main("1");
>>
>> sub MAIN() {
>> say "This is MAIN so this should print first";
>> }
>> execute_after_main("2");
>>
>> This prints the following:
>>
>> this 1 after MAIN?
>> this 2 after MAIN?
>> This is MAIN so this should print first
>>
>> I was expecting the MAIN message to be printed first.
>>
>> Did I miss something? Is my understanding wrong? I'd never seen that, but
>> I guess all my scripts using MAIN had all the code in subs called from
>> MAIN. So maybe I've never hit that case.
>>
>> Cheers,
>> Laurent.
>>
>
>
> --
> 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: MAIN subroutine

2018-07-19 Thread Brandon Allbery
Consider that "declarations" are actually executable code. They have
compile-time meaning, but many also have runtime meaning. This is most
obvious when it's a variable with an initializer: the initialization is at
runtime, not compile time. Which means MAIN has to run after all such, or
variables won't be initialized properly.

Most commonly you would not combine a MAIN sub with non-declaring code.

On Thu, Jul 19, 2018 at 5:32 PM Laurent Rosenfeld via perl6-users <
perl6-us...@perl.org> wrote:

> Hi folks,
>
> The documentation for the MAIN sub says that "the sub with the special
> name MAIN is executed after all relevant phasers."
>
> My understanding is that MAIN automatically executes before any code other
> than phasers happening at compile time or at the end or right after the end
> of compilation. It seems that this is not the case. It seems that my
> perception is wrong and that code not belonging to any sub is executed
> before MAIN.
>
> For example, take this code:
>
> sub execute_after_main(Str $string) {
> say "this $string after MAIN?";
> }
> execute_after_main("1");
>
> sub MAIN() {
> say "This is MAIN so this should print first";
> }
> execute_after_main("2");
>
> This prints the following:
>
> this 1 after MAIN?
> this 2 after MAIN?
> This is MAIN so this should print first
>
> I was expecting the MAIN message to be printed first.
>
> Did I miss something? Is my understanding wrong? I'd never seen that, but
> I guess all my scripts using MAIN had all the code in subs called from
> MAIN. So maybe I've never hit that case.
>
> Cheers,
> Laurent.
>


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


Re: using run

2018-06-20 Thread Brandon Allbery
I don't manage the docs. But a ticket has already been opened:
https://github.com/perl6/doc/issues/2111

On Thu, Jun 21, 2018 at 12:59 AM Todd Chester  wrote:

>
>
> On 06/20/2018 08:58 AM, Brandon Allbery wrote:
> > A pipe is for communication with a process. "Piped to a file" means
> > what? What's the process you're communicating with?
> >
> > More to the point, "run" is intended to be lower level, specifically so
> > you can directly control things. Things like redirection and shell
> > pipelines are higher level.
>
> Hi Brandon,
>
> Make sure the documentation makes it clear that "run" is
> not running a shell and that Pipes ("|"), redirects
> ("2>&1") and such are all shell dependent.
>
> -T
>
> p.s. I almost never make a shell system call anymore.
> I prefer "run" and then manipulate the data myself the
> way I want to, not some awkward shell helper command.
>


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


Re: using run

2018-06-20 Thread Brandon Allbery
If you're going to use terms in a different way than what they actually
mean, it's going to be difficult to produce something that does what you
believe it should do *and* what it should actually do.

A pipe is for communication with a process. "Piped to a file" means what?
What's the process you're communicating with?

More to the point, "run" is intended to be lower level, specifically so you
can directly control things. Things like redirection and shell pipelines
are higher level.

That said, :out and :err are incompletely documented; the form that tells
it to create pipes so your script can communicate with the process is
there, but you can also specify handles to attach them to. In which case
you would open a file, then say :out($myHandle) to attach the process's
stdout to the handle $myHandle.

On Wed, Jun 20, 2018 at 11:33 AM Theo van den Heuvel 
wrote:

> Hi all,
>
> trying to make sense of the documentation on run:
> https://docs.perl6.org/routine/run.
> In particular the last part. I don't  understand the adverbs :out and :
> err there.
> Can I set it up so that the output is piped into a file directly? If so
> how would I write that?
>
> I know I could use shell for that, but I doubt that is necessary.
>
> [On first reading I found the doc confusing because it start with a
> hairy example. WHy would anyone wish to write to a file named
> '>foo.txt'? How can that be the first example?]
>
> Thanks,
>
> --
> Theo van den Heuvel
>


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


Re: IO ???

2018-06-16 Thread Brandon Allbery
If you're performing an I/O operation on an IO::Path, either it's a
metadata operation (e.g. file tests) or you are operating on the whole file
(e.g. .lines). In the former case there is no handle; in the latter, the
handle exists only while .lines is active; that is, it exists only within
the implementation of the .lines method, it is not part of the IO::Path
object.

In short, an IO::Path is not a funny-looking handle. IO::Path methods may
internally use private handles, and thereby control their lifetimes. (It
should be closed when it goes out of scope, i.e. when the .lines method is
done, even if it's not explicitly closed.)


On Sat, Jun 16, 2018 at 1:00 PM Xin Cheng  wrote:

> I am wondering why the IO::Path class doesn't have a "close" method. After
> I read from a file by
>
> $filename.IO.lines -> $line;
>
> Am I supposed to close the file, or it is automatically closed for me
> after the reading?
>
> I tried something like
>
> $filename.IO.close;
>
> It is a runtime error. It seems to me that no need to close. Do I
> understand right? If so, why?
>
> Regards
>
> Xin
>
> On Jun 3, 2018, at 1:05 PM, ToddAndMargo  wrote:
>
> On Sun, Jun 3, 2018 at 1:01 PM ToddAndMargo  mailto:toddandma...@zoho.com >> wrote:
>Hi All,
>I have a been looking around the docs pages and I am
>not finding a list of what the various IO functions do.
>I would like a list of IO.e does this and IO.d
>does that.
>Any such list exist?
>Many thanks,
>-T
>
>
> On 06/03/2018 10:03 AM, Brandon Allbery wrote:
>
> It's a bit subtle to track down, but the IO method gives you an IO::Path
> object. https://docs.perl6.org/type/IO::Path
>
>
> I had found that, but I did not know what I was looking at.
> Thank you!
>
>
>

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


Re: Malformed UTF-8?

2018-06-16 Thread Brandon Allbery
Something's wrong with the data file you are reading. Perl 6 is expecting
UTF-8 encoding and getting something else (usually an ISO-8859 encoding).

On Sat, Jun 16, 2018 at 1:09 AM ToddAndMargo  wrote:

> rakudo-pkg-Fedora28-2018.05-01.x86_64.rpm
> $ perl6 -v
> This is Rakudo version 2018.05 built on MoarVM version 2018.05
> implementing Perl 6.c.
>
>
> What did I do wrong, this time?
>
> Malformed UTF-8
>in sub RotateZipFile at /home/linuxutil/CimCheck.pl6 line 290
>
> 290:   @ReverseLogs = @Logs.sort: {my ($month, $day, $year, $hour,
> $minute, $second) = .comb(/\d+/);($year // 0, $month // 0, $day // 0,
> $hour // 0, $minute // 0,$second // 0, $_);}
>


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


Re: EVAL?

2018-06-14 Thread Brandon Allbery
I'm trying to not second-guess whoever maintains the glossary. And by that
message also pointing up the omission.

On Thu, Jun 14, 2018 at 2:01 PM The Sidhekin  wrote:

> On Thu, Jun 14, 2018 at 7:57 PM, Brandon Allbery 
> wrote:
>
>> You can never be certain in *any* case. Check if you're not sure what it
>> means. Because sometimes languages use some term in a way you don't expect,
>> whether because they drew it from some specific discipline (Haskell uses a
>> lot of terminilogy from abstract mathematics, for example) or for some
>> reason (I've hit a few cases where the language author didn't know the
>> actual meaning of some term and used it "oddly" as a result).
>>
>> https://docs.perl6.org/language/glossary
>>
>> Which doesn't have "pragma" in it, probably because it's not specific to
>> Perl. It's been around, and used in this sense, since at least the 1960s
>> and probably earlier.
>>
>
>   ... but does have "whitespace" and "variable" in it, neither of which is
> specific to Perl. :-P
>
>   Isn't the lack of "pragma" there an omission to be corrected?
>
>   Particularly if the term is required for the reading of error messages?
>
>
> Eirik
>


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


Re: EVAL?

2018-06-14 Thread Brandon Allbery
Not to mention "language designer isn't from your culture, and the word has
different connotations in theirs". The eastern (or for that matter western)
US does not define the world.

On Thu, Jun 14, 2018 at 1:57 PM Brandon Allbery  wrote:

> You can never be certain in *any* case. Check if you're not sure what it
> means. Because sometimes languages use some term in a way you don't expect,
> whether because they drew it from some specific discipline (Haskell uses a
> lot of terminilogy from abstract mathematics, for example) or for some
> reason (I've hit a few cases where the language author didn't know the
> actual meaning of some term and used it "oddly" as a result).
>
> https://docs.perl6.org/language/glossary
>
> Which doesn't have "pragma" in it, probably because it's not specific to
> Perl. It's been around, and used in this sense, since at least the 1960s
> and probably earlier.
>
> So also check various CS glossaries.
> Such as FOLDOC: http://foldoc.org/pragma
>
> On Thu, Jun 14, 2018 at 1:52 PM ToddAndMargo 
> wrote:
>
>> On 06/14/2018 10:49 AM, Brandon Allbery wrote:
>> > That's actually the origin of it: pragmatic / real-world behavior, as
>> > opposed to idealized situations.
>>
>> I can't always tell when things are English and when
>> things are Perl.
>>
>
>
> --
> 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: EVAL?

2018-06-14 Thread Brandon Allbery
You can never be certain in *any* case. Check if you're not sure what it
means. Because sometimes languages use some term in a way you don't expect,
whether because they drew it from some specific discipline (Haskell uses a
lot of terminilogy from abstract mathematics, for example) or for some
reason (I've hit a few cases where the language author didn't know the
actual meaning of some term and used it "oddly" as a result).

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

Which doesn't have "pragma" in it, probably because it's not specific to
Perl. It's been around, and used in this sense, since at least the 1960s
and probably earlier.

So also check various CS glossaries.
Such as FOLDOC: http://foldoc.org/pragma

On Thu, Jun 14, 2018 at 1:52 PM ToddAndMargo  wrote:

> On 06/14/2018 10:49 AM, Brandon Allbery wrote:
> > That's actually the origin of it: pragmatic / real-world behavior, as
> > opposed to idealized situations.
>
> I can't always tell when things are English and when
> things are Perl.
>


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


Re: EVAL?

2018-06-14 Thread Brandon Allbery
That's actually the origin of it: pragmatic / real-world behavior, as
opposed to idealized situations.

On Thu, Jun 14, 2018 at 1:47 PM ToddAndMargo  wrote:

> On 06/14/2018 10:43 AM, The Sidhekin wrote:
> >
> >More relevant, Perl 6 documentation:
> > https://docs.perl6.org/language/pragmas
>
> You are presuming I knew the word was a Perl word.
> I though it was English, as in pragmatic
>


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


  1   2   3   4   5   6   >