[svn:perl6-synopsis] r14362 - doc/trunk/design/syn

2007-03-29 Thread larry
Author: larry
Date: Thu Mar 29 00:55:18 2007
New Revision: 14362

Modified:
   doc/trunk/design/syn/S09.pod

Log:
typo spotted by Ruud++


Modified: doc/trunk/design/syn/S09.pod
==
--- doc/trunk/design/syn/S09.pod(original)
+++ doc/trunk/design/syn/S09.podThu Mar 29 00:55:18 2007
@@ -194,7 +194,7 @@
 my @values.[10];  # Error
 my @keys\ .[10];  # Error
 
-Attempting to access an index outside a array's defined range will fail:
+Attempting to access an index outside an array's defined range will fail:
 
 @dwarves[7] = 'Sneaky';   # Fails with invalid index exception
 


anonymous multidim values (was Re: [svn:perl6-synopsis] r14359 - doc/trunk/design/syn)

2007-03-29 Thread Darren Duncan

At 7:28 PM -0700 3/28/07, [EMAIL PROTECTED] wrote:

 =head1 Multidimensional arrays

+Perl 6 arrays are not restricted to being one-dimensional (that's simply
+the default). To declare a multidimensional array, you specify it with a
+semicolon-separated list of dimension lengths:
+
+my int @ints[4;2];  # Valid indices are 0..3 ; 0..1
+
+my @calendar[12;31;24]; # Valid indices are 0..11 ; 0..30 ; 0..23
+
+You can pass a multislice for the shape as well:
+
+@@shape = (4;2);
+my int @ints[ [;[EMAIL PROTECTED] ];
+my int @ints[@@shape];  # Same thing

snip

This is great and all, but ...

How would one declare an anonymous multidimensional array value that 
is compatible with this system?


Eg, with normal arrays, one can say [foo,bar,baz] to declare a normal 
anonymous array value with those 3 elements.


But say for example that one wants to do a matrix multiply of literal 
values, and so each operand is a 2x3 array, and so is the result ... 
could we do something like this:


  my $result = [4,5;6,7;8,9] * [7,0;44,4;5,3];

Or that's probably bad syntax or example, but you get the idea; one 
defined an entire multi-dim-array value inline and not with a bunch 
of element assignments.


I didn't see this matter addressed in Synopsis 9.

Or do you consider this unlikely, and that people who use 
multidimensional arrays or hashes would be more likely to build their 
values piecemeal, or use arrays of arrays, which afaik are not the 
same thing?


-- Darren Duncan


Re: [svn:perl6-synopsis] r14359 - doc/trunk/design/syn

2007-03-29 Thread TSa

HaloO,

[EMAIL PROTECTED] wrote:

+Similarly, within a C.{} indexing operation you can use C*[$idx]
+to convert from standard indices to user-defined:
+
+@lengths{ *[2] .. Oct }  # Same as:  @lengths{ Jan .. Oct }


Isn't that same as @length{Mar..Oct}?
--


[svn:perl6-synopsis] r14363 - doc/trunk/design/syn

2007-03-29 Thread larry
Author: larry
Date: Thu Mar 29 07:11:09 2007
New Revision: 14363

Modified:
   doc/trunk/design/syn/S09.pod

Log:
missing blank line supplied by dduncan++


Modified: doc/trunk/design/syn/S09.pod
==
--- doc/trunk/design/syn/S09.pod(original)
+++ doc/trunk/design/syn/S09.podThu Mar 29 07:11:09 2007
@@ -861,6 +861,7 @@
 0 .. Inf :by(2)
 
 That's why we have C..* to mean C..Inf.
+
 =head1 PDL signatures
 
 To rewrite a Perl 5 PDL definition like this:


Re: [svn:perl6-synopsis] r14362 - doc/trunk/design/syn

2007-03-29 Thread Dr.Ruud
[EMAIL PROTECTED] schreef:

 -Attempting to access an index outside a array's defined range will
 fail:
 +Attempting to access an index outside an array's defined range
 will fail: 

Idea for Perl6 test code: detecting (simple) typos in documentation. 

-- 
Affijn, Ruud

Gewoon is een tijger.


[svn:perl6-synopsis] r14364 - doc/trunk/design/syn

2007-03-29 Thread larry
Author: larry
Date: Thu Mar 29 12:06:16 2007
New Revision: 14364

Modified:
   doc/trunk/design/syn/S09.pod

Log:
error spotted by TSa++


Modified: doc/trunk/design/syn/S09.pod
==
--- doc/trunk/design/syn/S09.pod(original)
+++ doc/trunk/design/syn/S09.podThu Mar 29 12:06:16 2007
@@ -682,7 +682,7 @@
 Similarly, within a C.{} indexing operation you can use C*[$idx]
 to convert from standard indices to user-defined:
 
-@lengths{ *[2] .. Oct }  # Same as:  @lengths{ Jan .. Oct }
+@lengths{ *[2] .. Oct }  # Same as:  @lengths{ Mar .. Oct }
 
 In other words, when treated as an array within an indexing
 operation, C* allows you to convert between standard and


[svn:perl6-synopsis] r14365 - doc/trunk/design/syn

2007-03-29 Thread larry
Author: larry
Date: Thu Mar 29 12:32:03 2007
New Revision: 14365

Modified:
   doc/trunk/design/syn/S04.pod

Log:
missing words spotted by shamu++


Modified: doc/trunk/design/syn/S04.pod
==
--- doc/trunk/design/syn/S04.pod(original)
+++ doc/trunk/design/syn/S04.podThu Mar 29 12:32:03 2007
@@ -854,8 +854,8 @@
NEXT {...}   at loop continuation time, before any LEAVE
LAST {...}   at loop termination time, after any LEAVE
 
-PRE {...}   assert precondition at every block entry, before any
-   POST {...}   assert postcondition at every block exit, after any
+PRE {...}   assert precondition at every block entry, before ENTER
+   POST {...}   assert postcondition at every block exit, after LEAVE
 
   CATCH {...}   catch exceptions, before LEAVE
 CONTROL {...}   catch control exceptions, before LEAVE


[svn:perl6-synopsis] r14366 - doc/trunk/design/syn

2007-03-29 Thread larry
Author: larry
Date: Thu Mar 29 16:14:45 2007
New Revision: 14366

Modified:
   doc/trunk/design/syn/S09.pod

Log:
clarifications suggested by thom++


Modified: doc/trunk/design/syn/S09.pod
==
--- doc/trunk/design/syn/S09.pod(original)
+++ doc/trunk/design/syn/S09.podThu Mar 29 16:14:45 2007
@@ -387,12 +387,12 @@
 final dimension to make a ragged array functionally equivalent to an
 array of arrays:
 
-my int @ints[42; *];# Second dimension unlimited
+my int @ints[42; *];# Second dimension unlimited/ragged
 push(@ints[41], getsomeints());
 
 but Iany dimensional of an array may be declared as autoextending:
 
-my @calendar[12;*;24];  # Month dimension unlimited
+my @calendar[12;*;24];  # day-of-month dimension unlimited/ragged
 @calendar[1;42;8] = 'meeting'   # See you on January 42nd
 
 It is also possible to specify that an array has an arbitrary number


Re: anonymous multidim values (was Re: [svn:perl6-synopsis] r14359 - doc/trunk/design/syn)

2007-03-29 Thread Larry Wall
On Thu, Mar 29, 2007 at 01:21:27AM -0700, Darren Duncan wrote:
: At 7:28 PM -0700 3/28/07, [EMAIL PROTECTED] wrote:
:  =head1 Multidimensional arrays
: 
: +Perl 6 arrays are not restricted to being one-dimensional (that's simply
: +the default). To declare a multidimensional array, you specify it with a
: +semicolon-separated list of dimension lengths:
: +
: +my int @ints[4;2];  # Valid indices are 0..3 ; 0..1
: +
: +my @calendar[12;31;24]; # Valid indices are 0..11 ; 0..30 ; 0..23
: +
: +You can pass a multislice for the shape as well:
: +
: +@@shape = (4;2);
: +my int @ints[ [;[EMAIL PROTECTED] ];
: +my int @ints[@@shape];  # Same thing
: snip
: 
: This is great and all, but ...
: 
: How would one declare an anonymous multidimensional array value that 
: is compatible with this system?

Depends on what you mean by compatible.  The semicolon notation is
really just intended for slicing subscripts, which are really just
two dimensional, so it's convenient to represent one of the dimensions
with semicolon rather than nested lists of some sort.

: Eg, with normal arrays, one can say [foo,bar,baz] to declare a normal 
: anonymous array value with those 3 elements.
: 
: But say for example that one wants to do a matrix multiply of literal 
: values, and so each operand is a 2x3 array, and so is the result ... 
: could we do something like this:
: 
:   my $result = [4,5;6,7;8,9] * [7,0;44,4;5,3];

Well, you want a hyperop there, but we might make that syntax work for
two dimensional arrays.  Semicolons don't conveniently extend to more
dimensions though without explicit bracketing.  But at any given level
we could replace [...],[...],[...] with ...;...;... as long as it's
unambiguous in context.

: Or that's probably bad syntax or example, but you get the idea; one 
: defined an entire multi-dim-array value inline and not with a bunch 
: of element assignments.
: 
: I didn't see this matter addressed in Synopsis 9.

It could probably use some clarification.

: Or do you consider this unlikely, and that people who use 
: multidimensional arrays or hashes would be more likely to build their 
: values piecemeal, or use arrays of arrays, which afaik are not the 
: same thing?

There are various ways to write multidimensional data; basically any
composite object potentially represents an item at object level but
a list of objects if asked to iterate somehow.  We've done a certain
amount of handwaving on multidimensional values, but my feeling is that
in a multidimensional context anything that can do Array or List can
be used as a sublist within a large list, much like we freely interconvert
strings and numbers where that makes sense.  So maybe it just doesn't
matter whether you write:

my $result = [[4,5],[6,7],[8,9]] »*« [[7,0],[44,4],[5,3]];
my $result = ((4,5),(6,7),(8,9)) »*« ((7,0),(44,4),(5,3));
my $result = (Seq(4,5),\(6,7),[8,9]) »*« (\(7,0),[44,4],Seq(5,3));
my $result = (4,5;6,7;8,9) »*« (7,0;44,4;5,3);

since potentially any flattening is done lazily, so if flattening
isn't wanted by the context, you don't get it.  But I freely admit
that I'm sorta waiting for the implementors to say what's practical
here, and I'd particularly like to see more participation from the
PDL crowd.  Unfortunately they're a rather practical set of people and
more interested in solving real problems than in painting linguistic
bikesheds.  'Course that's also precisely why I'd like to see more
of their input.  :-)

In any case, most of the syntax above is negotiable.  However,
literals defined with nested square brackets should work fine with
any data structure that they can be mapped to, whether declared as
a shaped array or as arrays of arrays.  The mapper just shoves any
early dimensions into the shape (if any), and the rest dangles off
each element as AoA (assuming the element type isn't forced to be a
simple type like Num there).  Offhand I don't see much problem with
this, but maybe it's just a big blind spot.

Larry


Re: relational language extension (was Re: request new Mapping|Hash operators)

2007-03-29 Thread John Beppu

Good luck w/ your studies.  Viable alternatives to SQL are always welcome.
;-)


On 3/23/07, Darren Duncan [EMAIL PROTECTED] wrote:


At 7:15 PM -0700 3/23/07, John Beppu wrote:
You might find Dee interesting:

http://www.quicksort.co.uk/

This Dee project in Python is a worthy thing to study, and it does
represent a major part of what I believe Perl 6 should elegantly
support, if not bundle.

And while my own efforts with either Set::Relation or QDRDBMS (to
rename) can not actually be used yet (but hopefully soon), Dee has
actually been released, and AFAIK, works right now.

In the short term, looking at that project will help to explain a lot
of what I'm trying to get at more than my own explanations, probably.

-- Darren Duncan