Re: Buf.pm: FIFO and grammar

2010-08-13 Thread Jonathan Worthington

Nicholas Clark wrote:

On Thu, Aug 12, 2010 at 03:38:31PM +0200, Carl Mäsak wrote:

  

In fact, jnthn++ had a talk at YAPC::EU the other week where he showed
how nested signatures can be used to make hierarchical matches. A
proof-of-concept module could simply be some sugar around this already
existing functionality.



That was a really good talk. I hope that it has been videoed, and will be
online soon.

  
I saw a video camera in the room, but not sure when we'll be seeing the 
footage from that. In the meantime, the slides are at:


http://www.jnthn.net/papers/2010-yapc-eu-signatures.pdf

Thanks,

/jnthn



Re: Buf.pm: FIFO and grammar

2010-08-13 Thread Aaron Sherman
On Fri, Aug 13, 2010 at 11:27 AM, Jonathan Worthington
jonat...@jnthn.netwrote:



 I saw a video camera in the room, but not sure when we'll be seeing the
 footage from that. In the meantime, the slides are at:

 http://www.jnthn.net/papers/2010-yapc-eu-signatures.pdf


Nice talk! One minor nit, and perhaps I'm just misunderstanding some subtle
use of the terminology, but you say:

In Perl 5, you get a copy of the arguments to work with in @_.

However, this isn't true (again, unless I'm misunderstanding you). @_ is a
by-reference list of positional parameters (Perl 5 only has positionals)
which are all read-write, which it's interesting to note, is impossible in
Perl 6... well, at least in Rakudo, as I'm not sure what the behavior is
supposed to be, but a slurpy positional list in Rakudo that's declared is
rw does not change the values passed in:

sub foo(*...@_ is rw) { @_[0] = 1 }
my $a = 0;
foo($a);
say $a; # 0

Kind of interesting that you can't easily emulate Perl 5's parameter
passing...

-- 
Aaron Sherman
Email or GTalk: a...@ajs.com
http://www.ajs.com/~ajs


Re: Buf.pm: FIFO and grammar

2010-08-13 Thread Jon Murray
My understanding from synopses was that you get the Perl 5 behaviour if
you omit the signature on your function declaration (though I
unfortunately can't check as I don't have Rakudo installed):

sub foo { @_[0] = 1 }
my $a = 0;
foo($a);
say $a; # 0

Cheers...

On Fri, 2010-08-13 at 12:06 -0400, Aaron Sherman wrote:
 On Fri, Aug 13, 2010 at 11:27 AM, Jonathan Worthington
 jonat...@jnthn.netwrote:
 
 
 
  I saw a video camera in the room, but not sure when we'll be seeing the
  footage from that. In the meantime, the slides are at:
 
  http://www.jnthn.net/papers/2010-yapc-eu-signatures.pdf
 
 
 Nice talk! One minor nit, and perhaps I'm just misunderstanding some subtle
 use of the terminology, but you say:
 
 In Perl 5, you get a copy of the arguments to work with in @_.
 
 However, this isn't true (again, unless I'm misunderstanding you). @_ is a
 by-reference list of positional parameters (Perl 5 only has positionals)
 which are all read-write, which it's interesting to note, is impossible in
 Perl 6... well, at least in Rakudo, as I'm not sure what the behavior is
 supposed to be, but a slurpy positional list in Rakudo that's declared is
 rw does not change the values passed in:
 
 sub foo(*...@_ is rw) { @_[0] = 1 }
 my $a = 0;
 foo($a);
 say $a; # 0
 
 Kind of interesting that you can't easily emulate Perl 5's parameter
 passing...
 




Re: Buf.pm: FIFO and grammar

2010-08-13 Thread Aaron Sherman
On Fri, Aug 13, 2010 at 8:11 PM, Jon Murray perlsm...@gmail.com wrote:

 My understanding from synopses was that you get the Perl 5 behaviour if
 you omit the signature on your function declaration (though I
 unfortunately can't check as I don't have Rakudo installed):

 sub foo { @_[0] = 1 }
 my $a = 0;
 foo($a);
 say $a; # 0



Nope. In fact, as you indicated in the comment you left in, that prints 0
just like the first example. In neither case is $a modified. In Perl 5, on
the other hand, the passed value can be modified:

$ ./perl6 -e 'sub foo { @_[0] = 1 } ; my $a = 0; foo($a); say $a'
0
$ perl -le 'sub foo { $_[0] = 1 } my $a = 0; foo($a); print $a'
1

You might well be correct about how it's supposed to work, but that's
certainly not the current behavior.


On Fri, 2010-08-13 at 12:06 -0400, Aaron Sherman wrote:
  On Fri, Aug 13, 2010 at 11:27 AM, Jonathan Worthington
  jonat...@jnthn.netwrote:
 
  
  
   I saw a video camera in the room, but not sure when we'll be seeing the
   footage from that. In the meantime, the slides are at:
  
   http://www.jnthn.net/papers/2010-yapc-eu-signatures.pdf
  
  
  Nice talk! One minor nit, and perhaps I'm just misunderstanding some
 subtle
  use of the terminology, but you say:
 
  In Perl 5, you get a copy of the arguments to work with in @_.
 
  However, this isn't true (again, unless I'm misunderstanding you). @_ is
 a
  by-reference list of positional parameters (Perl 5 only has positionals)
  which are all read-write, which it's interesting to note, is impossible
 in
  Perl 6... well, at least in Rakudo, as I'm not sure what the behavior is
  supposed to be, but a slurpy positional list in Rakudo that's declared
 is
  rw does not change the values passed in:
 
  sub foo(*...@_ is rw) { @_[0] = 1 }
  my $a = 0;
  foo($a);
  say $a; # 0
 
  Kind of interesting that you can't easily emulate Perl 5's parameter
  passing...
 





-- 
Aaron Sherman
Email or GTalk: a...@ajs.com
http://www.ajs.com/~ajs


Re: Buf.pm: FIFO and grammar

2010-08-13 Thread Brandon S Allbery KF8NH
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 8/13/10 22:03 , Aaron Sherman wrote:
 On Fri, Aug 13, 2010 at 8:11 PM, Jon Murray perlsm...@gmail.com wrote:
 
 My understanding from synopses was that you get the Perl 5 behaviour if
 you omit the signature on your function declaration (though I
 unfortunately can't check as I don't have Rakudo installed):

 sub foo { @_[0] = 1 }
 my $a = 0;
 foo($a);
 say $a; # 0


 
 Nope. In fact, as you indicated in the comment you left in, that prints 0
 just like the first example. In neither case is $a modified. In Perl 5, on
 the other hand, the passed value can be modified:
 
 $ ./perl6 -e 'sub foo { @_[0] = 1 } ; my $a = 0; foo($a); say $a'
 0
 $ perl -le 'sub foo { $_[0] = 1 } my $a = 0; foo($a); print $a'
 1
 
 You might well be correct about how it's supposed to work, but that's
 certainly not the current behavior.

As I read the spec, is ref should work (with some caveats).  I have no
idea if Rakudo currently implements it.

- -- 
brandon s. allbery [linux,solaris,freebsd,perl]  allb...@kf8nh.com
system administrator  [openafs,heimdal,too many hats]  allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon university  KF8NH
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.10 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxl+sYACgkQIn7hlCsL25Vh2wCeNZuQy7zhWqxYM/I87DBaSkDr
FzkAoIdwWGAR6r3y498xLUr2TBNduy9H
=FkBh
-END PGP SIGNATURE-


Re: Buf.pm: FIFO and grammar

2010-08-12 Thread Carl Mäsak
Oha ():
 after speaking with masak, i come up with some ideas about Buf
 i would like to share with you, maybe you can find them usefull

 http://register.oha.it/buf.pod

Just thought I'd weigh in here a bit. Oha's proposal consists of two
parts, each of which is interesting in its own right:

* The spec already has Buf as a Stringy, Array-ish thing. Perhaps one
could optimize for the ways Buf will actually be used, and think up an
API that combines the encoding/pushing and decoding/shifting into
single operations?

* Grammars define a hierarchical structure that seems to be perfect
for encoding the packing of larger pieces of data, for example when
serializing an object structure. Could one use grammars, or something
very much like it, as a modern pack template?

While I'm not convinced of the specifics of Oha's proposals, I think
the cores of both of these ideas have merit.

// Carl


Re: Buf.pm: FIFO and grammar

2010-08-12 Thread Aaron Sherman
On Thu, Aug 12, 2010 at 5:47 AM, Carl Mäsak cma...@gmail.com wrote:

 Oha ():


 * Grammars define a hierarchical structure that seems to be perfect
 for encoding the packing of larger pieces of data, for example when
 serializing an object structure. Could one use grammars, or something
 very much like it, as a modern pack template?


A while back we had a fairly productive conversation about matching regexes
on non-textual data:

http://groups.google.com/group/perl.perl6.language/msg/24f23fdfc0c5d459?hl=en

My proposal there is incomplete, but matching structured data (even if that
structure is just a sequence of non-textual bytes) using rules definitely
makes sense to me. The real question is: what is the least invasive way to
do it? Modifying nqp for this purpose would, I think, not make sense. I
think we'd need a pure Perl implementation of the rules engine that could
match either text or data, and that's a gigantic undertaking.

-- 
Aaron Sherman
Email or GTalk: a...@ajs.com
http://www.ajs.com/~ajs


Re: Buf.pm: FIFO and grammar

2010-08-12 Thread Carl Mäsak
Carl (), Aaron ():
 * Grammars define a hierarchical structure that seems to be perfect
 for encoding the packing of larger pieces of data, for example when
 serializing an object structure. Could one use grammars, or something
 very much like it, as a modern pack template?

 A while back we had a fairly productive conversation about matching regexes
 on non-textual data:
 http://groups.google.com/group/perl.perl6.language/msg/24f23fdfc0c5d459?hl=en

Interesting thread.

 My proposal there is incomplete, but matching structured data (even if that
 structure is just a sequence of non-textual bytes) using rules definitely
 makes sense to me. The real question is: what is the least invasive way to
 do it? Modifying nqp for this purpose would, I think, not make sense. I
 think we'd need a pure Perl implementation of the rules engine that could
 match either text or data, and that's a gigantic undertaking.

Crazy people have been known to implement the rules engine in Perl 6,
even... :-)

But I think we can get away much cheaper than that. If we contend
ourselves with keeping an early sublanguage inside strings, or with
some well-chosen subroutine names, we could experiment with
hierarchical matchers today in Rakudo. I'd love for someone to develop
a proof-of-concept module for something like this; both matching on
binary data, and the hierarchy matcher described in your thread.

In fact, jnthn++ had a talk at YAPC::EU the other week where he showed
how nested signatures can be used to make hierarchical matches. A
proof-of-concept module could simply be some sugar around this already
existing functionality.

// Carl


Re: Buf.pm: FIFO and grammar

2010-08-12 Thread Nicholas Clark
On Thu, Aug 12, 2010 at 03:38:31PM +0200, Carl Mäsak wrote:

 In fact, jnthn++ had a talk at YAPC::EU the other week where he showed
 how nested signatures can be used to make hierarchical matches. A
 proof-of-concept module could simply be some sugar around this already
 existing functionality.

That was a really good talk. I hope that it has been videoed, and will be
online soon.

Nicholas Clark


Buf.pm: FIFO and grammar

2010-08-11 Thread Oha

after speaking with masak, i come up with some ideas about Buf
i would like to share with you, maybe you can find them usefull

http://register.oha.it/buf.pod

HTH

Oha