MAIN(*magic)

2024-03-14 Thread Mark Devine
Rakoons,



I keep running into a space with Raku where it would be nice to have some magic 
to reduce boilerplate.  I often make roles & classes with interface options 
that flow from a consuming script’s MAIN arguments, then the first bit of code 
at the top the MAIN block, then into instantiation.  If a person makes nice 
utility libraries with lots of options for the user & employs them a lot, the 
time consumed typing out the boilerplate adds up & bloats the code.  Is there 
any way to shorten this pattern?  I was thinking about a ‘switchable’ trait for 
attributes (with the naivety of a schoolboy).



my class Output {

has $.csv  is switchable;

has $.html is switchable;

  .

  .

  .

has $.xml is switchable;

}



my class Timer {

has $.countis switchable;

has $.expire   is switchable;

has $.interval is switchable;

}



sub MAIN (

Output.switchables, #= switchables from Class 'Output'

Timer.switchables,  #= switchables from Class 'Timer'

) {

my Timer $t.= new: :$expire, :$interval, :$count;   # variables 
magically appear in scope

my Output $o   .= new: :$csv, :$html, … , :$xml;# variables 
magically appear in scope

}



I estimate 10-50 lines of boilerplate could be removed from most of my Raku 
scripts with something like that.  Unfortunately, I don’t possess any dark 
magic for such things or I’d put forward an attempt.



Thanks,



Mark


RE: I need sorting help

2024-03-02 Thread Mark Devine
Elizabeth,

I have been looking for that one to sort operating system devices.  Exceptional 
timing!

Thanks,

Mark Devine
(202) 878-1500

-Original Message-
From: Elizabeth Mattijsen  
Sent: Saturday, March 2, 2024 8:14 AM
To: ToddAndMargo via perl6-users 
Subject: Re: I need sorting help

$ raku -e '.say for .sort(*.split(/\d+/, :kv).map({ (try 
.Numeric) // $_}).List)
afoo2
afoo12


> On 2 Mar 2024, at 07:26, ToddAndMargo via perl6-users  
> wrote:
> 
> Hi All,
> 
> @Sorted_List = @Sorted_List.sort: { .comb(/ \d+ | \D+ /) .map({ .Int // .self 
> })};
> 
> gives me
> 
>   Element [0]  
>   Element [1]  
>   Element [2]  
>   Element [3]  
>   Element [4]  
>   Element [5]  
>   Element [6]  
>   Element [7]  
>   Element [8]  
>   Element [9]  
> 
> I need it to say
> 
>   Element [0]  
>   Element [1]  
>   Element [2]  
>   Element [3]  
>   Element [4]  
>   Element [5]  
>   Element [6]  
>   Element [7]  
>   Element [8]  
>   Element [9]  
> 
> What did I goof up, this time?
> 
> Many thanks,
> -T



RE: too many file handles

2021-03-17 Thread Mark Devine
Richard,

If a quick workaround is fitting, the problem can be dodged at the system 
level.  I'll pick 8192 open files on Linux for example:

/etc/security/limits.conf

myuser  hard nofile 8192
myuser  soft nofile 8192

This doesn't address the open file count within Raku, but sometimes people just 
want to get by the snag and keep flowing.

Mark

-Original Message-
From: Richard Hainsworth  
Sent: Wednesday, March 17, 2021 13:46
To: perl6-users 
Subject: too many file handles

I have been running into this error: "Too many open files"

Sorry for the lack of detail. The problem is that the error comes up in odd 
places, so I have found it difficult to golf down into Raku program that always 
fails with this error.

When I separate out the code that leads to the error, and create another 
program, Raku handles it without difficulty. It seems to occur when there are a 
lot of moving parts, so to speak.

I am not explicitly opening file handles, but the software I have written is 
using the idiom

"some-filename.html".IO.spurt( $an-accumulated-string );

Obviously, filehandles are being opened under the hood. Having written a file, 
there is no need to reference it again, so I could close the filehandle.

I have been told that because of the way garbage handling is implemented, there 
is a problem with file handles. If so, what is a safer idiom to use in place of 
and IO on a string, so that the handle can be closed immediately after use?

Appreciate some help on this.

Richard



IO::Socket::Async::SSL on new Linux

2020-11-27 Thread Mark Devine
Appreciation to https://github.com/jnthn for his recent update to 
https://github.com/jnthn/p6-io-socket-async-ssl.

My lab consists of the below Linux platforms, where the starred four 
distributions were snagged on IO::Socket::Async::SSL, thereby holding back cro. 
 Not tonight!

CentOS Linux release 7.9.2009 (Core)
*   CentOS Linux release 8.2.2004 (Core)
Debian GNU/Linux 10 (buster)
Fedora 32 (Thirty Two)
*   Fedora 33 (Thirty Three)
Oracle Linux Server 7.9
*   Oracle Linux Server 8.3
openSUSE Leap 15.2
Ubuntu 18.04.5 LTS
*   Ubuntu 20.04.1 LTS

Gratitude for getting cro via IO::Socket::Async::SSL enabled on these more 
recent distros.

- Mark



RE: just curious to know

2020-06-14 Thread Mark Devine
Radhakrishnan,

I would be considered a non-developer and more of a system admin/architect.  
I’ve used Perl 4/5 since the 1990s with success.  My opinion of Python is not 
particularly high, except that it is ubiquitous (like Perl 5).  Ruby was not 
unpleasant.  I’ve sampled a few others, but none were particularly fantastic 
for my general scripting purposes.

I consider Raku (formally renamed from “Perl 6” Oct 2019) as 
a modern alternative to Perl 5.  All of my operating system scripts are now in 
implemented in Raku.

I did frequently wince at some of the constructs that I had to put together in 
Perl.  I saw myself writing line noise and write-only scripts/modules, but I 
really didn’t have alternatives in Perl.  I have yet to experience any regret 
with coding Raku.  Raku appears to me to be the most well-thought-out language 
I’ve ever experienced.  I make basic & intermediate programming constructs, and 
the deeper I go, the more satisfying the coding experience.  I am confident 
that I can make reusable code in Raku that will be maintainable in 20 years.  
The Raku coding experience to me is like that of a 12-year-old playing the 
latest video game on a 90” 16K screen.  That’s just how it is.  I don’t mean to 
cheerlead.  I’m sincere.  It promotes “flow”, which encourages me to learn and 
produce more.  Perl had that “flow” characteristic too, and Raku inherited it.

The first release was Christmas 2015, launching with a small 
ecosystem.  Now it is growing with many useful 
modules (Web Services, DevOps, etc.).  The community is active, very patient, 
civil, and spot-on-helpful.

Raku is a big language.  I’m really hoping one or more of the superstars of 
Raku will publish “Idiomatic Raku: Parallelism, Concurrency, & Asynchrony”, 
“Idiomatic Raku: This”, “Idiomatic Raku: That”, etc.  A big language like this 
would benefit from more guidance.  Random blogs regularly publish brilliant 
Raku ideas, but it is a challenge to catalog/archive them.  I do hope for more 
expert knowledge sharing.

I think Larry Wall’s ambition was to make a “100 year” language.  Personally I 
can see that in Raku (until Quantum perhaps).  Raku has legs.  It probably 
isn’t positioned for the popularity contests of today, but I think that it has 
much more promise than people are aware of.

Try building a website or a web service in Cro to see 
the utility of Raku first hand.

Mark

From: Radhakrishnan Venkataraman 
Sent: Sunday, June 14, 2020 11:04
To: l...@dijkmat.nl
Cc: perl6-users@perl.org
Subject: just curious to know

Hi,
I had been a perl 5.0 user in the past.  Ever since perl 6.0 was announced, I 
waited, like many, indefinitely.  At last perl 6.0 has just started from its 
starting block and is also in the race.  I am happy about that.

Perl 5.0 was generally termed to be good at CGI scripting, system 
administration, web scraping, strong regex, processing text files etc.,

I want to know what perl 6 is so special in.  When perl 5.0 was there, there 
did not exist any other language to do the same things easily as perl 5.0 did. 
Similarly, in which areas perl 6 is special?  I am unable to know it from 
google search, as much information is not available.

Further, if concurrency and parallelism are the special things in perl 6, then 
Rust and Go (so special in both concurrency and parallelism) are already 
spreading its wings over the information technology field.  Both are statically 
typed and compiled languages and there would be more "welcome gesture" for 
these languages in the field.

To put my question simply, where is the space for perl 6 in today's technology?
Please enlighten me (any body from user group) on this.

Thank you,

Regards,
Radhakrishnan


RE: question about the multi in method

2020-06-08 Thread Mark Devine
Peter,

I applaud your excellent assistance with Raku.  Et. al. (you know the names)...

Outstanding community!

Mark

-Original Message-
From: Peter Pentchev  
Sent: Monday, June 8, 2020 17:13
To: perl6-users@perl.org
Subject: Re: question about the multi in method

On Mon, Jun 08, 2020 at 01:28:34PM -0700, ToddAndMargo via perl6-users wrote:
> On 2020-06-08 02:45, Richard Hainsworth wrote:
> > Ok Todd, let me have a go at this issue.
> > 
> >  From what I understand, you see 'multi' and think 'there are more 
> > than one', which leads to the question 'where are they?'
> > 
> > My understanding of 'multi' is 'there COULD be more than one', which 
> > leads to the question 'are there any?'
> > 
> > This is actually a very powerful aspect of Raku.
> > 
> > There are (as has been stated in this thread) four types of which  
> > multi = 'could be more than one' and only = 'only one' .
> > 
> > If the developer wrote 'only sub' then, no one else could write a 
> > sub with that name. For a developer of a program or a module, that 
> > might be OK, because it's unlikely anyone else would need/want to use that 
> > name.
> > But for a compiler, the probability is reversed. Someone will want 
> > to use it. That is why in many other languages there are 'reserved words'
> > which you are not allowed to use.
> > 
> > In Raku, if you develop a new type, for example say a quodion, and 
> > you want to 'add' quodions, then you CAN use + because it can be overloaded.
> > It is defined as a multi.
> > 
> > Or in your most overused example 'needle' can be rewritten to take a 
> > quodion, which may yield a spectrum of results because that's what 
> > quodions are for.
> > 
> > Since needle is defined as a 'multi', if you write a 'needle' method 
> > for quodions, the needle for strings STILL exists, and Raku will 
> > correctly call the method you wrote for quodions if a quodion is 
> > implied, but call the default needle if a string (or any other type) is 
> > used.
> > 
> > Since you have developed the quodion method entirely for your paid 
> > subscribers, the module is NOT available to the public, so you wont 
> > tell anyone about it. So it doesn't have to be in the documentation.
> > 
> > Is this making any sense to you?
> > 
> > Richard
> 
> 
> Hi Richard,
> 
> You are perfectly clear and beautifully well written.
> You did make me look up "quodion".
> 
> :-)
> 
> And I am feeling guilty because I did already know all this and it 
> looks like you spent a considerable amount of time getting into my 
> head to formulate an answer that was perfect for me.
> 
> Here is the thing.  I have no objecting to the developer calling 
> something a "multi" or an "only" depending on his needs.  That is 
> entirely "HIS" call, "NOT" mine.
> 
> And I hope the above statement ends all the well meaning, helpful 
> folks who are trying the re-explain the concept to me.  I got it a 
> LONG time ago.
> 
> My objection is when there actually exists more than one and they are 
> not experimental or otherwise hidden for some reason and are truly, 
> actually part of the distribution, then they also should be 
> documented.
> Updates to the documentation should be part of the code check in 
> process, and in all probability, are.
> 
> So, basically what I am saying is when multiples are there and are 
> open to the public, than it should be documented.  In this situation, 
> why would the developer want his hard work hidden?

OK, let me try to give you another example. If I'm too long-winded, there will 
be an abstract at the end :)

Say somebody is writing a library that should serve as the standard library for 
the C language. Now, there is a published, adopted standard for the C language 
that all C compilers and C standard libraries follow[1].

Now, the C language standard says that there may be more than one library - one 
called "libc" as "the C library" providing pretty much all of the functions, 
and another one called "libm" as "the mathematics library" providing some 
additional functions for more-or-less precise mathematical operations[2]. The 
standard says that the C library must provide a function called printf() that 
prints out all kinds of things according to a specific format, and that the 
maths library must provide a function called trunc() that pretty much rounds a 
real number down to the nearest integer that is not larger than it (so 
trunc(3.0) would return 3, trunc(4.5) would return 4, and trunc(-3.5) would 
return -4).

OK... So somebody is writing a "libc" that must provide the printf() function, 
and they suddenly realize that, in order to be able to print out real numbers 
with, say, two digits after the decimal point, one of the easiest ways is to 
have a function that rounds a real number down.
So they write such a function, let's call it printf_trunc(), and they hide it, 
they make it internal to the "libc" library, so your programs can't see it. 
Right? Everything's fine, there is an internal 

RE: Wrap an attribute’s ^get_value method in TWEAK

2019-09-08 Thread Mark Devine
Easy for you to say...  (haha)

Nice!  Many thanks.

Mark


From: Vadim Belman 
Sent: Sunday, September 8, 2019 21:32
To: Mark Devine 
Cc: perl6-users 
Subject: Re: Wrap an attribute’s ^get_value method in TWEAK

Here is a quickly hacked together example:

multi trait_mod: (Attribute:D $a, :$xmlattr!) {
my $mname = $a.name.substr(2);
my  = my method { say "ATTR($mname):", my \val = $a.get_value(self); 
val };
_name($mname);
$a.package.^add_method($mname, );
}

class Foo {
has $.foo is xmlattr;
}

say Foo.new(foo => 42).foo;


It would output:

ATTR(foo):42
42

Best regards,
Vadim Belman


On Sep 8, 2019, at 8:59 PM, Mark Devine 
mailto:m...@markdevine.com>> wrote:

Vadim,

Vadim,

Would you be able to expand on how to implement the trait that wraps into what 
is effectively the ‘get_value’ accessor of an attribute?  I’m not finding 
enough in the documentation to connect the dots.  I’ve looked at XML::Class, 
which does some pretty heavy trait’ing, but my intuition has expired.

my role XML-attribute {
has $attr;
method get_value () {
say 'in XML-attribute method get_value with ' ~ $.name;
$attr;
}
method set_value ($) {
say 'in XML-attribute method set_value with ' ~ $.name;
$attr = $;
}
}

multi sub trait_mod: (Attribute $a, :$xmlattr) {
say "⟨is xmlattr⟩ has been called with ⟨$xmlattr⟩ on {$a.WHICH}";
$a does XML-attribute;
}

class System {
has Str $.SerialNumber is xmlattr;
}

say System.new(:SerialNumber('ABCDEFG')).SerialNumber;


I’ve twisted myself into a pretzel.  I couldn’t even find where a role gets 
‘$’, but I saw it in JSTOWE’s code so I mimicked.

I need a little more broad-based help on what goes where and when.

Thanks,

Mark

From: Vadim Belman mailto:vr...@lflat.org>>
Sent: Sunday, September 8, 2019 14:57
To: Mark Devine mailto:m...@markdevine.com>>
Cc: perl6-users mailto:perl6-users@perl.org>>
Subject: Re: Wrap an attribute’s ^get_value method in TWEAK

Hi Mark,

get_value won't give you what you expect. It's use is narrowly limited to trait 
'is handles' and method .perl. Besides, are you sure all of your attributes 
will be considered as belonging to XML? I mean, won't there be need for utility 
attributes serving exclusively internal needs of a class? If so, then the best 
solution is to create a trait for an attribute and have it like:

has $.SerialNumber is xmlattr;

The trait would then install an accessor which would do what you need.

Best regards,
Vadim Belman



On Sep 8, 2019, at 12:41 PM, Mark Devine 
mailto:m...@markdevine.com>> wrote:

Perl6 Community,

How do I properly wrap an attribute’s ^get_value method in TWEAK?  If a 
condition exists, I’d like to wrap all (:local) attributes so that they can do 
some extra work.

The module that I’m working on has classes/attributes for hundreds of fields in 
dozens of different, big XML files -- there’s a lot.  And XML is easily 
extended, so I may very well be adding hundreds more attributes in the future.  
I would very much prefer to preserve the automatic accessor behavior of ‘has 
$.attr;’ versus writing a billion set/get accessors myself – truly prohibitive. 
 Wrapping seems the elegant/extensible approach.

class System {
has $.SerialNumber;
submethod TWEAK {
for self.^attributes(:local) -> $attr {
self.$attr.^get_value.wrap: { say 'in ' ~ $attr.name ~ "'s 
get_value"; nextsame; };
}
self;
}
}
say System.new(:SerialNumber('ABCDEFG')).SerialNumber;

# OUTPUT: No such method 'CALL-ME' for invocant of type 'Attribute'

I know the above .wrap is probably misguided, but it sort of demonstrates what 
I’m trying to do.

I’m not finding the proper approach.  Any hints?  Any tutorials?  Any existing 
examples in the ecosystem that I could mimic?

Thanks,

Mark



RE: Wrap an attribute’s ^get_value method in TWEAK

2019-09-08 Thread Mark Devine
Vadim,

Vadim,

Would you be able to expand on how to implement the trait that wraps into what 
is effectively the ‘get_value’ accessor of an attribute?  I’m not finding 
enough in the documentation to connect the dots.  I’ve looked at XML::Class, 
which does some pretty heavy trait’ing, but my intuition has expired.

my role XML-attribute {
has $attr;
method get_value () {
say 'in XML-attribute method get_value with ' ~ $.name;
$attr;
}
method set_value ($) {
say 'in XML-attribute method set_value with ' ~ $.name;
$attr = $;
}
}

multi sub trait_mod: (Attribute $a, :$xmlattr) {
say "⟨is xmlattr⟩ has been called with ⟨$xmlattr⟩ on {$a.WHICH}";
$a does XML-attribute;
}

class System {
has Str $.SerialNumber is xmlattr;
}

say System.new(:SerialNumber('ABCDEFG')).SerialNumber;


I’ve twisted myself into a pretzel.  I couldn’t even find where a role gets 
‘$’, but I saw it in JSTOWE’s code so I mimicked.

I need a little more broad-based help on what goes where and when.

Thanks,

Mark

From: Vadim Belman 
Sent: Sunday, September 8, 2019 14:57
To: Mark Devine 
Cc: perl6-users 
Subject: Re: Wrap an attribute’s ^get_value method in TWEAK

Hi Mark,

get_value won't give you what you expect. It's use is narrowly limited to trait 
'is handles' and method .perl. Besides, are you sure all of your attributes 
will be considered as belonging to XML? I mean, won't there be need for utility 
attributes serving exclusively internal needs of a class? If so, then the best 
solution is to create a trait for an attribute and have it like:

has $.SerialNumber is xmlattr;

The trait would then install an accessor which would do what you need.

Best regards,
Vadim Belman


On Sep 8, 2019, at 12:41 PM, Mark Devine 
mailto:m...@markdevine.com>> wrote:

Perl6 Community,

How do I properly wrap an attribute’s ^get_value method in TWEAK?  If a 
condition exists, I’d like to wrap all (:local) attributes so that they can do 
some extra work.

The module that I’m working on has classes/attributes for hundreds of fields in 
dozens of different, big XML files -- there’s a lot.  And XML is easily 
extended, so I may very well be adding hundreds more attributes in the future.  
I would very much prefer to preserve the automatic accessor behavior of ‘has 
$.attr;’ versus writing a billion set/get accessors myself – truly prohibitive. 
 Wrapping seems the elegant/extensible approach.

class System {
has $.SerialNumber;
submethod TWEAK {
for self.^attributes(:local) -> $attr {
self.$attr.^get_value.wrap: { say 'in ' ~ $attr.name ~ "'s 
get_value"; nextsame; };
}
self;
}
}
say System.new(:SerialNumber('ABCDEFG')).SerialNumber;

# OUTPUT: No such method 'CALL-ME' for invocant of type 'Attribute'

I know the above .wrap is probably misguided, but it sort of demonstrates what 
I’m trying to do.

I’m not finding the proper approach.  Any hints?  Any tutorials?  Any existing 
examples in the ecosystem that I could mimic?

Thanks,

Mark



Wrap an attribute’s ^get_value method in TWEAK

2019-09-08 Thread Mark Devine
Perl6 Community,

How do I properly wrap an attribute’s ^get_value method in TWEAK?  If a 
condition exists, I’d like to wrap all (:local) attributes so that they can do 
some extra work.

The module that I’m working on has classes/attributes for hundreds of fields in 
dozens of different, big XML files -- there’s a lot.  And XML is easily 
extended, so I may very well be adding hundreds more attributes in the future.  
I would very much prefer to preserve the automatic accessor behavior of ‘has 
$.attr;’ versus writing a billion set/get accessors myself – truly prohibitive. 
 Wrapping seems the elegant/extensible approach.

class System {
has $.SerialNumber;
submethod TWEAK {
for self.^attributes(:local) -> $attr {
self.$attr.^get_value.wrap: { say 'in ' ~ $attr.name ~ "'s 
get_value"; nextsame; };
}
self;
}
}
say System.new(:SerialNumber('ABCDEFG')).SerialNumber;

# OUTPUT: No such method 'CALL-ME' for invocant of type 'Attribute'

I know the above .wrap is probably misguided, but it sort of demonstrates what 
I’m trying to do.

I’m not finding the proper approach.  Any hints?  Any tutorials?  Any existing 
examples in the ecosystem that I could mimic?

Thanks,

Mark


RE: FW: Type name limit?

2019-08-14 Thread Mark Devine
Yary,

No, I can’t reproduce with independent test code so far.  I gave it a quick try 
but could not reproduce it (see the alphabet soup at the bottom of this thread).

ROLE.pm6
unit role ROLE;
method XXX () { say 'Nothing'; }
.pm6
unit class ;
use ::;
has :: $.B;
submethod TWEAK { $!B = ::.new(); }
/.pm6
use ROLE;
unit class :: does ROLE;
use ::::;
has :::: $.C;
submethod TWEAK { $!C = 
::::.new(); }
…
and so on
…
////////.pm6
use ROLE;
unit class 
::::::::::::::::
 does ROLE;
use 
::::::::::::::::::;
has 
::::::::::::::::::
 $.J;
submethod TWEAK { $!J = 
::::::::::::::::::.new();
}

Those crazy-long names compiled just fine.  All of my attempts to reproduce 
this behavior outside of my project 
(https://github.com/markldevine/perl6-Hypervisor-IBM-POWER-HMC) have failed so 
far.  I’m going to implement more modules with even more depth and see if I can 
reproduce the problem elsewhere in the project’s code.

My work-around

  *   cp DynamicPowerSavingTunables.pm6 ../..
  *   vi ../../ DynamicPowerSavingTunables.pm6  # delete 46 chars from 
‘unit class …’
  *   vi ../EnergyManagementConfiguration,pm6 # delete 46 chars from 
‘need’, ‘has’ type, and assignment type
  *   ~/bin/ManagedSystems# 
good compile, expected results

When I fold the module higher up in the hierarchy like the above, it 
compiles/executes successfully.  I’m stumped.

Thanks,

Mark

From: yary 
Sent: Wednesday, August 14, 2019 17:05
To: Mark Devine 
Cc: perl6-users 
Subject: Re: FW: Type name limit?

 What's the simplest way to get the error- can you make a 1 or 2 line class 
definition that should compile but doesn't?

On Wed, Aug 14, 2019, 10:27 AM Mark Devine 
mailto:m...@markdevine.com>> wrote:

Perl 6 Community,



Adding the gory details of my dilemma (JPG attached):



Red (longest & 2nd longest) fail to compile with:



===SORRY!===

Type 
'Hypervisor::IBM::POWER::HMC::ManagedSystems::ManagedSystem::EnergyManagementConfiguration'
 is not declared

at 
/home/mdevine/github.com/perl6-Hypervisor-IBM-POWER-HMC/lib/Hypervisor/IBM/POWER/HMC/ManagedSystems/ManagedSystem.pm6<http://github.com/perl6-Hypervisor-IBM-POWER-HMC/lib/Hypervisor/IBM/POWER/HMC/ManagedSystems/ManagedSystem.pm6>
 (Hypervisor::IBM::POWER::HMC::ManagedSystems::ManagedSystem):57

--> gedSystem::EnergyManagementConfiguration⏏   
$.EnergyManagementConfigurati

Malformed has

at 
/home/mdevine/github.com/perl6-Hypervisor-IBM-POWER-HMC/lib/Hypervisor/IBM/POWER/HMC/ManagedSystems/ManagedSystem.pm6<http://github.com/perl6-Hypervisor-IBM-POWER-HMC/lib/Hypervisor/IBM/POWER/HMC/ManagedSystems/ManagedSystem.pm6>
 (Hypervisor::IBM::POWER::HMC::ManagedSystems::ManagedSystem):57

--> ER::HMC::ManagedSystems::ManagedSystem::⏏EnergyManagementConfiguration



Green compiles fine.



I started with the longest-name configuration, experienced the compile error, 
copied the file up one directory, adjusted the names where required, then 
experienced the compile error again.  I repeated by copying 
DynamicPowerSavingTunables.pm6 yet another dire

Type name limit?

2019-08-13 Thread Mark Devine
This is Rakudo version 2019.07.1 built on MoarVM version 2019.07.1 implementing 
Perl 6.d.

Is there a type “name” size limit in Perl 6/Rakudo/Moar?

I’ve been making a hierarchy of classes to take in a > 4MB XML file, and I 
found it organized & convenient to use the names of the elements for class 
names and folders/.pm6 file names.  Perl 6 lets me do this for a few levels, 
then eventually refuses to compile because the latest (deep-in-the-hierarchy) 
class I added & ‘use’ and type an attribute with ‘has’ – is deemed insufficient 
as a type.  (actually the compile error says the parent of the new class isn't 
sufficiently type-like anymore)

Hypervisor::IBM::POWER::HMC # a REST API client package
  ::ManagedSystems  # xml root
::Managed-System# etc.
  ::EnergyManagementConfiguration
::DynamicPowerSavingTunables
  ::MinimumUtilizationThresholdForIncreasingFrequency
:: etc.
  :: etc.

Since I’ve encountered the compile error I’ve started folding the class files 
at an arbitrary level, but that’s not intuitive.  Implementing the hierarchy in 
the file system and class names seems much better.  (34" monitors are prevalent 
now)

If there is a type-name limit, then it would appear to be arbitrary.  Is it 
configurable?

Would anyone care to clarify?

Thanks,

Mark


RE: Perl6 use cases

2018-11-05 Thread Mark Devine
N6Ghost,

I use Perl 6 exclusively now for "systems" work.

- SSH commands to 500 systems to gather their info using 
promises/supplies/channels
- make Perl 6 modules for cantankerous system management utilities, 
then write scripts that use my .pm6 modules for various purposes (I.e. 
enterprise backup/restore clients)
- organize various REST APIs (I.e. vSphere, ISP OpCenter, ILMT) in .pm6 
modules, get status, send to NOC consoles to alert on-call people, email 
administrators
- parse arcane utilities (I.e. IBM's tape utility) that produce 
structured output with grammars, then take action (eject some tapes, check-in 
only inbound cartridges that are returning from the vault, etc.)

I began this use-pattern in 1996 with Perl 4, then to 5.  I started to get 
annoyed by the things that many people have pointed out about Perl.  I looked 
at other scripting languages, but I saw a lot of the same annoyances.  Perl 6 
doesn't annoy me at all -- flows great for me, very elegant.  Using 
Python/Ruby/Perl5/etc. again makes me wince.

I think that Perl 6 has long term potential.  I don't want to strategically 
plan to become deeply proficient in multiple languages if I can avoid it.  (My 
spouse is Chinese and I'm expected to learn Mandarin too!)  Perl 6 appears to 
have what I need until retirement (53 now).  I think that it has legs.

Mark


-Original Message-
From: N6ghost  
Sent: Sunday, November 4, 2018 23:19
To: perl6-users@perl.org
Subject: Perl6 use cases

Hi all,

Been looking around trying to find, anyone who is actually using Perl6.
and what they are using it for.

and if they are, what are there thoughts on it?

Thanks

-N6Ghost


RE: Could this be any more obscure?

2018-09-28 Thread Mark Devine
I guess I’m extra impressed with esoteric linguistic references.  Your replies 
were concise and I understood them pretty quickly.

Mark


From: Brandon Allbery 
Sent: Friday, September 28, 2018 21:51
To: Mark Devine 
Cc: la...@wall.org; ToddAndMargo ; perl6-users 

Subject: Re: Could this be any more obscure?

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 
mailto:m...@markdevine.com>> 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 mailto:la...@wall.org>>
Sent: Friday, September 28, 2018 21:28
To: ToddAndMargo mailto:toddandma...@zoho.com>>
Cc: perl6-users@perl.org<mailto:perl6-users@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<mailto:allber...@gmail.com>


RE: Could this be any more obscure?

2018-09-28 Thread Mark Devine
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-users@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


RE: Please explain this to me

2018-09-16 Thread Mark Devine
I get it.  Different angles of approach.  Some methods don't make a dent with 
me (I.e. rote).

Mark

-Original Message-
From: ToddAndMargo  
Sent: Sunday, September 16, 2018 21:42
To: perl6-users@perl.org
Subject: Re: Please explain this to me

On 09/16/2018 06:23 PM, Mark Devine wrote:
> foy, brian d. Learning Perl 6: Keeping the Easy, Hard, and Impossible Within 
> Reach (Kindle Location 557). O'Reilly Media. Kindle Edition.
> 
> Chapter 2: Binding and Assignment: "There’s an important concept here that 
> you should learn early."  [[ what follows in the most concise and 
> understandable explanation that I have found yet to the question you raised ]]
> 
> As I'm going through Learning Perl 6, he's really done a fantastic job of 
> answering tons of the questions that I've been tracking in this mailing list. 
>  Uncanny really.  The author rolls the angles just right and I'm having 
> mini-epiphanies one after another.
> 
> So recommended...
> 
> Mark

Hi Mark,

I am sorry, but books don't work for me.  Manuals do.
And correspondences do too.   That is just the way my
brain works. And, yes, I know I am weird.

-T


RE: Please explain this to me

2018-09-16 Thread Mark Devine
foy, brian d. Learning Perl 6: Keeping the Easy, Hard, and Impossible Within 
Reach (Kindle Location 557). O'Reilly Media. Kindle Edition.

Chapter 2: Binding and Assignment: "There’s an important concept here that you 
should learn early."  [[ what follows in the most concise and understandable 
explanation that I have found yet to the question you raised ]]

As I'm going through Learning Perl 6, he's really done a fantastic job of 
answering tons of the questions that I've been tracking in this mailing list.  
Uncanny really.  The author rolls the angles just right and I'm having 
mini-epiphanies one after another.

So recommended...

Mark

-Original Message-
From: ToddAndMargo  
Sent: Sunday, September 16, 2018 21:02
To: perl6-users@perl.org
Subject: Re: Please explain this to me

On 09/16/2018 05:58 PM, Curt Tilmes wrote:
> Read this:
> https://perl6advent.wordpress.com/2017/12/02/perl-6-sigils-variables-a
> nd-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


RE: RFE: contains documentation

2018-09-07 Thread Mark Devine
I second that nod.  Learning Perl 6 is fixing up all kinds of my errant mental 
models.  Just what I needed.

Mark


From: Curt Tilmes 
Sent: Friday, September 7, 2018 21:25
To: Todd Chester 
Cc: perl6-users 
Subject: Re: RFE: contains documentation


On Fri, Sep 7, 2018 at 8:58 PM ToddAndMargo 
mailto:toddandma...@zoho.com>> wrote:
My big gripe with the documentation is that it is written as
a refresher for those that already know what they are doing.
This is why I am such a good case for spotting things that
do not resonate with beginners.

I am clueless, until I learn.  When I do, I write my own
notes.  I have been trying to remember to write you guys
when the docs fly over my head.

The documentation isn't a tutorial, but is still improving every day.

I've been making my way through brian d foy's new book "Learning Perl 6: 
Keeping the Easy, Hard, and Impossible Within Reach" ( 
https://www.amazon.com/Learning-Perl-Keeping-Impossible-Within/dp/149197768X )

It is an awesome learning resource, much more in depth than the online docs.  
I'm very impressed by the thoroughness and overall quality.

I've found it quite an enjoyable read, and have already learned quite a few 
things and a better understanding of other things myself.
(I'll try to write an Amazon review when I get a chance -- it will get 5 stars 
from me.)

Curt
(I was a Kickstarter funder.)



RE: Perl6 POSIX IEEE Std 1003.1

2018-08-14 Thread Mark Devine
Liz,

I'm a "Systems" person, so I'm checking hosts/IPs/networks/users/groups/etc. 
frequently enough to benefit from your project.

My wish is that someone will someday do the heavy lifting for getnameinfo 
(http://pubs.opengroup.org/onlinepubs/9699919799/functions/getnameinfo.html), 
which gave me a headache when I tried.  I'm using getaddrinfo quite a bit now 
that someone fleshed it out in the Perl6 docs.

Thanks again for your work on Perl6!

Mark

-Original Message-
From: Elizabeth Mattijsen  
Sent: Tuesday, August 14, 2018 18:04
To: perl6-users 
Subject: Re: Perl6 POSIX IEEE Std 1003.1

Thank you.  Please let me know if you miss anything and/or find any problems.  
For myself, I’ve hardly had any use for these modules so they’re probably 
undertested.


Liz

> On 14 Aug 2018, at 22:15, Mark Devine  wrote:
> 
> Wow.  Glad I asked…
>  
> Thank you Elizabeth Mattijsen!  We’ll benefit greatly from your industrious 
> work.
>  
> Mark
>  
> From: JJ Merelo  
> Sent: Tuesday, August 14, 2018 17:01
> To: Mark Devine ; perl6-users 
> Subject: Re: Perl6 POSIX IEEE Std 1003.1
>  
> Many of them are already in the ecosystem as part of lizmat's Buttefly 
> project of porting Perl 5 CPAN modules to Perl 6. That If I remember 
> correctly, the ones you mention are one of the few that are missing, but you 
> can find most of them here: https://modules.perl6.org/search/?q=p5
>  
> Cheers
>  
>  
> El mar., 14 ago. 2018 a las 22:56, Mark Devine () 
> escribió:
> Perl6 Users,
>  
> The POSIX module in the ecosystem (https://github.com/cspencer/perl6-posix) 
> implements a few commonly used subs from POSIX IEEE Std 1003.1 in a single 
> file, which I found useful.  I wanted to use more of these so I coded a few 
> simple subroutines with NativeCall for my own use.  The more I look at it, I 
> will likely want to use a lot more of these functions/headers in Perl6 over 
> the long term.
>  
> Perl5 had a few of these subroutines included with the core distribution, as 
> well as a utility to extract header info.  Perl6 doesn’t include POSIX IEEE 
> Std 1003.1 in the core distro that I could see.
>  
> I am not a developer, otherwise I’d author Perl6 POSIX IEEE Std 1003.1 
> modules for the ecosystem.  getaddrinfo/freeaddrinfo 
> (https://docs.perl6.org/language/nativecall#Short_tutorial_on_calling_a_C_function)
>  clearly demonstrated to me that I was out of my depth, but some Perl6 
> developers seem to be fluent with these NativeCall constructs without 
> breaking a sweat.
>  
> Are there any initiatives to include POSIX IEEE Std 1003.1 in Perl6, 
> hopefully holistically?  Maybe with an extensible hierarchical file structure 
> (I.e. POSIX::getaddrinfo, POSIX::getnameinfo, etc.)?  Are there other Perl6 
> users who see a need for more POSIX IEEE Std 1003.1 functions 
> (http://pubs.opengroup.org/onlinepubs/9699919799/idx/functions.html)?
>  
> Thanks,
>  
> Mark
>  
> 
> 
> -- 
> JJ


RE: Perl6 POSIX IEEE Std 1003.1

2018-08-14 Thread Mark Devine
Wow.  Glad I asked…

Thank you Elizabeth Mattijsen!  We’ll benefit greatly from your industrious 
work.

Mark

From: JJ Merelo 
Sent: Tuesday, August 14, 2018 17:01
To: Mark Devine ; perl6-users 
Subject: Re: Perl6 POSIX IEEE Std 1003.1

Many of them are already in the ecosystem as part of lizmat's Buttefly project 
of porting Perl 5 CPAN modules to Perl 6. That If I remember correctly, the 
ones you mention are one of the few that are missing, but you can find most of 
them here: https://modules.perl6.org/search/?q=p5

Cheers


El mar., 14 ago. 2018 a las 22:56, Mark Devine 
(mailto:m...@markdevine.com>>) escribió:
Perl6 Users,

The POSIX module in the ecosystem (https://github.com/cspencer/perl6-posix) 
implements a few commonly used subs from POSIX IEEE Std 1003.1 in a single 
file, which I found useful.  I wanted to use more of these so I coded a few 
simple subroutines with NativeCall for my own use.  The more I look at it, I 
will likely want to use a lot more of these functions/headers in Perl6 over the 
long term.

Perl5 had a few of these subroutines included with the core distribution, as 
well as a utility to extract header info.  Perl6 doesn’t include POSIX IEEE Std 
1003.1 in the core distro that I could see.

I am not a developer, otherwise I’d author Perl6 POSIX IEEE Std 1003.1 modules 
for the ecosystem.  getaddrinfo/freeaddrinfo 
(https://docs.perl6.org/language/nativecall#Short_tutorial_on_calling_a_C_function)
 clearly demonstrated to me that I was out of my depth, but some Perl6 
developers seem to be fluent with these NativeCall constructs without breaking 
a sweat.

Are there any initiatives to include POSIX IEEE Std 1003.1 in Perl6, hopefully 
holistically?  Maybe with an extensible hierarchical file structure (I.e. 
POSIX::getaddrinfo, POSIX::getnameinfo, etc.)?  Are there other Perl6 users who 
see a need for more POSIX IEEE Std 1003.1 functions 
(http://pubs.opengroup.org/onlinepubs/9699919799/idx/functions.html)?

Thanks,

Mark



--
JJ


Perl6 POSIX IEEE Std 1003.1

2018-08-14 Thread Mark Devine
Perl6 Users,

The POSIX module in the ecosystem (https://github.com/cspencer/perl6-posix) 
implements a few commonly used subs from POSIX IEEE Std 1003.1 in a single 
file, which I found useful.  I wanted to use more of these so I coded a few 
simple subroutines with NativeCall for my own use.  The more I look at it, I 
will likely want to use a lot more of these functions/headers in Perl6 over the 
long term.

Perl5 had a few of these subroutines included with the core distribution, as 
well as a utility to extract header info.  Perl6 doesn't include POSIX IEEE Std 
1003.1 in the core distro that I could see.

I am not a developer, otherwise I'd author Perl6 POSIX IEEE Std 1003.1 modules 
for the ecosystem.  getaddrinfo/freeaddrinfo 
(https://docs.perl6.org/language/nativecall#Short_tutorial_on_calling_a_C_function)
 clearly demonstrated to me that I was out of my depth, but some Perl6 
developers seem to be fluent with these NativeCall constructs without breaking 
a sweat.

Are there any initiatives to include POSIX IEEE Std 1003.1 in Perl6, hopefully 
holistically?  Maybe with an extensible hierarchical file structure (I.e. 
POSIX::getaddrinfo, POSIX::getnameinfo, etc.)?  Are there other Perl6 users who 
see a need for more POSIX IEEE Std 1003.1 functions 
(http://pubs.opengroup.org/onlinepubs/9699919799/idx/functions.html)?

Thanks,

Mark



RE: return code?

2018-08-09 Thread Mark Devine
Todd,

I cleaned up my code and published it (with the help of Patrick Spek -- thanks 
again).

CPAN:   https://modules.perl6.org/dist/Async::Command:cpan:MLDEVINE

I’ve been using it in an enterprise environment with 1000+ UNIX/Linux servers.  
I’m able to launch hundreds of SSH commands at once and sort out each 
Proc::Async’s $*OUT and $*ERR without line noise.  For version 0.0.2 I 
hardcoded a throttle of 16 threads after graphing performance on a 4 x Linux VM 
– seems safe yet efficient.

Criticisms & suggestions always welcome by Perl6 mentors.

Thanks,

Mark


From: Mark Devine 
Sent: Saturday, July 28, 2018 16:38
To: ToddAndMargo 
Cc: perl6-users 
Subject: RE: return code?

Todd,

I see that you’re frequently running commands in your code like me.  I was 
looking for a reliable reusable approach for commands for a long time.  I’m 
still learning & not quite ready to step up to contribute to the ecosystem yet 
(https://docs.perl6.org/language/modules.html).  After reading Perl 6 
Fundamentals (Moritz Lenz), I cobbled together a reusable Command.pm6 for 
myself based on his examples.  Method ‘run’ for a single async command, or 
methods ‘sow’+‘reap’ for multiple async (possibly all different) commands, with 
all returns collected in Command::Result objects.

https://github.com/markldevine/perl6-Command

Now whenever I need any general-purpose external command, I ‘use Command;’ and 
it has never failed me (I.e. curl, , ssh, etc.).

Because it’s not in the ecosystem, git clone it into a directory and set 
PERL6LIB= or ‘use lib ’ internally.  Docs are internal POD.

If any of the Perl 6 big brains are reading this and would provide some welcome 
criticism resulting in something that should be published, I would upload as 
per the instructions it or hand it off to someone more capable of maintaining 
it.

If you give it a try, I think that you might find it helpful.

Thanks,

Mark

From: Brandon Allbery mailto:allber...@gmail.com>>
Sent: Saturday, July 28, 2018 16:22
To: ToddAndMargo mailto:toddandma...@zoho.com>>
Cc: perl6-users mailto:perl6-users@perl.org>>
Subject: Re: return code?

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 
mailto:toddandma...@zoho.com>> 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<mailto:allber...@gmail.com> 
 ballb...@sinenomine.net<mailto:ballb...@sinenomine.net>
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


RE: return code?

2018-07-28 Thread Mark Devine
Todd,

I see that you’re frequently running commands in your code like me.  I was 
looking for a reliable reusable approach for commands for a long time.  I’m 
still learning & not quite ready to step up to contribute to the ecosystem yet 
(https://docs.perl6.org/language/modules.html).  After reading Perl 6 
Fundamentals (Moritz Lenz), I cobbled together a reusable Command.pm6 for 
myself based on his examples.  Method ‘run’ for a single async command, or 
methods ‘sow’+‘reap’ for multiple async (possibly all different) commands, with 
all returns collected in Command::Result objects.

https://github.com/markldevine/perl6-Command

Now whenever I need any general-purpose external command, I ‘use Command;’ and 
it has never failed me (I.e. curl, , ssh, etc.).

Because it’s not in the ecosystem, git clone it into a directory and set 
PERL6LIB= or ‘use lib ’ internally.  Docs are internal POD.
If any of the Perl 6 big brains are reading this and would provide some welcome 
criticism resulting in something that should be published, I would upload as 
per the instructions it or hand it off to someone more capable of maintaining 
it.

If you give it a try, I think that you might find it helpful.

Thanks,

Mark

From: Brandon Allbery 
Sent: Saturday, July 28, 2018 16:22
To: ToddAndMargo 
Cc: perl6-users 
Subject: Re: return code?

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 
mailto:toddandma...@zoho.com>> 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


Perl 6: Protecting Intellectual Property for Commercial Code

2017-10-22 Thread Mark Devine
Perl 6 Users,

[[ Bouncing off Re: who own my code? ]]

This is the first of several possible spin-off questions, but here goes…

Perl 6 has its public ecosystem, which will drive growth and adoption.  Then 
there’s the commercial side, which would also drive the language from another 
important angle.  I believe in a balance of public sharing and private 
enterprise.

I am interested in packaging some of my long-term Perl 6 
projects/scripts/apps/frameworks into some kind of relocatable object form 
(binary) that cannot be easily altered or trivially reverse engineered.  Put 
another way, I sometimes would prefer not to sell source code to my customers, 
but rather some form of compiled package that can’t easily be diddled by a 
SysAdmin.  If I create code for a particular commercial domain over years, then 
I want to get compensated for it and not have it be diluted with copy-cats one 
week after I release it.  Certainly some of the generic libraries that I create 
in the future can be modularized for the Perl 6 ecosystem and I’ll push those 
eventually, but the really specialized domain-specific code that fills a 
commercial void & that I will commit years to maintaining, I’d like to offer a 
commercial license, key-protect, sell subscriptions, etc.

Again, I’m very interested in contributing to the ecosystem when possible.  I 
still need to grow past baby/teenager Perl 6, and I’ll get there soon.  But 
after creating something targeted only for customer purchase/subscription, what 
tools are available in the Perl 6 toolbox?  I saw something for the Java 
back-end (to .jar), but not much else.

Is there a Perl 6 roadmap that might mention compiling Perl 6 modules/scripts 
into something atomic, binary, & relocatable?  Or preferably the capability to 
compile only specific Perl 6 modules, requiring an existing Perl 6 on the 
target host?

Thanks,

Mark

From: Brandon Allbery [mailto:allber...@gmail.com]
Sent: Sunday, October 22, 2017 16:33
To: vijayvithal jahagirdar 
Cc: ToddAndMargo ; perl6-users 
Subject: Re: who own my code?

This is still best discussed elsewhere... isn't there a stackexchange for this 
kind of stuff?

On Sun, Oct 22, 2017 at 4:24 PM, vijayvithal jahagirdar 
> wrote:
Now If I implement this for one customer does the code becomes his IP and I 
cannot implement it for another?

Default is owned by who you are working for. If you want something else, you 
can negotiate it; you want to be clear about it, and for something relatively 
low level like this it should not be a problem in practice. That said, the part 
that requires this is also likely the least portable part: unless they're all 
using the same framework, it's the glue to their site framework that is (a) 
more difficult (b) more likely to be different between sites.

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


RE: Perl 6 Object Construction - General Advice

2017-10-05 Thread Mark Devine
Timo,

Oops.  You're right.  (I was unconditionally sending an argument in my test 
that zeroed it out the attribute that I was watching -- doh!)  Now I can 
confirm that TWEAK is the logical place to further initialize attributes.

I now see the light!

Thanks,

Mark


-Original Message-
From: Timo Paulssen [mailto:t...@wakelift.de] 
Sent: Thursday, October 5, 2017 13:56
To: Mark Devine <m...@markdevine.com>; perl6-users@perl.org
Subject: Re: Perl 6 Object Construction - General Advice

The main difference between BUILD and TWEAK is that BUILD will replace all 
default and requiredness handling, while TWEAK keeps it intact.
TWEAK gets run after these aspects had their turn, so if you have an "is 
required" attribute that doesn't get a value passed, the BUILDALL process will 
throw the corresponding exception before TWEAK even gets invoked.

Don't forget that with the assignment syntax for attribute defaults you're 
allowed to do calculations, too! You can even refer to other attributes in 
there, as long as you use the $!foo syntax.

hope that helps
  - Timo



Perl 6 Object Construction - General Advice

2017-09-30 Thread Mark Devine
Perl 6,

I am preparing to write several classes for some Perl 6 apps I intend to craft 
in support of a prominent backup suite.  In looking at the documentation & some 
of the modules published in the Perl 6 ecosystem, I’m not quite sure that I can 
identify the best idiomatic object construction (OC) approach for my most 
frequent cases that will stand the test of time.  I don’t want to start writing 
too many of these using my baby/teenager-Perl6 skills and then go back and 
refactor ALL of them later with better OC approaches as I learn more.  I’d like 
to have a boilerplate OC construct that accommodates most cases, if it is 
possible to zero in on one.

My most common OC case:  initialize attributes at OC time from external input 
that will be parsed with grammars &/| scrubbed with elaborate conditional tests.

Mu’s new() cannot assign to the class attributes, but BUILD can.  I’ve used 
that construct successfully, but I’m not convinced that will be the best 
approach for the long term.


OC: new() { self.bless() } – BUILD() still confuses me.  (I am hopeful for a 
future Perl 6 book with a 40-page chapter comprehensively detailing the 
responsibilities of each of these mechanisms.)  I’ve read 
https://docs.perl6.org/language/classtut & 
https://docs.perl6.org/language/objects#Object_Construction, but I’m not 
getting it all.

I’ve tried multiple approaches to initializing variables with defaults, 
sometimes failing at compile time when I attempt to do it in the wrong place.  
Other times, as I move things around, I break default assignments (I.e. has 
$.var = ‘/tmp’) that worked magically using Mu’s new().  I am still learning by 
experimentation…

The Perl 6 ecosystem has lots of clever OC constructs, but I’m still not able 
to infer which I could boilerplate into an “80%-of-the-time-go-to” OC.

I just recently encountered this construct in more than one module (I.e. 
https://github.com/sergot/io-socket-ssl/blob/master/lib/IO/Socket/SSL.pm6):



method new(*%args is copy) {

…# fiddle with the %args hash as required, but obviously not 
attributes here

self.bless(|%args)!initialize;

}



method !initialize {

…# directly initialize attributes with conditional logic

self;

}



Is this construct a bona-fide industrial-strength Perl 6 OC idiom that I could 
employ with confidence?  Should I keep looking?Also, in this OC approach, 
I’m not quite seeing how |%args (I.e. with %args = ‘example.com’) ends up 
magically as $!host (I.e. =’example.com’) in initialize().  I’ll need just a 
bit more explanation to understand it.



If anyone can provide more detail on the 
mechanics/expectations/responsibilities/idioms of Perl 6 OC (new() { 
self.bless() } – BUILD() & more), I would appreciate your input.  All educated 
advice is welcome.

Thanks,

Mark


RE: String to array problem

2017-07-16 Thread Mark Devine
T,

Disclaimer: P6 newbie/P5 intermediate -YMMV

Regex that looks (1) quoted strings (2) any non-space-chars:
/ [ '"' <-[ " ]> * '"' | \S+ ]

Smartmatch globally when comparing with $x
  $x ~~ m:global  

Since regex matches return Match object, they need their match string coerced 
out with '~'.
~(  );

Mark

-Original Message-
From: ToddAndMargo [mailto:toddandma...@zoho.com] 
Sent: Sunday, July 16, 2017 8:26 PM
To: perl6-users <perl6-users@perl.org>
Subject: Re: String to array problem


> -Original Message-
> From: ToddAndMargo [mailto:toddandma...@zoho.com]
> Sent: Sunday, July 16, 2017 7:41 PM
> To: perl6-users <perl6-users@perl.org>
> Subject: String to array problem
> 
> Hi All,
> 
> I have been scratching my head trying to figure out how to turn a string with 
> quotes in it into an array.
> 
> my $x='ls -al "Program Files" "Moe Curly Larry"';
> 
> Desired result:
> my @y;
>  $y[0] = 'ls';
>  $y[1] = '-la';
>  $y[2] = 'Program Files';
>  $y[3] = 'Moe Curly Larry';
> 
> Any words of wisdom?
> 
> Many thanks,
> -T
> 


On 07/16/2017 05:16 PM, Mark Devine wrote:
 > T,
 >
 > my $x = 'ls -al "Program Files" "Moe Curly Larry"';  > ~($x ~~ m:global/ [ 
 > '"' <-[ " ]> * '"' | \S+ ] /);  >  > Mark Devine  >

Thank you!

May I impose on you to take apart the example and explain what each part is 
doing?



--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


RE: String to array problem

2017-07-16 Thread Mark Devine
T,

This regex seems to work in both cases: m:global/ [ \\? '"' <-[ " ]> * \\? '"' 
| \S+ ] /;

#!/usr/bin/env perl6
use v6;

my ($x, @y);

$x = 'ls -al "Program Files" "Moe Curly Larry"';
@y = $x ~~ m:global/ [ \\? '"' <-[ " ]> * \\? '"' | \S+ ] /;
for @y -> $match { say ~$match; }

$x = 'ls -al \"Program Files\" \"Moe Curly Larry\"';
@y = $x ~~ m:global/ [ \\? '"' <-[ " ]> * \\? '"' | \S+ ] /;
for @y -> $match { say ~$match; }

Mark

-Original Message-
From: ToddAndMargo [mailto:toddandma...@zoho.com] 
Sent: Sunday, July 16, 2017 8:35 PM
To: perl6-users <perl6-users@perl.org>
Subject: Re: String to array problem

On 07/16/2017 05:16 PM, Mark Devine wrote:
> T,
> 
> my $x = 'ls -al "Program Files" "Moe Curly Larry"'; my @y = ~($x ~~ 
> m:global/ [ '"' <-[ " ]> * '"' | \S+ ] /);
> 
> Mark Devine
> 
> -Original Message-
> From: ToddAndMargo [mailto:toddandma...@zoho.com]
> Sent: Sunday, July 16, 2017 7:41 PM
> To: perl6-users <perl6-users@perl.org>
> Subject: String to array problem
> 
> Hi All,
> 
> I have been scratching my head trying to figure out how to turn a string with 
> quotes in it into an array.
> 
> my $x='ls -al "Program Files" "Moe Curly Larry"';
> 
> Desired result:
> my @y;
>  $y[0] = 'ls';
>  $y[1] = '-la';
>  $y[2] = 'Program Files';
>  $y[3] = 'Moe Curly Larry';
> 
> Any words of wisdom?
> 
> Many thanks,
> -T
> 


It kinda, sorta doesn't work:


$ cat ./QuoteArrayTest.pl6
#! /usr/bin/env perl6

use strict;

print "\n";
my $x = 'ls -al \"Program Files\" \"Moe Curly Larry\"'; my @y =~($x ~~ 
m:global/ [ '"' <-[ " ]> * '"' | \S+ ] /); say "$x\n\@y:";

for @y.kv -> $index, $value { say "\$y[$index] = <$value>"; } print "\n"; 


ls -al \"Program Files\" \"Moe Curly Larry\"
@y:
$y[0] = 


What did I do wrong?


--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


RE: String to array problem

2017-07-16 Thread Mark Devine
T,

my $x = 'ls -al "Program Files" "Moe Curly Larry"';
my @y = ~($x ~~ m:global/ [ '"' <-[ " ]> * '"' | \S+ ] /);

Mark Devine

-Original Message-
From: ToddAndMargo [mailto:toddandma...@zoho.com] 
Sent: Sunday, July 16, 2017 7:41 PM
To: perl6-users <perl6-users@perl.org>
Subject: String to array problem

Hi All,

I have been scratching my head trying to figure out how to turn a string with 
quotes in it into an array.

my $x='ls -al "Program Files" "Moe Curly Larry"';

Desired result:
my @y;
$y[0] = 'ls';
$y[1] = '-la';
$y[2] = 'Program Files';
$y[3] = 'Moe Curly Larry';

Any words of wisdom?

Many thanks,
-T