r26976 - docs/Perl6/Spec

2009-05-31 Thread pugs-commits
Author: lwall
Date: 2009-05-31 08:09:18 +0200 (Sun, 31 May 2009)
New Revision: 26976

Modified:
   docs/Perl6/Spec/S11-modules.pod
Log:
[S11] introduce declarators need and defines, components of use


Modified: docs/Perl6/Spec/S11-modules.pod
===
--- docs/Perl6/Spec/S11-modules.pod 2009-05-31 05:17:56 UTC (rev 26975)
+++ docs/Perl6/Spec/S11-modules.pod 2009-05-31 06:09:18 UTC (rev 26976)
@@ -12,8 +12,8 @@
 
   Maintainer: Larry Wall la...@wall.org
   Date: 27 Oct 2004
-  Last Modified: 26 Mar 2009
-  Version: 27
+  Last Modified: 30 Mar 2009
+  Version: 28
 
 =head1 Overview
 
@@ -154,6 +154,52 @@
 tags as arguments to Cis export.  (Of course, mixing incompatible scoping
 in different scopes is likely to lead to confusion.)
 
+The Cuse declaration is actually a composite of two other declarations,
+Cneed and Cdefines.  Saying
+
+use Sense common @horse;
+
+breaks down into:
+
+need Sense;
+Sense defines common @horse;
+
+=head2 Loading without importing
+Xneed
+
+The Cneed declarator takes a list of modules and loads them (at
+compile time) without importing any symbols.  It's good for loading
+class modules that have nothing to export (or nothing that you want
+to import):
+
+need ACME::Rocket;
+my $r = ACME::ROCKET.new;
+
+This declaration is equivalent to Perl 5's:
+
+use ACME::Rocket ();
+
+=head2 Importing without loading
+Xdefines
+
+The importation into your lexical scope may also be a separate declaration
+from loading.  This is primarily useful for modules declared inline, which
+do not automatically get imported into their surrounding scope:
+
+my module Factorial {
+multi fact (Int $n) is export { [*] 1..$n }
+}
+...
+Factorial defines 'fact';   # imports the multi
+
+Despite having the form of an infix operator, this form functions as
+a compile-time declarator, so that these notations can be combined:
+
+role Silly {
+enum Ness is export Dilly String Putty;
+} defines Ness;
+
+
 =head1 Runtime Importation
 
 Importing via Crequire also installs names into the current lexical scope by
@@ -188,16 +234,13 @@
 You may also import symbols from the various pseudo-packages listed in S02.
 They behave as if all their symbols are in the C:ALL export list:
 
-use CONTEXT $IN $OUT $ERR;
-require CALLER $x $y;
+CONTEXT defines $IN $OUT $ERR;
+CALLER defines $x $y;
 
 # Same as:
 # my ($IN, $OUT, $ERR) ::= ($*IN, $*OUT, $*ERR)
 # my ($x, $y) := ($CALLER::x, $CALLER::y)
 
-As pseudo-packages are always already preloaded, Cuse and Crequire will
-never attempt to load, for example, CCALLER.pm from an external source.
-
 =head1 Versioning
 
 When at the top of a file you say something like



Re: r26976 - docs/Perl6/Spec

2009-05-31 Thread John M. Dlugosz



 =head1 Runtime Importation
 
 Importing via Crequire also installs names into the current lexical scope by

@@ -188,16 +234,13 @@
 You may also import symbols from the various pseudo-packages listed in S02.
 They behave as if all their symbols are in the C:ALL export list:
 
-use CONTEXT $IN $OUT $ERR;

-require CALLER $x $y;
+CONTEXT defines $IN $OUT $ERR;
+CALLER defines $x $y;
 
  




Strange... you changed the examples to not be called require, but left 
the intro as Importing via require... ?


--John



Re: The game of life

2009-05-31 Thread John M. Dlugosz

yary not.com-at-gmail.com |Perl 6| wrote:

That was a big part of it... I'm glad Mark posted the APL snippet
because it got me to finally read up on the language that's been at
the back of my mind. Plus it's useful for p6 language discussion. APL
(and a successor, J) may still have a few tricks to lend.
  


Have you come across my Meditations on Perl taken from concepts in APL 
http://www.dlugosz.com/Perl6/web/APL.html?  
http://www.dlugosz.com/Perl6/web/APL.html


Thinking about who needs loops? was inspirational to me.

And it inspired the need for a column-reduce meta syntax.  It would be 
difficult to make macros for each op that don't step on each other, so 
an extensible way really needs to be inspired.




Re: The game of life

2009-05-31 Thread John M. Dlugosz

yary not.com-at-gmail.com |Perl 6| wrote:


Though I'm not quite sure that S03 covers some of the different-dimension cases.
my @table=
 (1,2,3;
  4,5,6); # is this the syntax to create 2d array?
  
No, the Capture on the right, although a Capture of Captures, will be 
flattened in the list context provided by list assignment.


   my @table= [1,2,3],[4,5,6];

will give you a Perl5-like array containing arrays for elements.

To give a true multi-dimensional array, you must declare it.  Although 
the lengths don't have to be fixed, you at least need the number of 
dimensions (which could involve ** so the dimensionality could be variable).


   my @table[2;3];

I pondered over feeding it another list of items in my APL essay.  I 
figured an iterator over the 2-D array should visit the elements in 
order.  So, use that to reshape the simple list.


--John




Module Library - aka CPAN

2009-05-31 Thread Richard Hainsworth
Before joining in the previous CPAN threads, here are some personal wish 
lists regarding what the perl6 version of CPAN should do. But in order 
to get some distance from CPAN, I want to call it the Module Library 
system. Some of the debate threads impact on the internal software 
environment, and here I think the internal and external environments 
must be designed in harmony.


A library paradigm is different from an archive paradigm, although a 
library is a form of archive. However, a library is a single place to go 
to obtain information. It is set up to enhance searching and finding. An 
archive is a place where things are stored; the users of an archive know 
what and where they are storing. Hence the difference between an archive 
and a library is a set of assumptions about what a user knows. Archives 
are essential for large libraries (often called stacks), but there must 
be standardised metadata about what is in each archive for it to be 
useful for a library.


So my wish list. I would like:

1) a single place to go for modules that will help me solve programming 
problems;
2) a variety of ways to look through modules and the information on them 
- reviews, documentation, dependencies - so that I can choose between 
them and know what a choice entails;
3) a variety of classifications of modules and module contents that can 
lead me to modules which may achieve what I want but are named in a 
manner I did not expect, or contain functionality I could use in another 
context;
4) a means to extract from the library the module(s) I want, (better 
still only the parts of the module) and all their dependencies;

5) the ability to access existing CPAN perl software.

Extending the library paradigm, there are generalist libraries, which 
only contain commonly requested books, and specialist libraries and also 
libraries in other languages. However, good libraries share systems for 
requesting books from other libraries, even if they are not stored 
locally. The difference between libraries then boils down to the 
metadata available to the user, eg., more accessible user catalogs, 
librarians who know about subjects and can point to related books, etc.


The library paradigm breaks down somewhat for software because there is 
an intimate link between my environment and the software I choose. 
Hence, it is important to consider the internal environment (my 
computer) as well as the external environment (the module libraries).


Not only is there the problem of different operating systems (*ix, 
windows*, mac, etc), there is also the possibility of outdated software 
installed, eg., different versions of languages, such as perl 5.8, perl 
5.10.


Within my environment, there are multiple possible locations for 
different aspects of software, eg. binaries, configuration data (which 
can be global to all users and local for a single user), documentation, 
data, results. In a corporate environment, these locations may exist 
across a network. For example, documentation may be on a server, 
binaries and local configuration data on the local computer, results 
posted to a web site, input data taken from a database.


My wish list for the internal environment; I would like:

1) a single system to manage all my software modules;
2) a method to see where different aspects of software are located, and 
to change them;
3) an ability to manage in parallel different dependency hierarchies 
(such as might result from a need to use modules from different 
generations (eg. perl 5.8 and 5.10).
4) a comprehensive method to determine what my local environment is, so 
that I can see whether it matches the environment required by software 
that I want to download, and if not, what I need in addition to be able 
to run the software.


Some commentary on the above:
I use the CPAN archive, CPANPLUS, and synaptic (a GUI frontend to the 
apt tools) for perl since I use Ubuntu/Gnome. In some cases I have to 
load binaries using synaptic because I cant get the sources to compile 
properly from CPAN. I do not have the time or inclination to discover 
why. The result is a mishmash of dependencies. Moreover, I cannot get 
updated software without breaking something. This occurred when the one 
Ubuntu generation was distributed with perl5.8 even though perl5.10 was 
out, and I really wanted to use some of the new software.


The result was that I had both 5.8 and 5.10 modules. Although most 
things worked, perldoc wasnt recognised by some Configure scripts. I am 
not interested now in discovering the reason. I use this simply as an 
example about how multiple distribution channels that make different 
assumptions can lead to problems. But because there is no single method 
for monitoring the perl environment, it is difficult to solve some of 
the problems.


The current setup works extremely well, except when it doesnt. My 
difficulty is finding out how to solve the problems that occur. So I 
think there should be a system that 

Re: Illustration of stuff we've been discussing

2009-05-31 Thread Brandon S. Allbery KF8NH

On May 28, 2009, at 10:27 , John M. Dlugosz wrote:

Daniel Ruoso daniel-at-ruoso.com |Perl 6| wrote:

Em Qui, 2009-05-28 às 00:24 -0500, John M. Dlugosz escreveu:


Please see http://www.dlugosz.com/Perl6/web/info-model-1.html
and talk to me about it.



The illustratino is cool, but it doesn't take into account the
possibility of:

@a[0] := $x;

Where in the synopses does it say anything like that is  
possible?  := is applied to a _name_.



The usual example in the Synopses is with a hash instead of an array,  
but the same principle applies:


 %ax := $y;

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part


Re: Module Library - aka CPAN

2009-05-31 Thread John M. Dlugosz

Richard Hainsworth richard-at-rusrating.ru |Perl 6| wrote:


Once a module has been decided on, you look to see if there is a 
binary that matches your internal environment. If not, you have to 
roll your own from source.




Why not have it generate the binary for you, and safe it for future 
users?  It can cross-compile things if needed, or draw upon a network of 
different kinds of machines that are registered to allow that.  
Something similar is used for testing modules, right?


--John



Re: Module Library - aka CPAN

2009-05-31 Thread Richard Hainsworth
Dont think this is workable. If the local environment is non-standard, 
requiring your own solution, then where would you store the binary? And 
how would you inform future users sufficiently about the local 
environment for them to access the binary.


Besides for most binaries, it is not really a time or space issue to 
create the binary locally.


Mind you, the mindset for a unix person is different to a Windows 
person. There is a form of linux - gentoo - in which everything is 
compiled from scratch. In windows, compilation of modules is extremely rare.


Richard

John M. Dlugosz wrote:

Richard Hainsworth richard-at-rusrating.ru |Perl 6| wrote:


Once a module has been decided on, you look to see if there is a 
binary that matches your internal environment. If not, you have to 
roll your own from source.




Why not have it generate the binary for you, and safe it for future 
users?  It can cross-compile things if needed, or draw upon a network 
of different kinds of machines that are registered to allow that.  
Something similar is used for testing modules, right?


--John



Re: Amazing Perl 6

2009-05-31 Thread Brandon S. Allbery KF8NH

On May 27, 2009, at 13:59 , Daniel Carrera wrote:
Wow... That's a foldl! In a functional language, that would be  
called a fold. It's very popular in Haskell.


I like that Perl 6 seems to be taking steps in the direction of  
functional languages. First lazy lists (0..Inf) and now a fold. :-D



One of the early P6 prototypes was written in Haskell, and there's  
been a lot of notions lifted from it.  (OTOH being an old phart I know  
[OP] @list as op/list :)


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part


Re: Amazing Perl 6

2009-05-31 Thread Brandon S. Allbery KF8NH

On May 27, 2009, at 15:42 , Daniel Carrera wrote:

Mark J. Reed wrote:
Note that of the examples given, only Perl 6 and Common Lisp do two  
things

that help immensely simplify the result:
1. reference the built-in * operator directly, without having to  
wrap it in

a lambda expression;
2. actually name the function !


Yes, very neat. Haskell does that too, but I don't know if you can  
make the function a postfix in Haskell.



Not in H98, but ghc allows it as a degenerate form of section.

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part


Re: Amazing Perl 6

2009-05-31 Thread Brandon S. Allbery KF8NH

On May 27, 2009, at 18:05 , John M. Dlugosz wrote:

And APL calls it |¨ (two little dots high up)



buh?  Metaoperator / (+/LIST).

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part


Re: Amazing Perl 6

2009-05-31 Thread Brandon S. Allbery KF8NH

On May 28, 2009, at 06:43 , Jon Lang wrote:

What I'm wondering is how the list knows to feed two items into '[+]'.
While 'infix:+' must accept exactly two arguments, '[+]' can accept
an arbitrarily long (or short) list of arguments.



I thought that at first too, then remembered a discussion about  
generalizing the meaning of square brackets and how [op] fell out of  
it automatically to take a reference to an operator without using the  
infix:op syntax.


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part


Re: Amazing Perl 6

2009-05-31 Thread Brandon S. Allbery KF8NH

On May 29, 2009, at 15:43 , John M. Dlugosz wrote:

Care to try ☃ ?  That's alt-meta-hyper-doublebucky-cokebottle.



*puzzled as to why OSX Character Map thinks that's related to 雪*

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part


Re: Amazing Perl 6

2009-05-31 Thread Brandon S. Allbery KF8NH

On May 29, 2009, at 21:50 , Timothy S. Nelson wrote:
some Linux programs support it too.  Unfortunately my e-mail program  
(Pine) seems to have some trouble with unicode -- I may have to look  
at alternatives after 14 years of use :(.



http://www.washington.edu/alpine/

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part


Re: Amazing Perl 6

2009-05-31 Thread Brandon S. Allbery KF8NH

On May 29, 2009, at 22:40 , Timothy S. Nelson wrote:

On Fri, 29 May 2009, John M. Dlugosz wrote:
Ah yes, on the PC historically you hold down the ALT key and type  
the code with the numpad keys.


	At least when I used it, this was a decimal, rather than hex  
number, and had to be preceded by a 0 (zero).



I see ALT+ a lot in Windows stuff, and have used it a few times  
(that is, while holding Alt type + and 4 hex digits).


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part


Re: renaming or adding some operators

2009-05-31 Thread Brandon S. Allbery KF8NH

On May 29, 2009, at 22:33 , Jon Lang wrote:

also is an ordered, short-circuiting version of  (and thus
all).  For some time now, I've wanted an analog for '|' and 'any' -
but the only name I can think of for it would be 'else', which has
some obvious clarity issues.


I have seen x (alt. y) used in print, so maybe alt?

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part


Re: renaming or adding some operators

2009-05-31 Thread Brandon S. Allbery KF8NH

On May 30, 2009, at 15:38 , Larry Wall wrote:

Perhaps something like

   use *;

should pull in all the Unicode operators.  Which if course means that
any golfing would start with

   *;



⨷ perhaps?  It only makes sense that a Unicode operator be used to  
pull in all of Unicode.


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part


Re: renaming or adding some operators

2009-05-31 Thread John M. Dlugosz

Brandon S. Allbery KF8NH allbery-at-ece.cmu.edu |Perl 6| wrote:


⨷ perhaps?  It only makes sense that a Unicode operator be used to 
pull in all of Unicode.



Bravo.
If you can't type that, you won't find it useful!


Re: The game of life

2009-05-31 Thread Daniel Ruoso
Em Qui, 2009-05-28 às 00:26 -0500, John M. Dlugosz escreveu:
 Mark J. Reed markjreed-at-gmail.com |Perl 6| wrote:
  Perhaps Perl 6 should not aspire to the expressiveness of APL. :)  As
  nice as it is that you can write Conway's Life in a one-liner(*), I
  think that a little verbosity now and then is a good thing for
  legibility
  (*) life ←{↑1 ω⌵.^3 4=+/,‾1 0 1◦.ϕ⊂ω}
 So how would that translate to Perl 6?  Both as an exact translation, 
 and how to do it better in a Perl way?

I didn't try to translate it, but rather I simply tried to implement it
in a way rakudo already runs So... here's my shot!

CODE
class Game {
  # XXX: rakudo doesn't know how to initialize arrays properly yet.
  has $.seed;
  has $.width;
  has $.height;
  multi method generation(Int $generation where 0) {
return @($.seed);
  }
  multi method generation(Int $generation) {
my @previous = self.generation($generation - 1);
my @new;
# XXX: rakudo doesn't autovivify arrays properly yet.
@new.push: [] for ^$.width;
for ^$.width X ^$.height - $x, $y {
  # XXX: there's an extra set of parens for rakudo
  my $value = [+] map { @previous[$^i][$^j] },
 ((grep { 0 = $_  $.width }, ($x-1)..($x+1))
  X
  (grep { 0 = $_  $.height }, ($y-1)..($y+1)));

  if @previous[$x][$y]  2 = ($value - 1) = 3 {
@new[$x][$y] = 1;
  } elsif !...@previous[$x][$y]  $value == 3 {
@new[$x][$y] = 1;
  } else {
@new[$x][$y] = 0;
  }
}
return @new;
  }
}

my $game = Game.new(
 :width(15), :height(15),
 :seed([
  [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
  [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
  [ 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
  [ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
  [ 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
  [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
  [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
  [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
  [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
  [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
  [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
  [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ],
  [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 ],
  [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ],
  [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
 ]));

my @g = $game.generation(4);
say .perl for @g;
/CODE


I guess my mindset is too much imperative for me to think in a more
elegant solution...

daniel