Re: Pike 7.4

2003-01-08 Thread Damian Conway
Chris Dutton wrote:


Given discussions about hyper operators in the past, I found this 
rather interesting in the release notes.

http://pike.idonex.com/download/notes/7.4.10.xml

Interesting, but I still feel that vectorized operators give more flexibility.
For example, I'm struggling to see how one could use the [*] to do this:

	@names = «Gödel Escher Bach»;
	
	@ages = $today »-« %date_of_birth{@names}

Damian





Re: Variable Types Vs Value Types

2003-01-08 Thread Damian Conway
One of the wise may override my evaluation,


Or I could do it. ;-)



Can the type of a variable vary independenty of its value?

 
My understanding is that the type of a variable merely restricts the type
of value you can assign to it.  (Well, it probably does more, but I'm not
clear on what or how yet.)

There are in fact *two* types associated with any Perl variable:

	1. Its storage type (i.e. the type(s) of value it can hold)
   This is specified before the variable or after an Cof or Creturns.
	   It defaults to Scalar.

	2. Its implementation type (i.e. the class that tells it how to act)
   This is specified after an Cis. It defaults to the type indicated
	   by the variable's sigil.

So:

	Declaration  Storage  Implementation
	 Type Type
	===  ===  ==

	my $var; Scalar   Scalar
	my @var; Scalar   Array
	my %var; Scalar   Hash

	my Int @var; Int  Array
	my @var of Int;  Int  Array
	my @var returns Int; Int  Array

	my @var is SparseArray;  Scalar   SparseArray

	my Int @var is SparseArray;  Int  SparseArray
	my @var is SparseArray of Int;   Int  SparseArray
	my @var is SparseArray returns Int;  Int  SparseArray


BTW, the use of Creturns may seem a little odd, until you realize that,
like a subroutine, a variable is just an access mechanism for values.
There's rather a nice node on PerlMonks just now about just that notion.




Consider the following:

  my @a = (1,2,3);
  my $b := @a;

@a and $b both refer to the same object. $b's object has methods such as
PUSH, POP, etc, as does @a's.



Do they?  One is obviously an array, and one is obviously a scalar.
You may get an error (cannot alias an array as a scalar)  or $b get aliased
to the array-in-scalar-context (a reference).


The latter, in fact. When trying to puzzle out what any binding does
imagine that the LHS is a subroutine parameter, and the RHS the corresponding
argument.




  my @a = (1,2,3) but implements_sum_method; # add .sum method to vtable
  my SummingArray $b := @a;



Actually, (unless implements_sum_method is a subclass of SummingArray,)


That won't help. Value (i.e. Cbut) properties don't confer class status.



it looks like an error to me,  because @a is an array and/or an
implements_sum_method, but $b is restricted to holding a SummingArray.


Yep.



As counter-example, consider:

  my Array @array := SpecialArray.new;

Should the value in @array act like an Array or a SpecialArray?  Most
people would say SpecialArray, because a SpecialArray ISA Array.


Weell...*I'd* say that @array should act like an Array (that is, you should
only be able to call the methods specified by the Array class), except that
any method calls should be polymorphically resolved to invoke the
equivalent SpecialArray methods.

But maybe that's just saying the same thing. Is there a linguist in the house?

;-)



I can also interpret what you want as saying my SpecialArray @array :=
Array.new should autopromote the value to a subclass somehow  which would
be very strange.


To say the least!

Damian





Re: AW: my int( 1..31 ) $var ?

2003-01-08 Thread Damian Conway
Christian Renz wrote:


Now, I might be stupid, but I keep asking myself what you would need a
property for in this example.


Yes. It's important to remember that the shiny new hammer of properties
is not necessarily the appropriate tool to beat on *every* problem. :-)

Damian





Re: AW: AW: AW: AW: nag Exegesis 2

2003-01-08 Thread Damian Conway
Murat Ünalan wrote:


Then i could pray to the god of the camel herdsman, that

  my DNA human size(4) ($alpha, $beta,  $gamma, $delta) 
 = ('atgc', 'ctga', 'aatt', 'ccaa');

may be activated through perl6 custom parser options 8-)

*Any* consistent syntax may be activated through perl6 custom parser options.
Whether it *should* be is, of course, another matter entirely. ;-)



I have a german background.


BTW, I wasn't criticizing your English. Someone who's German is as poor as mine
doesn't have the right. ;-)



But my litte english-vs-perl6 example sounds
not so odd to me (what doesn't mean to much):

  my aged uncles ( john, james, jim, tony ) are 
 ( 102,  99,88,  79   ) 

That's perfect English. But not necessarily good programming language design.
		


Thanks for your patience with me,


It's not a matter of patience. You raise important issues (which I very much
appreciate), and it's my job -- and my desire -- to address them.

Damian





Re: Array Questions

2003-01-08 Thread Damian Conway
Michael Lazzaro wrote:



   my int @a;
   my @a returns int;
   my @a is Array of int;
   my @a is Array returns int;
   my int @a is Array;

Those lines are all absolutely synonymous, and all declare an array of 
integers, right?  

Right. (This week, at least ;-)



Likewise, Arrays have methods:

   my int @a = (1..100);
   print @a.length;   # prints 100
   my @b = @a.grep { $_  50 };   # gets 51..100

... which is also known, based on previous Apocalypsii.


Right.



If we accept those as valid syntax -- and I *think* they have been -- 
then P6 Arrays are objects.  Or, at minimum, they cannot be _discerned_ 
from objects, regardless of implementation.

The later, I strongly suspect.



The remaining big question, then, is whether you can truly subclass 
Array to achieve Ctie-like behavior:

   class MyArray is Array { ... };

   my @a is MyArray;

Oh yes, I would certainly expect that this has to be possible.




Which, in turn, implies that the lines:

   my Foo $a; # (1)
   my $a is Foo;  # (2)
   my Foo $a is Foo;  # (3)

are all subtly different.  (2) and (3) (auto)instantiate a Foo, but (1) 
does not.

Correct. Though the instantiated Foo is the implementation object and
not directly accessible (just as the implementation object in a Perl 5
tie isn't).

BTW, Cmy Foo $a is Foo is just sick!
(i.e. I'll *definitely* be using it ;-)

Damian






Re: Array Questions

2003-01-08 Thread Damian Conway
Jonathan Scott Duff wrote:

On Tue, Jan 07, 2003 at 10:04:09AM -0800, Michael Lazzaro wrote:



Which, in turn, implies that the lines:

   my Foo $a; # (1)
   my $a is Foo;  # (2)
   my Foo $a is Foo;  # (3)

are all subtly different.  (2) and (3) (auto)instantiate a Foo, but (1) 
does not.
 
Um ... ick.  I'd hope that autoinstantiation wouldn't happen without
some clear syntactical clue.  (I don't think is that clue.  To me
all three of those look like they should just earmark $a to contain a
Foo and this Foo-thing can/will be instantiated later)

I doubt it. The Cis Foo tells Perl that this variable is *implemented*
by a (hidden) Foo object. The variable better be able to get in touch with
that inner Foo at the point the variable is first used in any way. So
it probably needs to be autocreated at the point of declaration (or, at
least, trampolined into existance before the variable is first used).

Damian





Re: Variable Types Vs Value Types

2003-01-08 Thread Damian Conway
John Williams wrote:


I'm still not buying the autoinstantiation argument.  All the other
(non-M.L.) threads I have read are requiring
   my $a is Foo = .new;  # or some such...


Yes. You're confusing auto-instantiation of *implementation type* (good)
with autoinstantiation of *stored value* (bad).



Both your examples above create the varible $a, but it contains the value
of undef, not an instance of Foo.


Correct. But:

	my Foo $var;

is implemented by an underlying (possibly optimized-away) Scalar object.
Whereas:

	my $var is Foo;

is implemented by an underlying Foo object. It's only this underlying Foo
object that is auto-instantiated.

Damian





Re: Array Questions

2003-01-08 Thread Luke Palmer
 From: Deborah Ariel Pickett [EMAIL PROTECTED]
 Date: Wed, 8 Jan 2003 09:42:18 +1100 (EST)

 [...] But everybody has to learn Perl once.

I agree with you entirely :)

Luke



Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Luke Palmer
 Date: Wed, 08 Jan 2003 12:14:10 +0800
 From: Damian Conway [EMAIL PROTECTED]
 
 Can I suggest that an alternative solution might be the following:
 
  Suppose Perl 6 had two new very low precedence operators: ~ and ~
  (a.k.a. bind rightwards and bind leftwards)
 
  Suppose ~ takes its left argument and binds it to
  the end of the argument list of its right argument,
  then evaluates that right argument and returns the result.
  So an L2R array-processing chain is:
 
  @out = @a ~ grep {...} ~ map {...} ~ sort;
 
  There might also be a be special rule that, if the RHS is
  a variable, the LHS is simply assigned to it. Allowing:
 
  @a ~ grep {...} ~ map {...} ~ sort ~ @a;
 
  Further suppose that ~ takes its right argument, and binds
  it in the indirect object slot of the left argument, which
  argument it then calls. So an R2L array-processing chain is:
 
  @out = sort ~ map {...} ~ grep {...} ~ @a;
 
  Or, under a special rule for variables on the LHS:
 
  @out ~ sort ~ map {...} ~ grep {...} ~ @a;
 
 That way, everything is still a method call, the ultra-low precedence of
 ~ and ~ eliminate the need for parens, and (best of all) the expressions
 actually *look* like processing sequences.

I think this is a big step towards readability.  It allows you to put
whatever part of the expression wherever you want (reminiscent of
Latin); i.e. always keep the important parts standing out.  I also
think that the operator (especially a cool 3d-looking one like ~) is
also much more readable than a word in this case. 

It's a shame ~ is ambiguous.  It's a lexical ambiguity, which can be
solved with whitespace 

Luke



Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread damian
Luke Palmer wrote:

 I think this is a big step towards readability.  It allows you to put
 whatever part of the expression wherever you want (reminiscent of
 Latin);

You didn't think Perligata was just for *fun*, did you? ;-)

 It's a shame ~ is ambiguous.  It's a lexical ambiguity, which can be
 solved with whitespace 

...and the longest token rule. 

And, of course, it's no more ambiguous than the ~~ operator:

foo ~~ $bar # means: foo() ~~ $bar
#   not: foo( ~ ~$bar )

Damian



Re: Variable Types Vs Value Types

2003-01-08 Thread chromatic
On Tue, 07 Jan 2003 12:21:48 +0100, Rafael Garcia-Suarez wrote:

 Delegation has drawbacks compared to inheritance : you can't use
 a object that delegates to class Foo where an instance of Foo is
 expected.

That sounds more like a problem with the polymorphism implementation than an
argument against delegation (or even mixins).  isa() considered harmful!

-- c



RE: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread frederic fabbro
#  Damian Conway wrote:
#   @out = sort ~ map {...} ~ grep {...} ~ @a;
#  
#   Or, under a special rule for variables on the LHS:
#  
#   @out ~ sort ~ map {...} ~ grep {...} ~ @a;

Hello,

Can one see it as a shell redirection/pipe? This may sound funny, 
but is the following ok?
 @b ~ @a  ~ @c; #  @c = @b = @a;
(@b ~ @a) ~ @c; #  same order i guess

so one can also:
@keep ~ grep /good/ ~ @list ~ grep /bad!/ ~ @throw;

is this if valid too?
@b ~ @a ~ @c; #  push @a, @b, @c;
or: @b, @c ~ push @a;
qw/hello world/ ~ print

I guess it modifies $_
print $_ \t %stat{$_} \n ~ grep /^[Aa]/ ~ keys %stat
print $_ \t %stat{$_} \n for grep /^[Aa]/, keys %stat


Could we get pairs (or more), and also something like a step, for 
example to only take one array elements every two?


Have a nice day,
Frederic



Re: Variable Types Vs Value Types

2003-01-08 Thread Rafael Garcia-Suarez
Damian Conway [EMAIL PROTECTED] wrote:
 
 There are in fact *two* types associated with any Perl variable:
 
   1. Its storage type (i.e. the type(s) of value it can hold)
 This is specified before the variable or after an Cof or Creturns.
  It defaults to Scalar.
 
   2. Its implementation type (i.e. the class that tells it how to act)
 This is specified after an Cis. It defaults to the type indicated
  by the variable's sigil.

How does it work regarding inheritance and polymorphism ?
E.g. consider
my @a is Set of Apple;
my @b is Basket of Fruit;
with Apple isa Fruit, and Basket is a Set.

I assume I can use @a or @b where the expected type is:

@a  @b
Set ok  ok
Set of Fruitok  ok
Set of Appleok  no(?)
Basket  no  ok
Basket of Fruit no  ok
Basket of Apple no  no(?)

the errors being compile-time or run-time, depends on how much verification the
compiler can perform with its input. Reminds me the SetApple C++ templates.
And the whole mess that comes with it (when you've got a statically typed language.)



Re: Variable Types Vs Value Types

2003-01-08 Thread Simon Cozens
[EMAIL PROTECTED] (Damian Conway) writes:
 There are in fact *two* types associated with any Perl variable:

Is there any chance we could make this a little more confusing? One or
two people still appear to be following you.

-- 
You advocate a lot of egg sucking but you're not very forthcoming with the 
eggs. - Phil Winterbottom (to ken)



Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Rafael Garcia-Suarez
frederic fabbro [EMAIL PROTECTED] wrote:
 
 Can one see it as a shell redirection/pipe? This may sound funny, 
 but is the following ok?
@b ~ @a  ~ @c; #  @c = @b = @a;
   (@b ~ @a) ~ @c; #  same order i guess
 
 so one can also:
   @keep ~ grep /good/ ~ @list ~ grep /bad!/ ~ @throw;
 
 is this if valid too?
   @b ~ @a ~ @c; #  push @a, @b, @c;
 or:   @b, @c ~ push @a;
   qw/hello world/ ~ print

Just add ^~ and v~ and we've got our own Befunge flavor.



Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread attriel
 Can I suggest that an alternative solution might be the following:

  Suppose Perl 6 had two new very low precedence operators: ~ and ~
 (a.k.a. bind rightwards and bind leftwards)

  @out = @a ~ grep {...} ~ map {...} ~ sort;

  @out = sort ~ map {...} ~ grep {...} ~ @a;

 That way, everything is still a method call, the ultra-low precedence of
 ~ and ~ eliminate the need for parens, and (best of all) the
 expressions actually *look* like processing sequences.

(a) OOh, shiny!

(b) Can ~ and ~ be used at the same time?

I'm not entirely sure of what functions take two array params
meaningfully, but could we do:

@a ~ grep (...) ~ sort ~ for ~ map (...) ~ @b {
 (for content goes here)
}

With the understanding that
(1) EWWW, that is horribly ugly, but it was the first thing I could come
up with that meaningfully takes two list args
(2) Anyone who ACTUALLY does this with a for be shot on sight?

It would be more meaningful in another function that takes two lists and
does something useful, but without a body block ... More of a

@a ~ grep (...) ~ apply ~ sort ~ @b ;

So that the grep'd elements of @a are applied, 1:1, to the sorted @b ... ala
  apply (grep (..., @a), sort(@b));

(again, more useful for a longer chain)

--attriel






RE: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread HellyerP
Atriel:
 Damian:
 Can I suggest that an alternative solution might be the following:

  Suppose Perl 6 had two new very low precedence operators: ~ and ~
 (a.k.a. bind rightwards and bind leftwards)

  @out = @a ~ grep {...} ~ map {...} ~ sort;

  @out = sort ~ map {...} ~ grep {...} ~ @a;

 That way, everything is still a method call, the ultra-low precedence of
 ~ and ~ eliminate the need for parens, and (best of all) the
 expressions actually *look* like processing sequences.

(a) OOh, shiny!

(b) Can ~ and ~ be used at the same time?

I'm not entirely sure of what functions take two array params
meaningfully, but could we do:

Damian's proposal didn't say anything about array params.  If I understood
him correctly, then this should print FOO on standard out:

my $foo = FOO;
$foo ~ print;
 
The opposite 'squiggly arrow' fiddles the indirect object, so perhaps this
would print FOO on standard error (modulo the STDERR syntax, which I think

changed when I wasn't looking):

$foo ~ print ~ STDERR;

Philip


Disclaimer

This communication together with any attachments transmitted with it ('this E-mail') 
is intended only for the use of the addressee and may contain information which is 
privileged and confidential. If the reader of this E-mail is not the intended 
recipient or the employee or agent responsible for delivering it to the intended 
recipient you are notified that any use of this E-mail is prohibited. Addressees 
should ensure this E-mail is checked for viruses. The Carphone Warehouse Group PLC 
makes no representations as regards the absence of viruses in this E-mail. If you have 
received this E-mail in error please notify our ISe Response Team immediately by 
telephone on + 44 (0)20 8896 5828 or via E-mail at [EMAIL PROTECTED] Please then 
immediately destroy this E-mail and any copies of it.

Please feel free to visit our website: 

UK
http://www.carphonewarehouse.com

Group
http://www.phonehouse.com




RE: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread attriel

(b) Can ~ and ~ be used at the same time?

I'm not entirely sure of what functions take two array params
meaningfully, but could we do:

 Damian's proposal didn't say anything about array params.  If I
 understood him correctly, then this should print FOO on standard out:

DOH!  All the examples were using @'s, and somehow that translated to
this is an array opthingy :o

 $foo ~ print ~ STDERR;

That makes a fair amount of sense (and certainly more than any of my
array-based flawed examples :)

Thanks for clearing up my fogginess :o

--attriel





RE: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread frederic fabbro
#  Rafael Garcia-Suarez [mailto:[EMAIL PROTECTED]] wrote:
#  frederic fabbro [EMAIL PROTECTED] wrote:
#   so one can also:
#  @keep ~ grep /good/ ~ @list ~ grep /bad!/ ~ @throw;
#   
#   is this if valid too?
#  @b ~ @a ~ @c; #  push @a, @b, @c;
#   or:@b, @c ~ push @a;
#  qw/hello world/ ~ print
#  
#  Just add ^~ and v~ and we've got our own Befunge flavor.

Hehe, yep ;-)

I'm not even sure how that would parse, though that:
@keep ~ grep /good/ ~ @list ~ grep /bad!/ ~ @throw;
would go like:
( @keep ~ grep /good/ ~ @list ) ~ grep /bad!/ ~ @throw;

which is probably not what i wanted...


Frederic



Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Austin Hastings

--- Damian Conway [EMAIL PROTECTED] wrote:
  @out = @a ~ grep {...} ~ map {...} ~ sort;
  ...
  @out ~ sort ~ map {...} ~ grep {...} ~ @a;
 
 That way, everything is still a method call, the ultra-low precedence
 of
 ~ and ~ eliminate the need for parens, and (best of all) the
 expressions
 actually *look* like processing sequences.

Brilliant! Keep pushing this. Finally, I'll be able to get investor
backing for my USB foot-pedal shift-key device. They say the first 20
million is the hardest...

Woo-hoo!

Q: How do you recognize a perl6 programmer?
A: His pinky is bigger than his thumb.

=Austin




Re: This week's Perl Summary

2003-01-08 Thread Piers Cawley
Steve Fink [EMAIL PROTECTED] writes:

 On Jan-04, Leopold Toetsch wrote:
 Damian Conway wrote:
 
 Piers Cawley wrote:
 
 Acknowledgements
 
 But, of course, modesty forebade him from thanking the tireless Perl 6
 summarizer himself, for his sterling efforts wading through the morasses
 that are P6-language and P6-internals
 
 Remembering e.g. perl6 operator threads, brrr, I just can say ...
 
 Thank-you, Piers!
 
 me2

 Me3. But watch out -- you are single-handedly responsibility for the
 sanity of hundreds of us, and are therefore responsible for anything
 we might do in this unnatural state.

I accept no responsibility for any such actions, and reserve the right
to cease producing summaries at any time (but not in the foreseeable
future). Now, I've got the perl6-internals section of the
christmas/new year summary written, hopefully I'll have the
perl6-language and other bits written and mailed out later today. Hang
in there people.

-- 
Piers



Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Jonathan Scott Duff
On Wed, Jan 08, 2003 at 05:14:06PM +0100, frederic fabbro wrote:
 I'm not even sure how that would parse, though that:
   @keep ~ grep /good/ ~ @list ~ grep /bad!/ ~ @throw;
 would go like:
   ( @keep ~ grep /good/ ~ @list ) ~ grep /bad!/ ~ @throw;
 
 which is probably not what i wanted...

Oh, then we just need a syntax to split the streams.  ... I know!

@list ~| grep /bad!/ ~ @throw ~| grep /good/ ~ @keep;

which, of course, could be written in the more readable form:

@list ~| grep /bad!/ ~ @throw 
  ~| grep /good/ ~ @keep;

And that, of course, leads us to sort of unzip were mutual exclusion
is not a requisite:

@list ~| grep length == 1 ~ @onecharthings
  ~| grep [0..29] ~ @numberslessthan30
  ~| grep /^\w+$/ ~ @words
  ~| grep $_%2==0 ~ @evennumbers;

:-)

-Scott
-- 
Jonathan Scott Duff
[EMAIL PROTECTED]



Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread David Storrs
On Wed, Jan 08, 2003 at 08:31:51AM -0800, Austin Hastings wrote:
 
 --- Damian Conway [EMAIL PROTECTED] wrote:
   @out = @a ~ grep {...} ~ map {...} ~ sort;
   ...
   @out ~ sort ~ map {...} ~ grep {...} ~ @a;

For the record, I think this is great.


 Brilliant! Keep pushing this. Finally, I'll be able to get investor
 backing for my USB foot-pedal shift-key device. 


http://www.tuxedo.org/~esr/jargon/html/entry/double-bucky.html

--Dks



Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Luke Palmer
 Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
 Date: Wed, 8 Jan 2003 11:30:51 -0500 (EST)
 From: attriel [EMAIL PROTECTED]
 Reply-To: [EMAIL PROTECTED]
 X-SMTPD: qpsmtpd/0.20, http://develooper.com/code/qpsmtpd/
 
 
 Note 1) This is the second time I'm typing this
 Note 2) Ctrl-Shift-Capslock apparently closes all current instances of
 mozilla ... that was weird
 
  I'm not even sure how that would parse, though that:
  @keep ~ grep /good/ ~ @list ~ grep /bad!/ ~ @throw;
  would go like:
  ( @keep ~ grep /good/ ~ @list ) ~ grep /bad!/ ~ @throw;
 
  which is probably not what i wanted...
 
 I would, from the descriptions, imagine that:
   @keep ~ grep /good/ ~ @list ~ grep /bad!/ ~ @throw;
 
 Would parse as:
   @keep ~ grep /good/ ~ @list;
   @list ~ grep /bad!/ ~ @throw;

Nope.  ~ and ~ only *rearrange* arguments, so if you only type @list
once, you can only do things that you could before when you typed
@list only once.

When we present this in the documentation (wishful thinking, now), it
will be important that we present it in precisely that way, as
argument rearrangers, lest people actually try that kind of foulplay.
In that documentation we should probably suggest that the arrows go
only one way per statement, otherwise you might not get what you
expect.

 Due to that being what is almost always going to be intended, I think. 
 Also, since we'd want $a ~ 2 + 4; to be $a = 6;, I would imagine that ~
 and ~ would need low priorities. 

Precedences.  Yes.

 Further, since ~ stars at the end of the list and works its way
 left, it would need a lower priority than ~ which starts at the
 beginning and works its way right. 

Not necessarily.  ~ will necessarily need to be right-associative,
while ~ left, however.  It would be logical to give them the same
precedence, except for the opposite associativity thing, where parsers
get different results based on their parse method.  So different
precedences would be good only to ensure that different parsers saw
the same thing.

 So if it did have a parenthetical variation, I would imagine it
 would be
 
   @keep ~ grep /good/ ~ (@list ~ grep /bad!/ ~ @throw);
 
 Which is, still, probably not what you wanted.

Right.  And probably not recommended.

 OTOH, I'm still new at posting here, and I may not be following all the
 bits that came before :o

You're quickly getting the hang of it.

Luke



Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Luke Palmer
 Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
 Date: Wed, 8 Jan 2003 10:45:37 -0600
 From: Jonathan Scott Duff [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Reply-To: [EMAIL PROTECTED]
 Mail-Followup-To: frederic fabbro [EMAIL PROTECTED],
   [EMAIL PROTECTED]
 Content-Disposition: inline
 X-SMTPD: qpsmtpd/0.20, http://develooper.com/code/qpsmtpd/
 
 On Wed, Jan 08, 2003 at 05:14:06PM +0100, frederic fabbro wrote:
  I'm not even sure how that would parse, though that:
  @keep ~ grep /good/ ~ @list ~ grep /bad!/ ~ @throw;
  would go like:
  ( @keep ~ grep /good/ ~ @list ) ~ grep /bad!/ ~ @throw;
  
  which is probably not what i wanted...
 
 Oh, then we just need a syntax to split the streams.  ... I know!
 
   @list ~| grep /bad!/ ~ @throw ~| grep /good/ ~ @keep;
 
 which, of course, could be written in the more readable form:
 
   @list ~| grep /bad!/ ~ @throw 
 ~| grep /good/ ~ @keep;

Spookily, this quantumish operation can be achieved with Perl's
quantumish operators.

  @list ~ (grep /bad!/ ~ @throw) | (grep /good/ ~ @keep);

I'd actually think I'd be happier if that didn't work.  Fortunately, I
don't think it does  (how do you put an argument on the end of a |
expression?)).

What we really need is a beam-split operator:

  @list ~ (-grep /bad!/ ~|~ grep /good/) ~ @result;

Then @result would contain all things bad or good, but not both,
because they interfere! :)

 And that, of course, leads us to sort of unzip were mutual exclusion
 is not a requisite:
 
   @list ~| grep length == 1 ~ @onecharthings
 ~| grep [0..29] ~ @numberslessthan30
 ~| grep /^\w+$/ ~ @words
 ~| grep $_%2==0 ~ @evennumbers;

I'm not going even to try this one.

 :-)
 (-:

Luke



Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Buddha Buck
Luke Palmer wrote:


I would, from the descriptions, imagine that:
 @keep ~ grep /good/ ~ @list ~ grep /bad!/ ~ @throw;

Would parse as:
 @keep ~ grep /good/ ~ @list;
 @list ~ grep /bad!/ ~ @throw;



Nope.  ~ and ~ only *rearrange* arguments, so if you only type @list
once, you can only do things that you could before when you typed
@list only once.


So what we have is (using a scalar for an arbitrary variable) is:

$a ~ subroutine $arg1;

is equivalent to:

subroutine $arg1, $a;

and

subroutine $arg1 ~ $a;

is equivalent to:

subroutine $arg1 $a:;  # or , equivalently, subroutine $a: $arg1;

and

.. ~ $a;

is equivalent to

$a = ...;

and similarly,

$a ~ ...;

is equivalent to

$a = ...;

~ is left associative, ~ right associative, have the same precedence, 
and can't be mixed in one expression because of conflicting associativity

That means that a standard chain like:

  @list ~ grep /good/ ~ map - { s/good/bad/ } ~ @badlist;

would parse as
  ((@list ~ grep /good/) ~ map - { s/good/bad/ } ) ~ @badlist;
to
  ((grep /good/ @list) ~ map - {s/good/bad/ } ) ~ @badlist;
to
  (map - {s/good/bad/}, (grep /good/ @list)) ~= @badlist;
to
  @badlist = (map - {s/good/bad/}, (grep /good/ @list));
to
  @badlist = map - {s/good/bad/}, grep /good/ @list;

(modulo possible regex sytax).






RE: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Austin Hastings

--- attriel [EMAIL PROTECTED] wrote:
  I'm not even sure how that would parse, though that:
  @keep ~ grep /good/ ~ @list ~ grep /bad!/ ~ @throw;
  would go like:
  ( @keep ~ grep /good/ ~ @list ) ~ grep /bad!/ ~ @throw;
 
  which is probably not what i wanted...
 
 I would, from the descriptions, imagine that:
   @keep ~ grep /good/ ~ @list ~ grep /bad!/ ~ @throw;
 
 Would parse as:
   @keep ~ grep /good/ ~ @list;
   @list ~ grep /bad!/ ~ @throw;

Actually, if you can say @a ~ sort ~ grep /foo/ ~ @output then
it's pretty obvious that ~ is left-associative, a la  in C++.

Remember: cout  Hello, world!  nl;

First does coutHW and returns cout-prime, 
then does cout-prime  nl

Likewise, the perl example does
@a ~ sort, returning @a-prime
@a-prime ~ grep /foo/, returning @a-2prime
@a-2prime ~ @output, returning @output-prime, I hope!

Reversing the direction:

@output ~ grep /foo/ ~ sort ~ @a

First does sort :@a, (I hope the syntax is right) returning @a-prime
then does grep /foo/ :@a-prime, returning @a-2prime
then does @output.operator() :@a-2prime
which we hope gets transmogrified into assignment, and I likewise hope
this will return @output-prime.

So ~ looks right-associative.

  @keep ~ grep /good/ ~ @list ~ grep /bad!/ ~ @throw;

Assuming that ~ and ~ have equal precedence, and that there's not
some hideous special case backing this syntax, the above becomes:

1:   @list ~ grep /bad!/
2: ~ @throw
3: grep /good/ ~
4:   @keep ~

Which greps the @throw list for goodies -- not what I think you want.

   @keep ~ grep /good/ ~ @list;
   @list ~ grep /bad!/ ~ @throw;
 Due to that being what is almost always going to be intended, I
 think. 

Which brings up the point: What DO we want here?

Frankly, I'm in love with the idea of a simple pipeline operator. I
find it really easy to write AND read scripts like this:

cat file
| sed -e ...
| grep -v ...
| nl
| sort -k ...
| awk ...
| sort 
 output

Being able to draw the pipeline make it really readable for the
maintainer. The idea of doing something similar:

@a
~ grep
~ map
~ @output

is attractive. Regardless, I'm sure I don't like 

$foo ~ print ~ STDOUT

That one's going to die a lonely death.

=Austin




Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Rafael Garcia-Suarez
Luke Palmer [EMAIL PROTECTED] wrote:
 
 Not necessarily.  ~ will necessarily need to be right-associative,
 while ~ left, however.

Not sure if you aren't getting this backwards, but anyway I often find
myself confused with right and left.

 It would be logical to give them the same
 precedence, except for the opposite associativity thing, where parsers
 get different results based on their parse method.  So different
 precedences would be good only to ensure that different parsers saw
 the same thing.

Actually I don't think you can define a grammar where two operators have
the same precedence but different associativity. Be it a pure BNF
grammar, or a classical yacc specification (using the %left and %right
declarations).



RE: Variable Types Vs Value Types

2003-01-08 Thread Brent Dax
Simon Cozens:
# [EMAIL PROTECTED] (Damian Conway) writes:
#  There are in fact *two* types associated with any Perl variable:
# 
# Is there any chance we could make this a little more 
# confusing? One or two people still appear to be following you.

I'll make it a little simpler.  If A is the type of aggregate (Array,
Hash, RowOfKennels) and E is the type of element (Scalar, String, Dog),
here's where each goes:

my E @var;  #assumes Array
my @var of E;   #same
my E @var is A; #No assumption
my @var is A of E;  #same

'returns' is an exact synonym of 'of', so for the same of clarity and
brevity I'll ignore it.  (I would suggest, though, that anyone who uses
'returns' here in real code should be shot.)

Notice that E is always either at the front or behind an 'of', and A is
always after an 'is'.  (If you think of a variable as a stack of
properties, this 'is' is just specifying the root property.)

Is that clear enough, or should I say it a little slower?

--Brent Dax [EMAIL PROTECTED]
@roles=map {Parrot $_} qw(embedding regexen Configure)

If you want to propagate an outrageously evil idea, your conclusion
must be brazenly clear, but your proof unintelligible.
--Ayn Rand, explaining how today's philosophies came to be






Re: Variable Types Vs Value Types

2003-01-08 Thread Simon Cozens
[EMAIL PROTECTED] (Brent Dax) writes:
 Is that clear enough, or should I say it a little slower?

Clear as it's going to get, I fear.

-- 
He was a modest, good-humored boy.  It was Oxford that made him insufferable.



RE: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Brent Dax
Jonathan Scott Duff:
# And that, of course, leads us to sort of unzip were mutual 
# exclusion is not a requisite:
# 
#   @list ~| grep length == 1 ~ @onecharthings
# ~| grep [0..29] ~ @numberslessthan30
# ~| grep /^\w+$/ ~ @words
# ~| grep $_%2==0 ~ @evennumbers;

Congratulations on re-inventing Cpart.  :^)

--Brent Dax [EMAIL PROTECTED]
@roles=map {Parrot $_} qw(embedding regexen Configure)

If you want to propagate an outrageously evil idea, your conclusion
must be brazenly clear, but your proof unintelligible.
--Ayn Rand, explaining how today's philosophies came to be





Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Michael Lazzaro
On Tuesday, January 7, 2003, at 08:14  PM, Damian Conway wrote:

Just when you thougth it was safe to go back on the mailing list,
Damian attempts to resurrect a dead can of worms:

And all because Mike Lazzaro wrote:


OK, but let it be known that the resulting megathread is now _your_ 
fault, not mine.  :-)  I have enough blamed on me.

That way, everything is still a method call, the ultra-low precedence 
of
~ and ~ eliminate the need for parens, and (best of all) the 
expressions
actually *look* like processing sequences.

I too think this idea is fabulous.  You are my hero.

Let the record show that I came back to 50+ messages this morning, in 
which nearly *all* were agreeing with each other, in this thread and 
all the others.  Wow.  :_)

MikeL



Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Austin Hastings
--- Jonathan Scott Duff [EMAIL PROTECTED] wrote:
 On Wed, Jan 08, 2003 at 05:14:06PM +0100, frederic fabbro wrote:
  I'm not even sure how that would parse, though that:
  @keep ~ grep /good/ ~ @list ~ grep /bad!/ ~ @throw;
  would go like:
  ( @keep ~ grep /good/ ~ @list ) ~ grep /bad!/ ~ @throw;
  
  which is probably not what i wanted...
 
 Oh, then we just need a syntax to split the streams.  ... I know!
 
   @list ~| grep /bad!/ ~ @throw ~| grep /good/ ~ @keep;
 
 which, of course, could be written in the more readable form:
 
   @list ~| grep /bad!/ ~ @throw 
 ~| grep /good/ ~ @keep;
 
 And that, of course, leads us to sort of unzip were mutual
 exclusion
 is not a requisite:
 
   @list ~| grep length == 1 ~ @onecharthings
 ~| grep [0..29] ~ @numberslessthan30
 ~| grep /^\w+$/ ~ @words
 ~| grep $_%2==0 ~ @evennumbers;
 
 :-)

Smiley aside, this is brilliant. It is nicely high-level (allowing for
parallelization/optimization behind the scenes), it reads nicely, and
it works as a high-leverage idiom.

I can see this as a nice basis for built-in threading below the level
of developer control. Also, it enables the two dimensional coding
that Damian likes.

And it doesn't have to be an array op. It could be a continuation op:


-$b |~ + sqrt($b ** 2 - 4*$a*$c) ~ $n1;
|~ - sqrt($b ** 2 - 4*$a*$c) ~ $n2;

(Yes, I know this would be a primo spot for a junction, but that's off
topic.)

So |~ does ~ except it remembers the LHS of the last invocation, if
one isn't provided (NOT the last ~, but the last |~).

Likewise ~| I guess, but what does it remember?

It could remember the object:

my WshObject $obj = $app.CreateObject($browser, $pfx); 
  MenuBar 0 ~| $obj;
  ToolBar 0 ~|;
   AddressBar 0 ~|;
 Height 600 ~|;
 Width  500 ~|;
  Visible 0 ~|;

Or it could remember the method:

my ($a, $b, $c, $d) = get_some_objects();
MethodCall $arg1, $arg2, $exp - $re + $ssion ~| $a;
 ~| $b;
 ~| $c;
 ~| $d;

Shiny! is right.

=Austin




RE: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Thom Boyer


-Original Message-
Rafael Garcia-Suarez [EMAIL PROTECTED] wrote:
 Actually I don't think you can define a grammar where two operators have
 the same precedence but different associativity. Be it a pure BNF
 grammar, or a classical yacc specification (using the %left and %right
 declarations).

You are correct in stating that in a classical yacc specification, you can't
declare two operators to have the same precedence but different
associativity. But that's because syntactically you can't express the idea.
You'd have to do something like
  %left PIPE_LEFT_OPERATOR
  %right PIPE_RIGHT_OPERATOR
Or you could put them in the opposite order. But, syntactically, they do
have to be on different lines, and that makes them have different
precedence.

However, you could have the following productions in a yacc grammar:

  exprB: exprA PIPE_LEFT_OPERATOR exprA
   | exprA PIPE_RIGHT_OPERATOR exprA  %PREC PIPE_LEFT_OPERATOR
   ;

(or something close to that -- it's been a while since I actually wrote yacc
grammars).

I assume that the generated parser would act in a manner similar to the way
it behaves when it catches you trying to chain together %nonassoc operators:
it generates a parse error. 

And given the fact that (IMHO)
  hello, world ~ print ~ STDERR;
is an abomination, a parse error would be just fine by me.

But cooler heads might just decree that the shift/reduce conflict is to be
resolved one way or another, so that
  A ~ B~ C~ O ~ X ~ Y ~ Z
parses as either
  (A ~B ~ C ~ O) ~ (X ~ Y ~ Z)
or
  (A ~B) ~ C) ~ (O ~ X ~ Y ~ Z)

Neither is likely to be what you want, however. And given the level of
difficulty that most people have with precedence and associativity rules, I
think it reasonable to require the parens if you want to mix ~ and ~ like
that.

=thom
There are 10 kinds of people in the world: 
those who understand binary, and those who don't.



Re: Pike 7.4

2003-01-08 Thread Chris Dutton
On Tuesday, January 7, 2003, at 11:20 PM, Damian Conway wrote:


Chris Dutton wrote:


Given discussions about hyper operators in the past, I found this 
rather interesting in the release notes.
http://pike.idonex.com/download/notes/7.4.10.xml

Interesting, but I still feel that vectorized operators give more 
flexibility.
For example, I'm struggling to see how one could use the [*] to do this:

	@names = «Gödel Escher Bach»;
	
	@ages = $today »-« %date_of_birth{@names}

While I agree that hyper-operators are the better way to go(though I can 
see advantages either way), I was bored, so I tried to figure out a not 
entirely unpleasant Perl6-ish version of the Pike syntax.

@ages[*] = $today - %date_of_birth{@names}.values[*]



Re: Array Questions

2003-01-08 Thread Michael Lazzaro

On Wednesday, January 8, 2003, at 02:17  AM, Damian Conway wrote:

Jonathan Scott Duff wrote:

On Tue, Jan 07, 2003 at 10:04:09AM -0800, Michael Lazzaro wrote:



Which, in turn, implies that the lines:

   my Foo $a; # (1)
   my $a is Foo;  # (2)
   my Foo $a is Foo;  # (3)

are all subtly different.  (2) and (3) (auto)instantiate a Foo, but 
(1) does not.
 Um ... ick.  I'd hope that autoinstantiation wouldn't happen 
without
some clear syntactical clue.  (I don't think is that clue.  To me
all three of those look like they should just earmark $a to contain a
Foo and this Foo-thing can/will be instantiated later)

I doubt it. The Cis Foo tells Perl that this variable is 
*implemented*
by a (hidden) Foo object. The variable better be able to get in touch 
with
that inner Foo at the point the variable is first used in any way. So
it probably needs to be autocreated at the point of declaration (or, at
least, trampolined into existance before the variable is first used).

Yes, I should have used something more clear than Foo, and it would 
have been more obvious what I was getting at:

my MyScalar $a;  # (1)
my $a is MyScalar;   # (2)
my MyScalar $a is MyScalar;  # (3)

(1) creates a scalar variable that may store a MyScalar value.
(2) creates an untyped variable in which the scalar variable $a is 
_implemented_ by an instance of class MyScalar.
(3) creates a variable that stores a MyScalar AND is implemented by an 
instance of class MyScalar.

Note that (3) is just plain sadistic.  My point was simply that 
scalars, like arrays and hashes, also should use the 'is' syntax to 
declare an implementor class, and that the implementor class is, by 
necessity, always autoinstanciated.

E.G. this is what our new Ctie syntax is gonna look like, fates 
willing.

MikeL



Re: Array Questions

2003-01-08 Thread Michael Lazzaro
On Wednesday, January 8, 2003, at 02:13  AM, Damian Conway wrote:

Michael Lazzaro wrote:

The remaining big question, then, is whether you can truly subclass 
Array to achieve Ctie-like behavior:
   class MyArray is Array { ... };
   my @a is MyArray;

Oh yes, I would certainly expect that this has to be possible.


OK, next question.  Is _THIS_ possible?

   class FileBasedHash is Hash { ...stuff... };

   my %data is FileBasedHash('/tmp/foo.txt');


And if _that's_ possible, is _THIS_ possible?

   my $path = '/tmp/foo.txt';
   my %data is FileBasedHash($path);


Sorry, but I gotta ask.  :-)

MikeL




Re: Array Questions

2003-01-08 Thread Chris Dutton
On Wednesday, January 8, 2003, at 01:32 PM, Michael Lazzaro wrote:


On Wednesday, January 8, 2003, at 02:13  AM, Damian Conway wrote:

Michael Lazzaro wrote:

The remaining big question, then, is whether you can truly subclass 
Array to achieve Ctie-like behavior:
   class MyArray is Array { ... };
   my @a is MyArray;

Oh yes, I would certainly expect that this has to be possible.


OK, next question.  Is _THIS_ possible?

   class FileBasedHash is Hash { ...stuff... };

   my %data is FileBasedHash('/tmp/foo.txt');


And if _that's_ possible, is _THIS_ possible?

   my $path = '/tmp/foo.txt';
   my %data is FileBasedHash($path);


Sorry, but I gotta ask.  :-)


I would ask, if it's possible to inherit from Array or Hash, is it 
possible to inherit from one which has a constrained storage type?

my WeirdHash is int Hash { ... }



Re: Array Questions

2003-01-08 Thread Michael Lazzaro

On Wednesday, January 8, 2003, at 10:39  AM, Chris Dutton wrote:

I would ask, if it's possible to inherit from Array or Hash, is it 
possible to inherit from one which has a constrained storage type?

my WeirdHash is int Hash { ... }

Yes, I think that was tentatively confirmed a while back.  But it would 
be spelled:

   class WierdHash is Hash of int { ... }

such that:

   my %h is WierdHash;   # automatically stores ints!

   my str %h is WierdHash;   # but this is probably an error


MikeL



Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Andy Wardley
Damian Conway wrote:
 [...] ~ and ~ 

Michael Lazzaro wrote:
 I too think this idea is fabulous.  You are my hero.

I also think this is semantically fabulous but syntactically slightly
dubious.  '~' reads 'match' in my book, so I'm reading the operators
as 'match left' and 'match right'.  Or perhaps even 'stringify left' 
and 'stringify right' with a different reading of '~'.

I would prefer something like | and | which has a more obvious
connotation (to me at least) of pipe left or pipe right.  

Damian is my hero regardless.  :-)

A




Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Nicholas Clark
 Actually I don't think you can define a grammar where two operators have
 the same precedence but different associativity. Be it a pure BNF
 grammar, or a classical yacc specification (using the %left and %right
 declarations).

But that would mean only perl6 could pass perl6, which isn't much different
from the perl5 situation, is it?
[Yes, I'm twisting things somewhat. the perl5 parser, written in C, can parse
perl5]

Although my brain thinks that having expressions with both ~ and ~ should
be illegal, because it's too damn confusing. Roughly:

~ ... ~   # My brain leaking out of my ears
~ ... ~   # My brain collapses because it's under too much pressure.

Nicholas Clark



Re: Variable Types Vs Value Types

2003-01-08 Thread Dan Sugalski
At 7:29 PM -0700 1/7/03, John Williams wrote:

On Tue, 7 Jan 2003, Dan Sugalski wrote:


 2. There is a primitive array type that is promoted to an
 objectified Array class when needed. This would be analogous
 to the int/Int distinction for primitive numbers. This would be
 visible to programmers, but may be acceptable for the same
 reason as the int/Int types are.

 Not unless Larry really insists. Primitive arrays aren't sub-,
 super-, or side-classes of objects--they aren't objects at all.
 (They're arrays, hence the name array) You may be able to treat
 them in some ways as objects, but that doesn't make them objects any
 more than treating arrays like integers makes them integers.


Perhaps you could explain how the $0 object will work in your mind.
A5 assert that $0 is a object, and it behaves as an array and a hash,
depending on how you subscript it.  Typeglobs are gone, and we're all
hoping the TIE interface is gone too, so how will this effect be
accomplished?


All variables in parrot are implemented as PMCs, and all PMCs may be 
accessed with a string, integer, or PMC subscript or set of 
subscripts. For PMCs that don't do subscripting this will be a fatal 
error, for those that do it'll do whatever the PMC is supposed to do. 
(In the case of $0, do the lookup)

If you really, really, really wanted to, you could consider PMCs as 
objects. You may have to squint really hard and paint them pink, 
but...that PMCs do is allow you to call a method on them, which we 
don't guarantee will work as we don't guarantee there's even a 
package associated with a PMC)
--
Dan

--it's like this---
Dan Sugalski  even samurai
[EMAIL PROTECTED] have teddy bears and even
  teddy bears get drunk


RE: perl6-lang Project Management

2003-01-08 Thread Thom Boyer
On Wednesday, November 06, 2002, at 11:54 AM, Michael Lazzaro wrote:
 On Tuesday, November 5, 2002, at 11:18  PM, Allison Randal wrote:
  Since you're interested in the management of the Perl 6 project, I'll
  let you in on some of it. Let's start with a step back into a bit of
  history:
 
 OK, let me pause for a second...  pause, pause, pause... OK, I'm better 
 now.  Please forgive me, I'm going to be quite forceful in my 
 evaluation of the situation here.  To the point of making a Simon C. 
 post look mellow.  Get ready for some spectacular virtual 
 coffee-mug-throwing here.

I'm replying to your coffee-mug-throwing posting *very* late simply because
I got so far behind on p6l that I had 1000 unread messages. Largely because
of the hellacious thread reworking operators. I just now got caught up to
November 6th.

I just want you to know how much I personally appreciate your efforts. I
agree that we need to be creating some unified description of the current
status. I'd be interested in helping, but one reading of your summary
convinced me that I can't write anywhere near as well as you do. And, of
course, it is discouraging to think about putting that much effort into a
language description when that language is shifting so wildly, often on a
day-to-day basis.

Now, just before Christmas, I archived my unread heap, and starting time
slicing between current postings and my archive. So I can see you're still
actively participating in p6l, and I'm glad to see that. I still have
November 6th-December 24th to read, so I don't yet know how others responded
to your outburst. But it made me realize two things: (1) I don't want you to
get discouraged, and (2) I haven't given you any feedback (let alone,
appreciative feedback).

You have been among the handful of posters whose messages I look forward to.
Your messages are a breath of fresh air -- an island of sanity -- amid the
quicksand shiftings of p6l. So please accept my thanks for the tremendous
amount of time and productive thought you are sharing with us.

And now, my unread pl6 archive has been reduced to 772 messages. Sigh. I
wish I could beat back my anal-retentive tendencies long enough to be
satisfied with the fine Piers Cawley summaries. But always want the
fine-grained detail, too

=thom
Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing.
  --Dr. Jubal Harshaw (Robert Heinlein's _To_Sail_Beyond_the_Sunset_)



Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Dave Whipp
Buddha Buck [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 and similarly,

 $a ~ ...;

 is equivalent to

 $a = ...;

But with the different precedence. At last, I can assign from a list without
using parentheses:

  @a = 1, 2, 3; # newbie error
  @a ~ 1, 2, 3; # would work


Something else springs to mind. Consider the Cfor syntax:

  for 1,2,3 ~ foo - $a { ... }

Is there any way we could unify these two operators without creating
ambiguities? If we
could, then using straight arrows would be nicer to type than the squiggly
ones.


Dave.





Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Rafael Garcia-Suarez
Nicholas Clark wrote in perl.perl6.language :
 Actually I don't think you can define a grammar where two operators have
 the same precedence but different associativity. Be it a pure BNF
 grammar, or a classical yacc specification (using the %left and %right
 declarations).
 
 But that would mean only perl6 could pass perl6, which isn't much different
 from the perl5 situation, is it?

I meant that if ~ and ~ are going to have the same precedence, you
can't parse
s ~ t ~ u
It's not a well formed phrase of the language (even though this language
can't described by a nonambiguous BNF grammar.)

In fact, this is different from the Perl 5 situation you're alluding to.



Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Rafael Garcia-Suarez
Dave Whipp wrote in perl.perl6.language :
 But with the different precedence. At last, I can assign from a list without
 using parentheses:
 
   @a = 1, 2, 3; # newbie error
   @a ~ 1, 2, 3; # would work

or :
@a ~ 1 ~ 2 ~ 3;

or :
1, 2, 3 ~ @a;
which would be also written as :
3 ~ 2 ~ 1 ~ @a;
shoot me :
3 ~ 2 ~ @a ~ 1;
(Aha, Damian's 1st proposal seems to imply that ~ has highest precedence
than ~).



Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Buddha Buck
Dave Whipp wrote:


Something else springs to mind. Consider the Cfor syntax:

  for 1,2,3 ~ foo - $a { ... }

Is there any way we could unify these two operators without creating
ambiguities? If we
could, then using straight arrows would be nicer to type than the squiggly
ones.


I think I see what you're saying...

$a ~ foo;

calls foo on $a, while

  $a - $x { ... }

um, does nothing...  OK, I didn't see what I thought I said.

Actually, I do see something like:

  $a ~ - $x { ... }

as having meaning, namely call the anon sub with $a as an argument.

Does syntax already exist for doing that?  Can one do:

  - $x { ... } ($a);

already?

If not, then the ~ - construct has a use, perhaps a semi-common use, 
and perhaps it should be simplified.  Not to suggest another operator 
here, but $a ~- $x { ... } anyone?

But you were looking for a way to play off their similar meanings to 
avoid having to use a tilde

The BNF for anonymous subs is something like (I haven't read the 
existing grammars, so if I'm not using the standard terms...sorry):

anon_sub :== sub block
   | sub ( paramlist ) block
   | - block
   | - paramlist block

The BNF for left-to-right pipelines would be something like:

lr_pipe :== lr_pipe ~ variable
  | lr_pipe ~ function_call

If we were to combine - and ~, would it lead to any ambiguity?  I'm 
not sure.  Certainly we'd be talking about more than a one-token lookahead.

Actually, I'm not sure the lr_pipe is unambiguous in its own right.  I 
don't have it complete, obviously, but I see problems with the two calls 
as is...

What is the result of:

  $input ~ %functionTable{$state} ~ $state;

Is it equivalent to:

%functionTable($state) = $input;
$state = %functionTable($state);

or

$state = %functionTable($state).($input);

How does the grammar differentiate between the two?

Or would I have to type

  $input ~ %functionTable{$state}.() ~ $state;

instead?







Dave.












Re: Pike 7.4

2003-01-08 Thread Mr. Nobody
--- Damian Conway [EMAIL PROTECTED] wrote:
 Chris Dutton wrote:
 
  Given discussions about hyper operators in the past, I found this 
  rather interesting in the release notes.
  
  http://pike.idonex.com/download/notes/7.4.10.xml
 
 Interesting, but I still feel that vectorized operators give more
 flexibility.
 For example, I'm struggling to see how one could use the [*] to do this:
 
   @names = «Gödel Escher Bach»;
   
   @ages = $today »-« %date_of_birth{@names}
 
 Damian
 
 

We can't use « or ». Not only are they impossible to type on some editors,
but they're different in CP437 (the DOS charset), Latin1, and UTF8.


__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Mr. Nobody
--- Luke Palmer [EMAIL PROTECTED] wrote:
  Date: Wed, 08 Jan 2003 12:14:10 +0800
  From: Damian Conway [EMAIL PROTECTED]
  
  Can I suggest that an alternative solution might be the following:
  
   Suppose Perl 6 had two new very low precedence operators: ~ and ~
   (a.k.a. bind rightwards and bind leftwards)
  
   Suppose ~ takes its left argument and binds it to
   the end of the argument list of its right argument,
   then evaluates that right argument and returns the result.
   So an L2R array-processing chain is:
  
   @out = @a ~ grep {...} ~ map {...} ~ sort;
  
   There might also be a be special rule that, if the RHS is
   a variable, the LHS is simply assigned to it. Allowing:
  
   @a ~ grep {...} ~ map {...} ~ sort ~ @a;
  
   Further suppose that ~ takes its right argument, and binds
   it in the indirect object slot of the left argument, which
   argument it then calls. So an R2L array-processing chain is:
  
   @out = sort ~ map {...} ~ grep {...} ~ @a;
  
   Or, under a special rule for variables on the LHS:
  
   @out ~ sort ~ map {...} ~ grep {...} ~ @a;
  
  That way, everything is still a method call, the ultra-low precedence of
  ~ and ~ eliminate the need for parens, and (best of all) the
 expressions
  actually *look* like processing sequences.
 
 I think this is a big step towards readability.  It allows you to put
 whatever part of the expression wherever you want (reminiscent of
 Latin); i.e. always keep the important parts standing out.  I also
 think that the operator (especially a cool 3d-looking one like ~) is
 also much more readable than a word in this case. 

I don't like either of these operators. What's wrong with @out = sort map
{...} grep {...} @a?

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



Re: L2R/R2L syntax (was Re: Everything is an object.)

2003-01-08 Thread Damian Conway
Trey Harris wrote:


I love this.

And any class could override the ~ operator, right?


Right.



I suppose it could be done like arithmetic
overloading, if you define both ~ (I'm being pointed at from the right)
and ~ (I'm being pointed at from the left) in your class then Perl will
use whichever appears in code, but if you define just one, Perl will use
it for both.


H. Maybe. I'm not certain that Perl 6 operator overloading will be as
highly dwimical as Perl 5's is.

Damian





This week's summary

2003-01-08 Thread p6summarizer
The Perl 6 Summary for the week ending 20030105
Hello and welcome to the first summary of 2003, welcome to the future.
This summary covers 2 weeks, but they've been quietish what with
Christmas and the New Year.

So, starting as usual with perl6-internals

  A pile of patches to the Perl 6 compiler
Joseph F. Ryan submitted a bunch of patches to the Perl 6 mini compiler,
(found in the languages/perl6 subdirectory of your friendly
neighbourhood parrot distribution) mostly implementing the the semantics
for string and numeric literals discussed on perl6-documentation.

  Garbage Collection headaches
Heads have been put together in an attempt to get Parrot's Garbage
Collection system working efficiently and accurately (no destroying
stuff before anyone's had a chance to use it, dammit!) It appears that
there's still a good deal of head scratching to be done in this area
(the chaps over on the LL1 list are wondering why we aren't just using
the Boehm GC system...)

I freely admit that GC makes my head hurt (especially as, in my current
Perl 5 project I'm busy implementing mark and sweep collection for a
persistent object store whilst also making sure that my random
assortment of circular data structures has weakened references in just
the right places so that stuff gets destroyed but only when it *should*
be destroyed... Boy, am I looking forward to Perl 6 and not having to
worry about this stuff ever again...) but I I'll have a go at
summarizing the issues.

The main problem appears to be that of 'Infant mortality', an issue that
I will now attempt to explain.

All the objects in memory can be represented as nodes in a graph, and
the pointers between those objects can be represented as edges in that
graph. The process of garbage collection involves taking a subset of
those nodes (the rootset) and freeing (or marking as freeable) all those
nodes in the graph which are not reachable from the rootset.

Now, consider a function that sets up a new PMC, specifically a PMC that
contains another PMC. The first step is grab the memory for our new PMC.
Next we create the contained PMC, a process which allocates more
memory... and there's the rub. Garbage Collection can get triggered at
any point where we go to allocate more memory; unless the *containing*
PMC is reachable from the rootset then it will get freed at the point.
And that leads to badness. So the Infant Mortality problem can also be
thought of as the problem of rootset maintenance. Which is, in theory,
simple; just treat all C variables as members of the rootset. However,
in practice it isn't that simple, mostly because hardware registers
complicate the issue.

Steve Fink offered an overview of the issues and some of the possible
approaches to dealing with them, which sparked a fair amount of
discussion amongst those who understood the issues.

http://makeashorterlink.com/?K2FE52303

http://makeashorterlink.com/?Y20F32303 -- Steve's overview

  Variable/value vtable split
Leo Tötsch posted a summary of where we stand on doing the
variable/value vtable split, suggesting that he wanted to start feeding
in patches soon. Mitchell N Charity supplied a handy dandy 'context'
post with links to appropriate articles, and he and Leo did a certain
amount of thrashing out of issues.

http://makeashorterlink.com/?B11F21303

http://makeashorterlink.com/?G12F32303

  Parrot gets another new language
Ook! Jerome Quelin offered an implementation of the latest silly
language, Ook! which can be thought of as brainf.ck for Librarians. Due
to insanity, the Ook! compiler is implemented in Parrot assembly, and
emits parrot assembly too, which led Jerome to ask for an 'eval' opcode.
Which Leo promised to supply. And which Dan specced out in PDD6. All of
which led Leo to comment that, for all these languages are toys, they do
seem to be driving the implementation of important bits of Parrot.
Nicholas Clark reminded everyone that a zcode interpreter would be
another good thing to have a crack at because it would require a couple
of other really useful bits of Parrot functionality. Ook! is now in the
core.

http://makeashorterlink.com/?R53F23303

  Returning new PMCs
David Robins wondered what was the resolution about creating and
returning a new PMC in PMC ops that take a PMC* dest parameter. He and
Dan discussed it back and forth and it became apparent that Dan really
needs to get Parrot Objects defined...

http://makeashorterlink.com/?Q24F21303

  Fun with PerlHash
Jerome Quelin noticed that you couldn't delete an item from a PerlHash.
Leo fixed it. Jerome later asked how one could retrieve the keys of a
PerlHash in Parrot assembly and wondered if there was a way to traverse
a hash. Sadly the