Hyphenated rule names [Was: Perl 6 Summary for 2004-12-06 through 2004-12-20]

2004-12-20 Thread Larry Wall
On Mon, Dec 20, 2004 at 09:52:32PM -0500, Matt Fowles wrote:
: Much churning went on and it seems that multiple different
: (but identically named) rule captures can now be performed by adding
: information after a dash ala "  ".

Actually, much churning is still going on in both @Larry and $Larry,
and the final form of the solution is unlikely to involve hyphenated
names.  There has to be some way of serially getting at everything
that matched anyway, and picking up multiple names is probably just
a particular kind of selection syntax.  The hash and array subscripts
are just other shortcuts through that same general selector.  But
my formulations up till now have tended to destroy the serialization
of the matches unless you already know what your rules say.  And that's
not good, since it ought to be possible traverse a syntax tree generated
by a rule-set you aren't familiar with.

Larry


Perl 6 Summary for 2004-12-06 through 2004-12-20

2004-12-20 Thread Matt Fowles
Perl 6 Summary for 2004-12-06 through 2004-12-20
All~

The observant among you might notice that I missed last week's summary.
With the hubbub and confusion of the holidays, I blame ninjas, in
particular Ryu Hyabusa. Given that Christmas is next weekend and New
Years is the weekend after that, what you are like to see in the future
are a pair of 10 day summaries are some other equally irregular pattern.
If you are thinking of using the dates of my summaries to seed a random
number generator, I would advise against it as I can be really easily
bought ;-) Without more ado, I give you this fortnight's summary
starting with

  Perl 6 Language
   Lexical scope of parametric declaration blocks
Ashley Winters wanted to know what the differences between type
parameter lists and sub parameter lists. Luke Palmer could not think of
any.



   object representation
Abhijit Mahabal noticed that S12 allowed one to supply an object layout
to " bless() " and wondered if one could really have two instances of
the same class with different layouts. Larry admitted that he had
probably not intended for that to be the case.



   capturing into a hash, hypothetically
Patrick R. Michaud wondered about capturing things into a hash in S05,
as "" now captures. Larry admitted that it was probably supposed
to be " («ident»)", but also noticed that this exposed a blind spot in
the design. He went on to ruminate about this blind spot and ways to
solve it. Much churning went on and it seems that multiple different
(but identically named) rule captures can now be performed by adding
information after a dash ala "  ".



   custom subscripting
When talking about key Type for a hash, Larry offhandedly commented
about attaching a block to a hash or array to provided custom
subscripting. Many people drooled over the awesome syntactic sugar this
could provide them.



   undeclared attributes
Dave Whipp hoped that he need not predeclare his attributes as they
necessarily start with $. the fact that a new variable is an attribute
is easy to determine. Abhijit Mahabal thought that it would not be a
good idea, but then asked if classes could be declared as not strict.
Still waiting for more official word...



   classes which autovivify attributes
Abhijit Mahabal wondered about creating a class that populates it
attributes on demand, as some of them might be rarely used. Larry
suggested that it would be something that one should not undertake
lightly and a simple hash attribute would provide most of what is
wanted. This also morphed into the eternal debate about strictures and
one liners. There has to be a joke in there somewhere A stricture, a
one-liner, and Larry Wall walk into a bar...



   auto my
Rod Adams wondered if having my occur automatically for new variables
might be worthwhile. Several people commented that some languages
already do this and it is simply an aesthetic choice. The concensus
seems to be that Perl has already made this choice and is sticking with
its answer.



  Perl 6 Compiler
At long last google has picked up P6C, I guess I have slightly mixed
emotions about this as it takes a running gag from me. Alas, I will have
to find another.

   PGE tests
Markus Laire began working on a formerly small script to convert perl
5's regex tests to PGE. He produced a modest 700 tests a few of which
pass. Nice work. Patrick suggested only running the script once and
thereafter maintaining the tests external to perl5.

 -- initial post

 -- Patrick's suggestion

 -- how to deal with abiguity converting

   On your marks, get set, HACK!
Luke Palmer opened the door to hacking and has requested rules for parts
of the Perl 6 Grammar. Patrick posted a link to the SVN repository for
it.





  Parrot
   "\0namespace"
Leo commited a fix to support namespace mangling.



   store global => invalidate method cache
Leo commited a fix to invalidate the method cache when a global is
stored.



   pow, hash, batman sound effect!
Leo added pow and hash as vtables and opcodes. He also renamed
"new_extended" to "instantiate".



   base scalar semantics
Leo asked for comments about base PMC semantics and receive none.



   split now independant of Perl
James deBoer provided a patch removing the dependancy on Perl Array in
split. Will applied it.



   SVN
Periodically every project p

Re: Auto My?

2004-12-20 Thread Larry Wall
On Sun, Dec 19, 2004 at 08:25:58PM -0600, Rod Adams wrote:
: Another facet of this discussion comes into account when also specifying 
: type.
: 
: from S9:
:  my bit @bits;
:  my int @ints;
:  my num @nums;
:  my int4 @nybbles;
:  my str @buffers;
:  my ref[Array] @ragged2d;
:  my complex128 @longdoublecomplex;
: 
: Wouldn't this be much better as:
:  bit @bits;
:  int @ints;
:  num @nums;
:  int4 @nybbles;
:  str @buffers;
:  ref[Array] @ragged2d;
:  complex128 @longdoublecomplex;
: 
: Given that most of the stated reservations had to deal with explicit 
: declaration better defining scope, what is wrong with drooping the my in 
: this case?

How 'bout ambiguity with unary ops like "int" and "ref", or any
other unaries anyone ever decides to have that might conflict with
type names.  Plus it's just visually confusing.  Making it hard to
tell declarations from statements is one of the areas where C made
a big mistake, and I am not at all tempted to repeat it.

Larry


spaces for alignement

2004-12-20 Thread Stéphane Payrard
On Sun, Dec 19, 2004 at 06:44:33PM -0800, chromatic wrote:
> On Sun, 2004-12-19 at 20:25 -0600, Rod Adams wrote:
> > [snipped]
> > 
> > $x = 4;
> > $y = 7;
> > $z = 12;
> > $r = 4543;
> > $q = 121;
> > 
> > With a fixed width font, like all code editors use, all the =' like up, 
> > and I can quickly scan the var names to get to the one I want to change 
> > at that moment.
> 
> If you align the equals signs yourself with spaces, you can use variable
> names of different lengths (and possibly improved meaningfulness in
> actual factual code) too.
> 
> I'm only half-joking.  Vertical alignment makes a dramatic difference to
> readability.

> 
> -- c
> 


Speaking of alignement, my understanding is that the .[] operator,
allows spacing while [] does not:

$a = @shortnm.[0 ];
$b = @longername .[42];
--
 stef


Re: Auto My?

2004-12-20 Thread Juerd
James Mastros skribis 2004-12-19 23:00 (+0100):
> Juerd wrote:
> >Just typing "my " before the first use of a variable isn't hard, and it
> >makes things much clearer for both the programmer and the machine. 
> Does this imply that it's now possible to type C, and 
> declare @foo?  In the current perl, this doesn't work -- it's a syntax 
> error.  It'd certainly make many constructs easier.

I didn't mean to imply that, but I sure think it's a great idea, even
though I can't think of useful examples (as everything I can come up
with is more elegantly done with vector ops or map anyway).


Juerd


Re: Auto My?

2004-12-20 Thread Luke Palmer
James Mastros writes:
> Luke Palmer wrote:
> >James Mastros writes:
> >>Does this imply that it's now possible to type C, and 
> >>declare @foo?  In the current perl, this doesn't work -- it's a syntax 
> >>error.  It'd certainly make many constructs easier.
> >
> >That looks weird to me.  But as Rod points out, it can be useful with
> >hashes. 
> Yes, that's the primary case I was thinking of.  I was trying to find a 
> smaller example.
> 
> OTOH, I realize now you can do that with zip in P6, in which case you do 
> have a mention of the whole variable to stick a my on -- C zip(@keys, @values);>  I think C reads 
> better 
> though, even though looking at it literally, you're attempting to 
> lexicalize an element.

Know what's cool?

my %foo = @keys Â=>Â @values;

I think we have enough WTDI now. 

Luke


Re: Auto My?

2004-12-20 Thread Mark J. Reed
On 2004-12-19 at 21:35:46, Luke Palmer wrote:
>In Perl 5 you can do the hackish:
> 
>(\my @foo)->[23] = 42;

Hm.  My reaction to the above is, and I think I speak for the entire
assemblage when I say this, "Yuckbo."

:)

Now, (my @foo)[23] would be somewhat better, but of course, that's
attempting to assign to an element of a nonce list, not an array.

I think it would be reasonable for { my @foo[23] = 42; } to be legal
Perl 6 that declares @foo as lexical.  Letting { my $foo[23] = 42; }
work in Perl 5 would be weirder, but Perl6's "arrays always have @"
means that it's pretty clear you're declaring an array rather than a single
element.

Just my 2c.

-Mark


Re: Auto My?

2004-12-20 Thread James Mastros
Luke Palmer wrote:
James Mastros writes:
Does this imply that it's now possible to type C, and 
declare @foo?  In the current perl, this doesn't work -- it's a syntax 
error.  It'd certainly make many constructs easier.
That looks weird to me.  But as Rod points out, it can be useful with
hashes. 
Yes, that's the primary case I was thinking of.  I was trying to find a 
smaller example.

OTOH, I realize now you can do that with zip in P6, in which case you do 
have a mention of the whole variable to stick a my on -- C  I think C reads better 
though, even though looking at it literally, you're attempting to 
lexicalize an element.

-=- James Mastros,
theorbtwo