Re: user and group of a file?

2017-09-26 Thread Brandon Allbery
On Tue, Sep 26, 2017 at 11:02 AM, Parrot Raiser <1parr...@gmail.com> wrote:

> This is the capability provided by Perl 5's "stat". Would a clone with
> the same properties and behaviours be the right thing, or are there
> "features" to fix?


Same features, probably. It is just one of those things that is poorly
portable to Windows, so doesn't belong in the core. There should also be a
corresponding Windows module that matches Windows APIs instead of trying to
force it to look like Unix (which is what perl 5 does).

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


Re: user and group of a file?

2017-09-26 Thread Parrot Raiser
This is the capability provided by Perl 5's "stat". Would a clone with
the same properties and behaviours be the right thing, or are there
"features" to fix?

On 9/26/17, Brandon Allbery  wrote:
> On Tue, Sep 26, 2017 at 2:11 AM, ToddAndMargo 
> wrote:
>
>> Does Perl 6 have one of those fancy subs that will tell me
>> the user and group association of a file?  Or do I just
>> make a system call to "ls"?
>>
>
> At the moment you'll have to use ls. There's an ecosystem want out for a
> POSIX support module with this functionality; the core sticks to portable
> operations, and user and group information is different on Windows
> (notably: the ownership information is SIDs / UUIDs, and it's not so much
> like Unix groups defined by its members as it is an ACL defined by logical
> operations).
>
> --
> brandon s allbery kf8nh   sine nomine
> associates
> allber...@gmail.com
> ballb...@sinenomine.net
> unix, openafs, kerberos, infrastructure, xmonad
> http://sinenomine.net
>


Re: user and group of a file?

2017-09-26 Thread Brandon Allbery
On Tue, Sep 26, 2017 at 2:11 AM, ToddAndMargo  wrote:

> Does Perl 6 have one of those fancy subs that will tell me
> the user and group association of a file?  Or do I just
> make a system call to "ls"?
>

At the moment you'll have to use ls. There's an ecosystem want out for a
POSIX support module with this functionality; the core sticks to portable
operations, and user and group information is different on Windows
(notably: the ownership information is SIDs / UUIDs, and it's not so much
like Unix groups defined by its members as it is an ACL defined by logical
operations).

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


Re: Need a second pair of eyes

2017-09-26 Thread Brandon Allbery
This explanation confuses me a bit, actually. (more inline)

On Tue, Sep 26, 2017 at 9:45 AM, Larry Wall  wrote:

> In slightly greater detail, we're currently treating an undeclared
> variable as a syntax error rather than a semantic error, and we treat
> those differently.  Syntax errors are usually treated as immediately
> fatal becase they demonstrate we don't know what language we're parsing.
>

...because that was kinda the point. But with one additional piece of
metadata (when it last switched languages) and a small amount of domain
knowledge (that multiline in the current language is less common than
single-line) it can then suggest to the user that maybe there's a missing
end-switch.

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


Re: Need a second pair of eyes

2017-09-26 Thread Larry Wall
On Mon, Sep 25, 2017 at 10:25:42AM -0400, Brandon Allbery wrote:
: So as to make this not entirely content-free: I would suggest that the
: string language note the line on which it sees a bare newline, and if it
: subsequently hits a syntax error while still parsing that string it could
: output something like perl 5's "Possible runaway multi-line string starting
: on line ..." as a suggestion.

Thing is, rakudo already does this.  It's just that it blew up before
it even got to the second quote and the subsequent two-terms-in-a-raw
syntax error where it would have noticed the runaway string.  I suppose
what we're really asking for is a slightly less fatal error on the
undeclared variable error so that it can get to the syntax error that
usually triggers the heuristic.

In slightly greater detail, we're currently treating an undeclared
variable as a syntax error rather than a semantic error, and we treat
those differently.  Syntax errors are usually treated as immediately
fatal becase they demonstrate we don't know what language we're parsing.
Semantic errors, on the other hand. indicate a known language with
unknown meaning, so we tend to continue parsing even though we know we
will blow up at the end of the parse.  So relaxing this in the parser
from immediately fatal to fatal later may be as easy as changing a .panic
to a .sorry somewhere.

Larry


undeclared variables inside double-quoted string lwas: Re: Need a second pair of eyes]

2017-09-26 Thread Timo Paulssen
On 26/09/17 04:26, Brandon Allbery wrote:
> On Mon, Sep 25, 2017 at 10:23 PM, ToddAndMargo  > wrote:
>
> On 09/25/2017 07:25 AM, Brandon Allbery wrote:
>
> So as to make this not entirely content-free: I would suggest
> that the string language note the line on which it sees a bare
> newline, and if it subsequently hits a syntax error while
> still parsing that string it could output something like perl
> 5's "Possible runaway multi-line string starting on line ..."
> as a suggestion.
>
>
> Really like this sugestion!
>
>
> I'm actually looking at the code in question now... and unsure how to
> proceed, as hacking on perl 6 parsers is a bit new to me and this
> looks like it needs to be implemented in a way that is usable by
> multiple roles representing different kinds of 'quoted string'
> (single, double, regex, ...).
>
> -- 
> brandon s allbery kf8nh                               sine nomine
> associates
> allber...@gmail.com                       
>            ballb...@sinenomine.net 
> unix, openafs, kerberos, infrastructure, xmonad      
>  http://sinenomine.net

Here's a tiny start at this. it finds undeclared variables inside double
quoted strings and points out the double quoted string existing. It does
not understand the difference between "{ $foo }" and "$foo", but there's
a $*ESCAPEBLOCK dynamic variable that gets set in the closure
interpolation piece of the nibbler (called c1), that could be interesting.

One dead-end was $*LASTQUOTE, which is only set when a quote has been
completely parsed. You can, however, probably steal a bit of code from
World.nqp where it detects run-away quotes, it's inside method
typed_exception. Could be enough to ignore $qe there and pretend $qs is
what is set in is-nibbling.

Also, the quotestart and quotetype attributes of the
X::Undeclared::InQuotes are not set by the code at present, and not
included in the message either. That requires a bit of code from the
run-away quote detection to work.

Good luck!

diff --git a/src/Perl6/Grammar.nqp b/src/Perl6/Grammar.nqp
index 9859181..3c855e0 100644
--- a/src/Perl6/Grammar.nqp
+++ b/src/Perl6/Grammar.nqp
@@ -410,7 +410,12 @@ role STD {

 CATCH {}
 }
-    $*W.throw($var, ['X', 'Undeclared'], symbol =>
$name, suggestions => @suggestions, precursor => '1');
+    if $*is-nibbling {
+    $*W.throw($var, ['X', 'Undeclared',
'InQuotes'], symbol => $name, suggestions => @suggestions, precursor =>
'1');
+    }
+    else {
+    $*W.throw($var, ['X', 'Undeclared'], symbol
=> $name, suggestions => @suggestions, precursor => '1');
+    }
 }
 }
 else {
@@ -5110,6 +5115,7 @@ grammar Perl6::QGrammar is HLL::Grammar does STD {
 token do_nibbling {
 :my $from := self.pos;
 :my $to   := $from;
+    :my $*is-nibbling := $/.from;
 [
 
 [
diff --git a/src/core/Exception.pm b/src/core/Exception.pm
index 2d30a50..5f58be3 100644
--- a/src/core/Exception.pm
+++ b/src/core/Exception.pm
@@ -971,6 +971,24 @@ my class X::Undeclared does X::Comp {
 }
 }

+my class X::Undeclared::InQuotes does X::Comp {
+    has $.what = 'Variable';
+    has $.symbol;
+    has @.suggestions;
+    has $.quotetype;
+    has $.quotestart;
+
+    method message() {
+    my $message := "$.what '$.symbol' is not declared, but used in
a double-quoted string";
+    if +@.suggestions == 1 {
+    $message := "$message. Did you mean '@.suggestions[0]'?";
+    } elsif +@.suggestions > 1 {
+    $message := "$message. Did you mean any of these?\n    {
@.suggestions.join("\n    ") }\n";
+    }
+    $message;
+    }
+}
+
 my class X::Attribute::Undeclared is X::Undeclared {
 has $.package-kind;
 has $.package-name;



user and group of a file?

2017-09-26 Thread ToddAndMargo

Dear list,

Does Perl 6 have one of those fancy subs that will tell me
the user and group association of a file?  Or do I just
make a system call to "ls"?

Many thanks,
-T