Re: trait and properties thru getter/setters

2005-05-14 Thread mark . a . biggar
I don't understand why you think you need the eval here? -- Mark Biggar [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED] > There is syntax to define trait and properties > but is there an API? > > my $b = eval '$a but true'; # setting a true property > # API to do it without an eval? >

Re: Plethora of operators

2005-05-14 Thread Adam Kennedy
[»+^=«] reminds me of a P5 regex that has a comment saying "This is black magic. Don't touch!". --That's-- my complaint. Indeed. There's a time and a place for that sort of black magic, and it's usually about once per 5,000 lines of code, and so deep and well wrapped in comments and unit tests th

Re: ^method ?

2005-05-14 Thread Adam Kennedy
Autrijus Tang wrote: Juerd informed me today that .method should still means $_.method. However, for the OO modules we're writing, there still needs to be a way to invoke methods on the current invocant, when the invocant name has been omitted from the method() declaration. Currently Pugs has:

Re: ^method ?

2005-05-14 Thread Adam Kennedy
The obvious way to do it is to declare the invocant. Wasn't one of the original headline features for Perl 6 not having to do that any more for basic normal code? Or at least from a couple of damian talks it was one of the things that practically _everybody_ wanted. On the plus side, with explic

Re: ^method ?

2005-05-14 Thread Luke Palmer
On 5/14/05, Adam Kennedy <[EMAIL PROTECTED]> wrote: > I don't mean to be disrespectful, but what was whoever suggested ^ > thinking? Well I suggested backtick in the same role *duck*. > For starters, about the only combination harder to hit with on > spanned hand might be ctrl-F5. I've remapped

Re: ^method ?

2005-05-14 Thread Damian Conway
Luke wrote: > If the alternatives are: > > * declare $self, use $self.method, and .method for calling on $_ > * use .method, and use $_.method for calling on $_ > > I'd say the former has no case. I, for one, am not nearly so certain of that. Our original rationale for that choice was not c

Re: ^method ?

2005-05-14 Thread Juerd
Firstly, thanks for writing the message out so clearly that it cannot be misunderstood. Damian Conway skribis 2005-05-14 22:06 (+1000): > .{width} //= 80; > .{height}//= 24; > .{gutter}//= 4; > .{justification} //= 'left'; > .{availa

Re: Plethora of operators

2005-05-14 Thread Damian Conway
Adam Kennedy wrote: And reduction? I write 25,000+ lines of Perl a year, and if you are talking about something like List::Util::reduce, I think I've used it maybe twice? Which proves what? That you don't (yet) write the sort of code that benefits from reductions? That you don't (yet) think in t

Re: Object Numify/Stringify-ing to Unique values

2005-05-14 Thread Leopold Toetsch
Autrijus Tang <[EMAIL PROTECTED]> wrote: > What does unboxed values return for their "id", though? > 3 =:= 3; # always true? > 3.id ~~ 3.id; # ditto? Maybe true or not, that's highly implementation dependent. I'd not touch these internals: $ python Python 2.4 [...] >>> id(2) ==

Re: Plethora of operators

2005-05-14 Thread Herbert Snorrason
On 14/05/05, Damian Conway <[EMAIL PROTECTED]> wrote: > Here are a few of the things I'll be using reductions for in Perl 6... > > 1. To add things up: > > $sum = [+] @amounts; > > 2. To calculate the probability that I'll need to use a reduction today: > > $fi

Re: Plethora of operators

2005-05-14 Thread Juerd
Damian Conway skribis 2005-05-14 22:56 (+1000): >$leaf_value = [.{}] %hash, @keys; >$propped = [but] $value, @properties; With the precedence of [op] being that of a normal list op, the above are a problem. Perhaps ; or multiple <== can solve this? Juerd -- http://convol

Re: Plethora of operators

2005-05-14 Thread Eirik Berg Hanssen
Juerd <[EMAIL PROTECTED]> writes: > Damian Conway skribis 2005-05-14 22:56 (+1000): >>$leaf_value = [.{}] %hash, @keys; >>$propped = [but] $value, @properties; > > With the precedence of [op] being that of a normal list op, the above > are a problem. Perhaps ; or multiple <

Re: Plethora of operators

2005-05-14 Thread Jonathan Scott Duff
On Sat, May 14, 2005 at 10:56:29PM +1000, Damian Conway wrote: > 3. To drill down a hierarchical data structure, following the path >specified by a list of keys: > >$leaf_value = [.{}] %hash, @keys; I think this one needs to be written as: $leaf_value = [.{}] \%ha

The [] metaoperator

2005-05-14 Thread Autrijus Tang
On Sat, May 14, 2005 at 10:56:29PM +1000, Damian Conway wrote: > 8. To verify the monotonicity of a sequence: > >$is_monotonic = [<] @numbers; Hey. Does this mean that the [] metaoperator folds with the associativity of the operator inside it? That is, if the operator inside is

Re: Plethora of operators

2005-05-14 Thread Juerd
Eirik Berg Hanssen skribis 2005-05-14 16:22 (+0200): > > With the precedence of [op] being that of a normal list op, the above > > are a problem. Perhaps ; or multiple <== can solve this? > I suppose the first must just make sure not to flatten the %hash: > $leaf_value = [.{}] \%hash, @keys; # %h

Re: Plethora of operators

2005-05-14 Thread Uri Guttman
> "DC" == Damian Conway <[EMAIL PROTECTED]> writes: DC> Here are a few of the things I'll be using reductions for in Perl 6... DC> 3. To drill down a hierarchical data structure, following the path DC> specified by a list of keys: DC> $leaf_value = [.{}] %has

Re: Plethora of operators

2005-05-14 Thread Juerd
Jonathan Scott Duff skribis 2005-05-14 9:49 (-0500): > Then surely $leaf = [.{}] %hash, $k1, $k2, $k3 > is the same as$leaf = %hash .{} $k1 .{} $k2 .{} $k3 Then perhaps the easy way out is to make .{} $key and .[] $index valid syntax. Or perhaps [] can play the role of

Re: Plethora of operators

2005-05-14 Thread Markus Laire
Adam Kennedy kirjoitti: [»+^=«] reminds me of a P5 regex that has a comment saying "This is black magic. Don't touch!". --That's-- my complaint. I look at... >>but the basic operator there is just ^, with a + modifier to indicate >>numeric XOR, = to indicate an assignment operator, »« to indicate

Re: Plethora of operators

2005-05-14 Thread Juerd
Markus Laire skribis 2005-05-14 18:07 (+0300): > [>>+^=<<] (@a, @b, @c) These arrays flatten first (otherwise [+] @foo could never calculate the sum of the elements), so imagine that you have Juerd -- http://convolution.nl/maak_juerd_blij.html http://convolution.nl/make_juerd_happy.html ht

Re: Plethora of operators

2005-05-14 Thread Juerd
Juerd skribis 2005-05-14 17:23 (+0200): > Markus Laire skribis 2005-05-14 18:07 (+0300): > > [>>+^=<<] (@a, @b, @c) > These arrays flatten first (otherwise [+] @foo could never calculate the > sum of the elements), so imagine that you have $foo, $bar, $baz, $quux, $xyzzy to let >>+^=<< op

Re: The [] metaoperator

2005-05-14 Thread Larry Wall
On Sat, May 14, 2005 at 10:53:38PM +0800, Autrijus Tang wrote: : On Sat, May 14, 2005 at 10:56:29PM +1000, Damian Conway wrote: : > 8. To verify the monotonicity of a sequence: : > : >$is_monotonic = [<] @numbers; : : Hey. Does this mean that the [] metaoperator folds with the :

Re: Object Numify/Stringify-ing to Unique values

2005-05-14 Thread Larry Wall
On Sat, May 14, 2005 at 02:57:53PM +0200, Leopold Toetsch wrote: : If we want some interoperbility with Python dicts, hashing will not be : done on ids but on the hash function of the type. Which Perl could default to id. Larry

Re: ^method ?

2005-05-14 Thread Larry Wall
On Sat, May 14, 2005 at 02:17:38PM +0200, Juerd wrote: : Firstly, thanks for writing the message out so clearly that it cannot be : misunderstood. : : Damian Conway skribis 2005-05-14 22:06 (+1000): : > .{width} //= 80; : > .{height}//= 24; : > .{gutter}

Re: ^method ?

2005-05-14 Thread Larry Wall
On Sat, May 14, 2005 at 04:22:44PM +1000, Adam Kennedy wrote: : >The obvious way to do it is to declare the invocant. : : Wasn't one of the original headline features for Perl 6 not having to do : that any more for basic normal code? Or at least from a couple of damian : talks it was one of the

Re: Plethora of operators

2005-05-14 Thread Jonathan Scott Duff
On Sat, May 14, 2005 at 05:05:10PM +0200, Juerd wrote: > Jonathan Scott Duff skribis 2005-05-14 9:49 (-0500): > > Then surely $leaf = [.{}] %hash, $k1, $k2, $k3 > > is the same as $leaf = %hash .{} $k1 .{} $k2 .{} $k3 > > Then perhaps the easy way out is to make .{} $key and

Re: The [] metaoperator

2005-05-14 Thread Juerd
Larry Wall skribis 2005-05-14 8:29 (-0700): > : say [x]; > : Is it a repeating metaoperator on an empty list, or a single-element > : array reference that contains the return value of calling &x()? > Always the first. [x] doesn't have to do lookahead. Does this mean that [x] is just an inter

Re: Plethora of operators

2005-05-14 Thread Larry Wall
On Sat, May 14, 2005 at 10:55:43AM -0500, Jonathan Scott Duff wrote: : But perhaps the reduce operator is some of that sufficiently advanced : technology that "knows" how the operator it wraps is slotted and does : something appropriate. Possibly. Or we just define infix .{}. and .[]. variants,

junctions vs English negatives.

2005-05-14 Thread Larry Wall
We have a bit of a problem with negative operators applied to junctions, as illustrated recently on PerlMonks. To wit, when a native English speaker writes if $a != 1 | 2 | 3 {...} they really mean one of: if not $a == 1 | 2 | 3 {...} if $a == none(1, 2, 3) {...} or, expressed in

Re: Plethora of operators

2005-05-14 Thread Jonathan Scott Duff
On Sat, May 14, 2005 at 09:20:21AM -0700, Larry Wall wrote: > On Sat, May 14, 2005 at 10:55:43AM -0500, Jonathan Scott Duff wrote: > : But perhaps the reduce operator is some of that sufficiently advanced > : technology that "knows" how the operator it wraps is slotted and does > : something approp

Re: Plethora of operators

2005-05-14 Thread Juerd
Larry Wall skribis 2005-05-14 9:20 (-0700): > Possibly. Or we just define infix .{}. and .[]. variants, or some such. The problem is that we already have @foo[] meaning the same as @foo, and an always allowed . that also allows you to put whitespace around it. This means that %foo.{}.$kv should

Re: BEGIN and lexical variables inside subroutines

2005-05-14 Thread Larry Wall
On Fri, May 13, 2005 at 04:21:25PM +0200, "TSa (Thomas Sandlaß)" wrote: : And I hope that it is not possible to accidentially : mess up the internals of the compiler because code : in a BEGIN hits compiler data. Whereas I hope that it *is* possible to intentionally mess up the internals of the com

Re: Plethora of operators

2005-05-14 Thread Larry Wall
On Sat, May 14, 2005 at 06:41:35PM +0200, Juerd wrote: : Larry Wall skribis 2005-05-14 9:20 (-0700): : > Possibly. Or we just define infix .{}. and .[]. variants, or some such. : : The problem is that we already have @foo[] meaning the same as @foo, and : an always allowed . that also allows you

Re: junctions vs English negatives.

2005-05-14 Thread Jonathan Scott Duff
On Sat, May 14, 2005 at 09:31:29AM -0700, Larry Wall wrote: > I don't think we can allow this situation to stand. Either we have > to make != and !~ and ne transform themselves via "not raising", or > we have to disallow negative comparisons on junctions entirely. I'm of the opinion that disallow

Re: Plethora of operators

2005-05-14 Thread Rod Adams
Larry Wall wrote: On Sat, May 14, 2005 at 06:41:35PM +0200, Juerd wrote: : Larry Wall skribis 2005-05-14 9:20 (-0700): : > Possibly. Or we just define infix .{}. and .[]. variants, or some such. : : The problem is that we already have @foo[] meaning the same as @foo, and : an always allowed . th

Re: junctions vs English negatives.

2005-05-14 Thread Rod Adams
Larry Wall wrote: We have a bit of a problem with negative operators applied to junctions, as illustrated recently on PerlMonks. To wit, when a native English speaker writes if $a != 1 | 2 | 3 {...} they really mean one of: if not $a == 1 | 2 | 3 {...} if $a == none(1, 2, 3) {...} or, e

Re: Plethora of operators

2005-05-14 Thread Larry Wall
On Sat, May 14, 2005 at 12:51:32PM -0500, Rod Adams wrote: : Larry Wall wrote: : : >On Sat, May 14, 2005 at 06:41:35PM +0200, Juerd wrote: : >: Larry Wall skribis 2005-05-14 9:20 (-0700): : >: > Possibly. Or we just define infix .{}. and .[]. variants, or some : >such. : >: : >: The problem is

Re: Plethora of operators

2005-05-14 Thread Rod Adams
Larry Wall wrote: On Sat, May 14, 2005 at 12:51:32PM -0500, Rod Adams wrote: : Unless, of course, there is some subtle difference between a 3-d hash : and a hash of hashes of hashes that invalidates this. No difference, I hope. The multidimensional notation is meant to extend to HoH and AoA tran

Re: Plethora of operators

2005-05-14 Thread Larry Wall
On Sat, May 14, 2005 at 01:36:22PM -0500, Rod Adams wrote: : Larry Wall wrote: : : >On Sat, May 14, 2005 at 12:51:32PM -0500, Rod Adams wrote: : > : >: Unless, of course, there is some subtle difference between a 3-d hash : >: and a hash of hashes of hashes that invalidates this. : > : >No differ

Re: Plethora of operators

2005-05-14 Thread Rob Kinyon
On 5/14/05, Larry Wall <[EMAIL PROTECTED]> wrote: > On Sat, May 14, 2005 at 01:36:22PM -0500, Rod Adams wrote: > : Larry Wall wrote: > : > : >On Sat, May 14, 2005 at 12:51:32PM -0500, Rod Adams wrote: > : > > : >: Unless, of course, there is some subtle difference between a 3-d hash > : >: and a ha

Re: Plethora of operators

2005-05-14 Thread Rod Adams
Rob Kinyon wrote: So, does this mean that I can do something like: @a = [ 1 .. 4 ]; $x = @a{2}; and have $x == 3? If so, is there any reason (other than clarity) to use the @a[] notation? The @ already indicates you have an array vs. the % which indicates hash. Is there a reason to have the subsc

Re: C<::> in rules

2005-05-14 Thread Patrick R. Michaud
On Fri, May 13, 2005 at 01:07:20PM -0700, Larry Wall wrote: > On Fri, May 13, 2005 at 11:54:47AM -0500, Patrick R. Michaud wrote: > : $r1 = rx / abc :: def | ghi :: jkl | mn :: op /; > : $r2 = rx / abc ::: def | ghi ::: jkl | mn ::: op /; > : $r3 = rx / [ abc :: def | ghi :: jkl | mn ::

Re: Plethora of operators

2005-05-14 Thread Brent 'Dax' Royal-Gordon
Damian Conway <[EMAIL PROTECTED]> wrote: > 3. To drill down a hierarchical data structure, following the path > specified by a list of keys: > > $leaf_value = [.{}] %hash, @keys; When I saw this, the following happened. *pause for a second* "Wow." *a few more seconds* "H

Re: ^method ?

2005-05-14 Thread Brent 'Dax' Royal-Gordon
Damian Conway <[EMAIL PROTECTED]> wrote: > [an extremely well-thought-out explanation] Thank you, Dr. Conway. That was very enlightening, and I think I agree with all of it. Larry Wall <[EMAIL PROTECTED]> wrote: > You guys are all ignoring that I said it could be set via pragma or macro. > If yo

Re: Plethora of operators

2005-05-14 Thread Juerd
Larry Wall skribis 2005-05-14 9:45 (-0700): > : OTOH, reduce probably just needs to be smart enough to understand > : postcircumfix. Perhaps whitespace helps, [{ }], in parallel with > : &postcircumfix:<{ }>, to avoid a conflict with an infix {}. > Erm, I don't like tokens with spaces in the middl

Re: junctions vs English negatives.

2005-05-14 Thread Damian Conway
Larry wrote: I don't think we can allow this situation to stand. Either we have to make != and !~ and ne transform themselves via "not raising", or we have to disallow negative comparisons on junctions entirely. Opinions? Making them DWIM here would be a mistake, since the dwimmery would disappear

gravity defying \

2005-05-14 Thread Aaron Sherman
On Sat, 2005-05-14 at 16:22 +0200, Eirik Berg Hanssen wrote: > I suppose the first must just make sure not to flatten the %hash: > > $leaf_value = [.{}] \%hash, @keys; # %hash .{$key1} . {$key2} ... Side point on the whole topic: I just LOVE \ as an explosive list- context flattening preventer

Re: ^method ?

2005-05-14 Thread Jonathan Worthington
"Brent 'Dax' Royal-Gordon" <[EMAIL PROTECTED]> wrote: Like the decision about which side of the road cars should drive on, it really doesn't matter *which* choice is taken, as long as *something* is decided. The only thing is, there already is a decided way to do it so far as I can see... I've s

Re: Plethora of operators

2005-05-14 Thread Damian Conway
Larry wrote: Actually, I think Damian's original formulation is sufficiently clear. Me too! ;-) I think that a standard [.] abbreviation for all postcircumfix operators within [op] reductions would be a useful bit of dwimmery. Damian

Re: ^method ?

2005-05-14 Thread Rod Adams
Jonathan Worthington wrote: "Brent 'Dax' Royal-Gordon" <[EMAIL PROTECTED]> wrote: Like the decision about which side of the road cars should drive on, it really doesn't matter *which* choice is taken, as long as *something* is decided. The only thing is, there already is a decided way to do it so f

Re: ^method ?

2005-05-14 Thread Juerd
Rod Adams skribis 2005-05-14 19:21 (-0500): > $?SELF, and nothing else by default. Wrong because it's inconsistent. Nothing else defaults to $?SELF. > $_ bound to $?SELF at start of method. Current spec. > o. > O. > this. > self. > me. Not special syntax, meaning you can no longer use these id

Re: ^method ?

2005-05-14 Thread Rod Adams
Juerd wrote: Rod Adams skribis 2005-05-14 19:21 (-0500): o. O. this. self. me. Not special syntax, meaning you can no longer use these identifiers for your own class. Bad style to use single-letter identifiers, but we know what trouble $a and $b in Perl 5 cause, and the B:: namespace. I bel

Re: ^method ?

2005-05-14 Thread Rob Kinyon
On 5/14/05, Rod Adams <[EMAIL PROTECTED]> wrote: > Jonathan Worthington wrote: > > > "Brent 'Dax' Royal-Gordon" <[EMAIL PROTECTED]> wrote: > > > >> Like the decision about which side of the road cars should drive on, > >> it really doesn't matter *which* choice is taken, as long as > >> *something

Re: ^method ?

2005-05-14 Thread Aaron Sherman
On Sat, 2005-05-14 at 22:06 +1000, Damian Conway wrote: > Luke wrote: > > > If the alternatives are: > > > > * declare $self, use $self.method, and .method for calling on $_ > > * use .method, and use $_.method for calling on $_ > > > > I'd say the former has no case. > > I, for one

Re: Plethora of operators

2005-05-14 Thread Stuart Cook
On 5/15/05, Juerd <[EMAIL PROTECTED]> wrote: > How does [EMAIL PROTECTED] know the difference between &postcircumfix: > and > &postcircumfix:? Perhaps it checks how many different variations are actually defined--if it finds only one, it can DWIM, and if it finds more than one it can barf with an