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: 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: (default) Real->Rat precision should match what compiler uses for literals

2018-03-03 Thread Brandon Allbery
Max precision rapidly becomes more memory requires than your computer has.

On Sat, Mar 3, 2018 at 3:32 PM, yary  wrote:

> Or instead of 1/2**(32 or 64), re-asking these questions about epsilon:
>
> "  Why so large?
>
>Why not zero?  "
>
> What's justification for using 1/100,000 vs. something smaller vs. 0 "max
> possible precision?"
>



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


Re: CALL-ME vs. Callable

2016-11-14 Thread Brandon Allbery
I feel like you're focusing on the wrong thing somehow. The issue is not
that what nqp is doing is somehow wrong. The issue is that the thing it is
doing is necessarily an implementation detail, and as such should be
isolated from the language level and any failures/errors exposed as
language level instead of leaking implementation details the programmer
should not have to care about. The Perl 6 way to do this is to wrap it in a
role that is documented at language level; in this case, I don't think it
is necessary for that role to translate errors between levels (this often
is needed in other such isolation-layer roles), since most (possibly all)
of the errors become language level compile time errors.

On Mon, Nov 14, 2016 at 5:08 PM, Aaron Sherman <a...@ajs.com> wrote:

> I guess I wasn't clear in what I was asking:
>
> What, exactly, was it that NQP was doing? What were the inputs and what
> was the behavior that you observed? So far, all I have to go on is one
> example that you feel is not illustrating the broken behavior of NQP that
> you want to work around with a change to the way Callable and calling work.
> I'm not suggesting that the latter is bad, but it seems to be a patch
> around a problem in the former...
>
>
>
>
> Aaron Sherman, M.:
> P: 617-440-4332 Google Talk, Email and Google Plus: a...@ajs.com
> Toolsmith, developer, gamer and life-long student.
>
>
> On Mon, Nov 14, 2016 at 4:32 PM, Brandon Allbery <allber...@gmail.com>
> wrote:
>
>>
>> On Mon, Nov 14, 2016 at 4:28 PM, Aaron Sherman <a...@ajs.com> wrote:
>>
>>> So, you said that the problem arises because NQP does something
>>> non-obvious that results in this error. Can you be clear on what that
>>> non-obvious behavior is? It sounds to me like you're addressing a symptom
>>> of a systemic issue.
>>
>>
>> That's pretty much the definition of LTA. The programmer did something
>> that on some level involves a call (in the simple example it was explicit,
>> but there are some implicit ones in the language), and got a runtime error
>> referencing an internal name instead of something preferably compile time
>> related to what they wrote. The fix for this is to abstract it into a role
>> that describes "calling"/"invoking" instead of having a CALL-ME that the
>> user didn't (and probably shouldn't) define suddenly pop up out of nowhere.
>> That isn't the part that's difficult, aside from "so why wasn't it done
>> that way to begin with?".
>>
>> --
>> 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: CALL-ME vs. Callable

2016-11-14 Thread Brandon Allbery
On Mon, Nov 14, 2016 at 5:00 PM, Jon Lang  wrote:

> So what is the assuming method, and why is it in a callable role? What was
> the logic behind that decision?


It's perfectly sensible: it's how you implement partial application (which
as sadly usual is mis-called "currying"). (foo) is a
callable (and a Callable; note however that some-callable is not
necessarily a Callable!) which, when invoked, invokes
some-callable(foo, <*parameters
to invocation here*>).


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


Re: CALL-ME vs. Callable

2016-11-14 Thread Brandon Allbery
This should probably have been cc-d to the list.

Callable claims to be the thing we want. What it actually is, is a mix-in
that adds the assuming method. I am not sure these can be conflated.

Note that the current docs actually do claim it is what I want. This is
because I first brought this up in IRC while the documentation for Callable
was being written, and it got modified to match my then current musings
because nobody who actually works on the spec was around. I had in fact
specified that this was a "would be nice" but that I wasn't sure if it
would actually work; I have since concluded that it likely won't, and needs
to be a distinct role. Which is part of why I brought this up: the current
doc does not match what currently happens, and may not actually be
implementable without breaking the spec (that is, 6.d would have a
fundamental conflict with 6.c over the meaning of Callable).

On Mon, Nov 14, 2016 at 4:30 PM, Jon Lang <datawea...@gmail.com> wrote:

> Okay, let's go with that. What does Callable do, and why is it called that?
>
> On Nov 14, 2016 1:09 PM, "Brandon Allbery" <allber...@gmail.com> wrote:
>
>>
>> On Mon, Nov 14, 2016 at 3:42 PM, Aaron Sherman <a...@ajs.com> wrote:
>>
>>> I do think, though that if the concern is really with "the 4 cases when
>>> nqp hauls a CALL-ME out of its bowels" then that's what should be
>>> addressed...
>>>
>>
>> The main addressing of that is some kind of role to abstract it properly.
>> I just think the current situation is bad and even if we come up with a
>> name for the new role, it's still going to be confusing ("ok, why do we
>> have both Callable and Invokable? ...uh wait, Callable means *what*
>> exactly?").
>>
>>
>> --
>> 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: CALL-ME vs. Callable

2016-11-14 Thread Brandon Allbery
On Mon, Nov 14, 2016 at 4:28 PM, Aaron Sherman  wrote:

> So, you said that the problem arises because NQP does something
> non-obvious that results in this error. Can you be clear on what that
> non-obvious behavior is? It sounds to me like you're addressing a symptom
> of a systemic issue.


That's pretty much the definition of LTA. The programmer did something that
on some level involves a call (in the simple example it was explicit, but
there are some implicit ones in the language), and got a runtime error
referencing an internal name instead of something preferably compile time
related to what they wrote. The fix for this is to abstract it into a role
that describes "calling"/"invoking" instead of having a CALL-ME that the
user didn't (and probably shouldn't) define suddenly pop up out of nowhere.
That isn't the part that's difficult, aside from "so why wasn't it done
that way to begin with?".

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


Re: CALL-ME vs. Callable

2016-11-14 Thread Brandon Allbery
Also...

On Mon, Nov 14, 2016 at 3:06 PM, Aaron Sherman  wrote:

> Role-based testing seems very perl6ish. I'd suggest the role name be
> "Invocable" with much the sort of signature as you've described.


If it's Invokable then the method should probably be INVOKE. It still
leaves the question of why Callable appears to be the only role named after
what it applies to instead of what it provides.

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


Re: This seems to be wrong

2016-09-18 Thread Brandon Allbery
On Sun, Sep 18, 2016 at 6:36 PM, Trey Harris  wrote:

> Does not being defined on Any explain why the error for @input.map( .Str )
> is different (Use of uninitialized value $_ of type Any in string context)
> than the error for @input.map( .Num ) (Method 'Num' not found for
> invocant of class 'Any'), but both*.Str and *.Num work in the .map?
>
Yes. Without the *, it's doing $_.Str or $_.Num when $_ is the one
*outside* the map call, which has no current value (and so is (Any)); in
the Str case it is invoking Any.Str and failing on the undefined value, in
the Num case it can't find the method for Any. With the *, it's a closure
and applies to the $_ current for each iteration of map; the invocant is a
defined Str.



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


Re: This seems to be wrong

2016-09-18 Thread Brandon Allbery
On Sun, Sep 18, 2016 at 6:29 PM, Trey Harris  wrote:

> But I see there’s a multi method Str defined on Any, and you can’t do
> @inputs.map( .Str ), either (Use of uninitialized value $_ of type Any in
> string context). Why not? (There’s no multi method Num on Any, even
> though the docs about Cool 
>
> seem to imply there should be…)
>
>
Same reason I had to wrap it in a Block --- it's not recognizing .Str as a
closure, it's running it immediately. Perhaps you wanted *.Str?


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


Re: This seems to be wrong

2016-09-18 Thread Brandon Allbery
On Sun, Sep 18, 2016 at 6:15 PM, Brandon Allbery <allber...@gmail.com>
wrote:

> for @inputs.map({ .:<+> }) { ... }


Which means the shorter way is:

for @inputs.map(+*) { ... }


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


Re: This seems to be wrong

2016-09-18 Thread Brandon Allbery
On Sun, Sep 18, 2016 at 6:06 PM, Trey Harris  wrote:

> Not work? It results inMethod 'prefix:<+>' not found for invocant of
> class 'Any', but the docs
> 
>
> say it is defined as a multi on Any….
>
>
No, they say it's a multi sub, not a multi method on Any. And the prefix:
syntax doesn't seem to work directly with the quick workaround for that, so
it ends up being

for @inputs.map({ .:<+> }) { ... }




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


Re: Is this a bug?

2016-09-18 Thread Brandon Allbery
On Sun, Sep 18, 2016 at 4:49 PM, Parrot Raiser <1parr...@gmail.com> wrote:

> What is this  -> ;; $_? is raw { #`(Block|170303864) … } output?


It's the gist of a Block, which is what you asked for when you did a `say`
on an executable block.
Why do you believe `say { $_ }` is the right thing there? What were you
expecting it to do?

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


Re: This seems to be wrong

2016-09-18 Thread Brandon Allbery
On Sun, Sep 18, 2016 at 4:31 PM, Parrot Raiser <1parr...@gmail.com> wrote:

> but seems to have a problem with larger numbers:
>
> 7
> 3
> 21  <- This
> 2
> 1
> 0
> 4
> bamm-bamm
> barney
> (Any)  <--- Produces this
> betty
> fred
> 0 out of range 1..7
> dino
>

[18 20:35]  m: say so "21" ~~ 1..7
[18 20:35]  rakudo-moar 34f950: OUTPUT«True␤
[18 20:35]  »

It came from lines(), it is a Str. Numify it first.

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


Re: Justification for the "reversed" instruction format

2016-09-07 Thread Brandon Allbery
On Wed, Sep 7, 2016 at 6:08 PM, Parrot Raiser <1parr...@gmail.com> wrote:

> There is a "flip" in P6, to reverse the characters in a string, and a
> "reverse", to return the elements of a list. Would either of those be
> an equivalent?
>

Not without an "apply" mechanism used for function / method / operator
invocations. Which is almost viable in Perl 6 since the parameters get
passed as a list --- except that the list is only visible within the
implementation, not at the call site (which is what "apply" does).

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


Re: Intalling Perl6

2016-06-26 Thread Brandon Allbery
On Sun, Jun 26, 2016 at 1:51 PM, Julian Brown  wrote:

> I search for packages on Debian Jessie for Perl 6 and found Rakudo and
> Parrot.
>
> Does everyone install per user and not system-wide?
> Does anyone use Parrot instead of Moar?
>

Debian is, as always, way behind. The Parrot backend hasn't even been
supported for over a year. (There should be be newer packages in unstable,
and possibly already in testing.)

System-wide installation was broken when the new CompUnitRepo stuff was
added, and was only recently fixed --- but still needs more testing, so if
you choose to do a system-wide install of a sufficiently recent rakudo (I
think this means 2016.05 or later) you should expect to be a guinea pig.

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


Re: It's time to use "use 6.c"

2016-02-09 Thread Brandon Allbery
On Tue, Feb 9, 2016 at 5:38 AM, Peter Pentchev  wrote:

> For the record, just to clear up some possible confusion, "use 6.c"
> doesn't work in source files; you need "use v6.c".
>

Clarifying: yary seems to have been confused by the fact that META6.json
(only) needs to use version numbers without the leading "v". Perl 6 code
needs to continue to use version-string syntax with the leading "v";
otherwise the ".c" confuses it since "c" is not a valid decimal digit. (I
assume this is because JSON marshaling of version strings creates /
consumes normal strings, those being the only strings defined in JSON, and
the leading "v" of a version string is treated as syntax in the same way
that Python's "r'" or Ruby's "%r{" are, with no way to represent those
"metadata" in JSON.)

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


Re: It's time to use "use v6.c"

2016-02-06 Thread Brandon Allbery
On Sat, Feb 6, 2016 at 2:30 PM, yary  wrote:

> this morning I installed the 2016.01 R*. Now I'm at the NYC perl6
> study group, and a helpful neighbor asked me to start up p6doc.
>

This is something of an edge case. It is reasonable for stuff that is
supposed to ship *with* perl6 to bend the rules; the problem is that nobody
realized that p6doc was broken (this was discovered earlier today), so R*
silently (grumble) didn't include it and you got some other p6doc instead.

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


Re: Rationale for $!

2016-01-28 Thread Brandon Allbery
On Wed, Jan 27, 2016 at 11:00 AM, Felipe Gasper 
wrote:

> Unrelated, but, does open() not throw on failures anyway? (Noodling with
> the perl6 REPL just now seems inconclusive.)


There have been issues with failures in sink context not throwing, IIRC? So
how you were noodling can matter.


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


Re: Rationale for $!

2016-01-28 Thread Brandon Allbery
On Wed, Jan 27, 2016 at 11:06 AM, Felipe Gasper <fel...@felipegasper.com>
wrote:

> On 27 Jan 2016 11:03 AM, Brandon Allbery wrote:
>>
>> On Wed, Jan 27, 2016 at 11:00 AM, Felipe Gasper <fel...@felipegasper.com
>> <mailto:fel...@felipegasper.com>> wrote:
>>
>> Unrelated, but, does open() not throw on failures anyway? (Noodling
>> with the perl6 REPL just now seems inconclusive.)
>>
>> There have been issues with failures in sink context not throwing, IIRC?
>> So how you were noodling can matter.
>>
>
> felipe@Macintosh-3 00:45:46 /
> > perl6
> > open("/dfgsgsdfgd", :r);
> Failed to open file /dfgsgsdfgd: no such file or directory
> > my $f = open("/dfgsgsdfgd", :r);
> Failed to open file /dfgsgsdfgd: no such file or directory
> > print $f;
> (HANDLED) Failed to open file /dfgsgsdfgd: no such file or directory
>   in any  at
> /Users/felipe/.rakudobrew/moar-2015.12/install/share/perl6/runtime/CORE.setting.moarvm
> line 1
>   in block  at  line 1
>

Looks to me like both of them threw? and $f is set to the Failure object
instead of a filehandle, which has an annotation saying that it was indeed
handled (thrown).

Perl 6 has two ways to indicate failure: you can throw immediately, or you
can return a Failure object which is a "lazy exception". The latter allows
a program to introspect the return value to recognize and handle a Failure
without actually throwing it (faster and often cleaner than catching it),
or if something just tries to use the value without checking then it throws
at that point. It remembers the context in which it was created, so the
traceback should indicate that it happened in the open call.

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


Re: Commensurability as Key

2013-08-21 Thread Brandon Allbery
On Tue, Aug 20, 2013 at 11:19 PM, Doug McNutt dougl...@macnauchtan.comwrote:

 I confess.  I'm here because I hoped perl 6 would do vector operations
 after reading an early small book.


I don't think anyone has said that it won't/can't. Perl 6 indeed returns a
scalar... but that scalar may be a container of some kind, including a
vector if such a container type has been defined. (Think perl5's refs, only
managed automatically instead of making the programmer manually convert
between refs and referenced.)

Even FORTRAN doesn't actually pass or return arbitrarily sized arrays. It
passes pointers around instead; you just can't see them or touch them
directly --- but there are ways to *abuse* them, such as the infamous hack
that lets you change the value of a literal number because of the
representation that has to be used for them just in case they're passed to
or returned from a function. Perl6 normally hides this kind of as well, but
if for some reason you need to, you can get at the underlying machinery, so
the existence of that machinery is admitted instead of being hidden and
occasionally coughing up bizarre dust bunnies.)

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


Re: Problem using a module containing a grammar

2013-03-25 Thread Brandon Allbery
On Mon, Mar 25, 2013 at 11:01 AM, phi...@free.fr wrote:

 grammar SalesExportGram is export {

 (...)

 my $parsed = SalesReportGram.parsefile('sales_report.txt');


Might help if you used the same name in both places?

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