Re: Lvalue Str::words iterator

2005-06-15 Thread Larry Wall
Y'all are getting hung up on the correspondence of "words" with "word
characters", but you're ignoring the fact that most of the time people
want to do awk's version of splitting, matching \S+ words rather than \w+
words (*neither* of which actually matches what people usually mean
by words, in any case).

So I think .match should default to .match(rx:g/\S+/), if it defaults
to anything.  But I still think people would find .words much clearer
when reading someone else's code.  And the :g would be implicit,
so .words(/\w+/) would be still be a shortcut for .match(rx:g/\w+/).

Larry


Re: PATCH: S04 - unary C<=> is not slurpy

2005-06-15 Thread Damian Conway

Autrijus asked:


On Wed, Jun 15, 2005 at 05:37:18PM -0500, Patrick R. Michaud wrote:


Based on an off-list discussion, it turns out that unary C<=>
is not slurpy as mentioned in S04.  The following patch to S04
corrects this; I've already applied the patch but thought I'd
pass it by p6l for review/comments/reactions.



Does it mean that it's a synonym to "&readline"?


No. It's the general-purpose "iterate this..." operator.

Applied to a filehandle, it iterates the filehandle (which *is* equivalent to 
 calling C).


But it can also be applied to any other iterator object, in which case it 
calls that object's C<.next> method.


Damian


Re: PATCH: S04 - unary C<=> is not slurpy

2005-06-15 Thread Autrijus Tang
On Wed, Jun 15, 2005 at 05:37:18PM -0500, Patrick R. Michaud wrote:
> Based on an off-list discussion, it turns out that unary C<=>
> is not slurpy as mentioned in S04.  The following patch to S04
> corrects this; I've already applied the patch but thought I'd
> pass it by p6l for review/comments/reactions.

Does it mean that it's a synonym to "&readline"?

Thanks,
/Autrijus/


pgpGE4T1lI9Ej.pgp
Description: PGP signature


PATCH: S04 - unary C<=> is not slurpy

2005-06-15 Thread Patrick R. Michaud
Based on an off-list discussion, it turns out that unary C<=>
is not slurpy as mentioned in S04.  The following patch to S04
corrects this; I've already applied the patch but thought I'd
pass it by p6l for review/comments/reactions.

Pm

Index: S04.pod
===
--- S04.pod (revision 3802)
+++ S04.pod (working copy)
@@ -12,7 +12,7 @@
 
   Maintainer: Larry Wall <[EMAIL PROTECTED]>
   Date: 19 Aug 2004
-  Last Modified: 29 Jan 2005
+  Last Modified: 15 Jun 2005
   Number: 4
   Version: 5
 
@@ -185,13 +185,10 @@
 This has the added benefit of limiting the scope of the C<$line>
 parameter to the block it's bound to.  (The C's declaration of
 C<$line> continues to be visible past the end of the block.  Remember,
-no implicit block scopes.)  It is possible to write
+no implicit block scopes.)  It is also possible to write
 
 while =$*IN -> $line {...}
 
-But it won't do what you expect, because unary C<=> does a slurp in scalar
-context, so C<$line> will contain the entire file.
-
 Note also that Perl 5's special rule causing
 
 while (<>) {...}


Re: new mailing list: perl6-general?

2005-06-15 Thread David Storrs

On Jun 15, 2005, at 3:33 PM, Patrick R. Michaud wrote:


And here they are...  this is just a draft -- feel free to flame/edit/
tear it apart liberally.  These are also written assuming we don't
create a perl6-general list (but it shouldn't be hard to adapt them
should one be created).


Well, I'd suggest the following.  (Anything not mentioned stays as  
you wrote it.)



perl6-language
This is the "theory of" list. Discussion of the design of the  
perl6

language, and its desired (or unwanted) feature list. If you have
patches and/or suggestions for improving the Perl 6 design  
documents

(Apocalypses, Synopses, etc.), send them here.


perl6-howto
This is the "practice of" list.  Come here to ask "How do I...",  
"What
does XYZ mean?", or "Why doesn't this work?"  Novices are  
especially

welcome.

(Note:  I envision this list being much like beginners@perl.org, but  
I never liked that name because it seems like it would drive away  
those who have a question but do not consider themselves beginners.   
On the other hand, maybe it's more important to explicitly welcome  
novices.  I could go either way:  maybe the above list should be  
'perl6-beginners')




Re: Lvalue Str::words iterator

2005-06-15 Thread Juerd
Ingo Blechschmidt skribis 2005-06-15 21:35 (+0200):
> So maybe we should allow words() (or however we'll end up calling it) to
> take an optional parameter specifying what's considered a wordchar,
> with a default of rx/\w+/:

Then isn't making \w+ the default for match much easier?

(Although I still want m// to correspond to .m and s/// to .s, not m//
to .match and s/// to .subst.)

I think this is so often used that the default isn't even as insane as
it may appear at first sight.

>   say "foo bar baz".words()   .join(":");# same as

say "foo bar baz".match

>   say "foo bar baz".words(rx/\w+/).join(":");# "foo:bar:baz"

say "foo bar baz".match(/\w+/)

rx is optional, as bare // does rx// in Rule context, not m//.


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html


Re: Lvalue Str::words iterator

2005-06-15 Thread Ingo Blechschmidt
Hi,

Juerd wrote:
> Ingo Blechschmidt skribis 2005-06-15 20:18 (+0200):
>> >> say join ",", @words; # "hi,my,name,is,ingo";
>> > Following the logic that .words returns the words, the words are no
>> > longer individual words when joined on comma instead of
>> > whitespace...
>> sorry, I don't quite get that.
> 
> "foo bar baz".words.join(',').words.join(':') ne 'foo:bar:baz';
> 
> so somewhere in that process, foo, bar and baz managed to no longer be
> words by the definition of words used by an on whitespace splitting
> words method - they're one word, together, when they're joined on
> comma.

ah! I understand :)

So maybe we should allow words() (or however we'll end up calling it) to
take an optional parameter specifying what's considered a wordchar,
with a default of rx/\w+/:

  say "foo bar baz".words()   .join(":");# same as
  say "foo bar baz".words(rx/\w+/).join(":");# "foo:bar:baz"

  say "foo,bar,baz".words()   .join(":");# same as
  # "," doesn't match /\w+/
  say "foo,bar,baz".words(rx/\w+/).join(":");# "foo:bar:baz"

  # Now "," is considered to be part of words:
  say "foo,bar,baz".words(rx/[\w|,]+/).join(":");# "foo,bar,baz"

  say "foo bar baz".words(rx/b../).join(":");# "bar:baz"

Then your example...
  say "foo bar baz".words.join(',').words.join(':'); # "foo bar baz";

And:
  say "foo bar baz".words.join(",").words(rx/[\w|,]+/).join(":");
 # "foo,bar,baz"


I hope these examples make sense...

--Ingo

-- 
Linux, the choice of a GNU | Perfection is reached, not when there is no
generation on a dual AMD   | longer anything to add, but when there is
Athlon!| no longer anything to take away.



Re: new mailing list: perl6-general?

2005-06-15 Thread Patrick R. Michaud
On Tue, Jun 14, 2005 at 10:04:34AM -0500, Patrick R. Michaud wrote:
> 
> Perhaps what we need is updated descriptions of the various mailing
> lists on perl.org (http://dev.perl.org/perl6/lists/)?  I'll draft
> some proposed changes to that page.

And here they are...  this is just a draft -- feel free to flame/edit/
tear it apart liberally.  These are also written assuming we don't
create a perl6-general list (but it shouldn't be hard to adapt them
should one be created).

perl6-announce
Moderated list for news of new lists, working groups, and so on. 
Summaries from the top-level working groups are also posted here.

perl6-language
Discussion of the perl6 language, focusing primarily on the
design of the language itself and its desired (or unwanted)
features.  General questions about the Perl 6 language tend
to come here, as well as patches and suggestions for improving
the Perl 6 design documents (Apocalypses, Synopses, etc.).

perl6-internals
Discussion of the design, development, and implementation of
Parrot, the virtual machine underlying Perl 6 and other
interpreted languages.  Messages here focus on implementing
and testing the Parrot virtual machine, patches to the Parrot
implementation, porting Parrot to other target platforms, 
the components and design features needed for Parrot to 
support higher-level languages, and selected high-level language
compilers (e.g. Tcl, Lisp, etc.).

perl6-compiler
Discussion of the development and implementation of Perl 6
compilers and runtime components, including Pugs and the
Parrot Grammar Engine (Perl 6 rules).  Questions, bug
reports, and patches regarding existing Perl 6 compilers and 
runtime components go here.


Pm


Re: Lvalue Str::words iterator

2005-06-15 Thread Juerd
Ingo Blechschmidt skribis 2005-06-15 20:18 (+0200):
> >> say join ",", @words; # "hi,my,name,is,ingo";
> > Following the logic that .words returns the words, the words are no
> > longer individual words when joined on comma instead of whitespace...
> sorry, I don't quite get that.

"foo bar baz".words.join(',').words.join(':') ne 'foo:bar:baz';

so somewhere in that process, foo, bar and baz managed to no longer be
words by the definition of words used by an on whitespace splitting
words method - they're one word, together, when they're joined on comma.

It was a demonstration of why "words" for this feature is a bad name,
not anything against the presentation using commas.


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html


Re: Lvalue Str::words iterator

2005-06-15 Thread Ingo Blechschmidt
Hi,

Juerd wrote:
> Ingo Blechschmidt skribis 2005-06-15 19:14 (+0200):
>> as Larry mentioned in another thread that he wants a "different
>> notation for word splitting"
>> (http://www.nntp.perl.org/group/perl.perl6.language/21874),
>> how about that, similar to Haskell's "words" function:
> 
> "words" is wrong for something that splits.

I took the name from Haskell's words, but I don't mind a name change.

> It'd be right for something that matches. Let me demonstrate: 
> 
>    "(foo bar --baz blah-- quux)".words;
> This should return , not <(foo bar --baz blah--
> quux)>. So the name "words" isn't good for this.

right, it should return , with the additional
lvalue ability, so that the following (contrived) example works:

my $str = "(foo bar --baz blah-- quux)";
$str.words .= map:{ substr $^word, 1 };
say $str;
 # "(oo ar --az lah-- uux)";

>> say join ",", @words; # "hi,my,name,is,ingo";
> 
> Following the logic that .words returns the words, the words are no
> longer individual words when joined on comma instead of whitespace...

sorry, I don't quite get that.

I wanted to show the contents of @words, I did not want to split the
string into words and then concatenate the words again.

   # Maybe this...
   say " hi my  name is ingo ".words.map:{ "($_)" }
 # "(hi) (my) (name) (is) (ingo)"
   # ...is clearer?


--Ingo

-- 
Linux, the choice of a GNU | Black holes result when God divides the
generation on a dual AMD   | universe by zero.  
Athlon!| 



Re: Lvalue Str::words iterator

2005-06-15 Thread Juerd
Ingo Blechschmidt skribis 2005-06-15 19:14 (+0200):
> as Larry mentioned in another thread that he wants a "different
> notation for word splitting"
> (http://www.nntp.perl.org/group/perl.perl6.language/21874),
> how about that, similar to Haskell's "words" function:

"words" is wrong for something that splits. It'd be right for something
that matches. Let me demonstrate:

"(foo bar --baz blah-- quux)".words;

This should return , not <(foo bar --baz blah--
quux)>. So the name "words" isn't good for this.

> say join ",", @words; # "hi,my,name,is,ingo";

Following the logic that .words returns the words, the words are no
longer individual words when joined on comma instead of whitespace...


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html


Lvalue Str::words iterator

2005-06-15 Thread Ingo Blechschmidt
Hi,

as Larry mentioned in another thread that he wants a "different notation
for word
splitting" (http://www.nntp.perl.org/group/perl.perl6.language/21874),
how about that, similar to Haskell's "words" function:

# Str::words should return a list of words, without whitespace.
my $str   = " hi   my name is  ingo  ";
my @words = words $str;
say join ",", @words; # "hi,my,name,is,ingo";


# The list returned should contain lvalueable objects (idea courtesy
# of wolverian):
my $str = " hi   my name is  ingo  ";
$str.words .= map:{ ucfirst };
say $str; # " Hi   My Name Is  Ingo  "
# Note: The whitespace was preserved!


Comments?


--Ingo

-- 
Linux, the choice of a GNU | We are Pentium of Borg. Division is futile.
generation on a dual AMD   | You will be approximated.  
Athlon!| 



Re: new mailing list: perl6-general?

2005-06-15 Thread BÁRTHÁZI András

Hi Michele,

Where should I ask, that what's PGE means? Yes, I know, it's Parrot 
Grammar Engine, and I know what it is, but a beginnner maybe not. And 
I think that


Which makes me think that first or later it may be worth to start a FAQ 
for questions like these even if they're not frequently asked. And 
indeed a perl6-general may be a starting point for writing one.


I agree. Is it possible the setup an SVN repo for the FAQ, that would be 
mirrored the the web page?


Anyway, if the perl.org webmasters not interested in it, or it is a big 
work to setup a mailing list and/or a FAQ like this, I can offer the 
infrastructure for it, and I can setup it in a day.


Bye,
  Andras


Re: proposal: binding with a function

2005-06-15 Thread BÁRTHÁZI András

Hi,

Carl Franks wrote:

:   alias newlines, newline;


Isn't it possible to add a Role to the relevant Class, which specifies
that is 'handles' the method name you want as an alias?


If it's possible, it would be fine for me in this particular case. Is it 
possible?


Anyway, IMHO this alias function can be useful in other cases, too.

Bye,
  Andras


Re: State of Design Documents

2005-06-15 Thread Christian Renz

Not really, except insofar as we've talked about compact classes of
native types working like C structs.  There are lots of nitty things
we can fix with pack/unpack, but the basic underlying problem is
that pack/unpack are defined operationally rather than declaratively.


I think it's worth taking a look at Marcus Holland-Moritz'
powerful Convert::Binary::C ( http://search.cpan.org/dist/Convert-Binary-C/ ). 
It already offers a way to declaratively convert to/from binary

data, which could serve as inspiration for a similar Perl6 interface.

Greetings,
  Christian Renz

--
[EMAIL PROTECTED] - http://www.web42.com/crenz/ - http://www.web42.com/

"If God were a Kantian, who would not have us till we came to Him from
the purest and best motives, who could be saved?"
   -- C.S. Lewis, The Problem of Pain


Re: new mailing list: perl6-general?

2005-06-15 Thread Michele Dondi

On Tue, 14 Jun 2005, [iso-8859-2] BÁRTHÁZI András wrote:

Where should I ask, that what's PGE means? Yes, I know, it's Parrot Grammar 
Engine, and I know what it is, but a beginnner maybe not. And I think that


Which makes me think that first or later it may be worth to start a FAQ 
for questions like these even if they're not frequently asked. And indeed 
a perl6-general may be a starting point for writing one.



Michele
--

Is e+pi a rational or irrational number?

Yes, it is.
- Robert Israel in sci.math, "Re: A Number Problem"


Re: proposal: binding with a function

2005-06-15 Thread Carl Franks
> :   alias newlines, newline;

Isn't it possible to add a Role to the relevant Class, which specifies
that is 'handles' the method name you want as an alias?

Carl