Re: Junction Values

2005-02-20 Thread Nigel Sandever
On Sat, 19 Feb 2005 18:42:36 +1100, [EMAIL PROTECTED] (Damian Conway) wrote: the Awesome Power of Junctions: As I tried to express elsehwere, this what I'm looking for. Instinctively, and for a long time since I first came across Q::S, I thought that the killer app of Junctions is there

Re: Junction Values

2005-02-20 Thread Damian Conway
Rod Adams asked: This sound reasonable enough? Frankly, no. ;-) Sorry, but your latest proposal sounds complex, multiply special-cased, and way too much of an imposition on the programmer (which is specifically what junctions are supposed to avoid). I'm going to continue to strongly recommend

Re: Junction Values

2005-02-20 Thread Rod Adams
Nigel Sandever wrote: On Sat, 19 Feb 2005 18:42:36 +1100, [EMAIL PROTECTED] (Damian Conway) wrote: The Awesome Power of Junctions: As I tried to express elsehwere, this what I'm looking for. Instinctively, and for a long time since I first came across Q::S, I thought that the killer app of

Re: Junction Values

2005-02-20 Thread Rod Adams
Damian Conway wrote: Rod Adams asked: This sound reasonable enough? Frankly, no. ;-) Sorry, but your latest proposal sounds complex, multiply special-cased, and way too much of an imposition on the programmer (which is specifically what junctions are supposed to avoid). Funny. I thought it was

Re: Set sigils (was: Re: Junction Values)

2005-02-20 Thread Patrick R. Michaud
On Sat, Feb 19, 2005 at 01:43:57PM -0800, Ashley Winters wrote: Instead of primary sigils, what about secondary sigils on an array to mark it as an unordered set? @|foo = any @foo = all @^foo = one # can arrays be curried arguments? hmm @!foo = none After all, why should scalars get

Re: Junction Values

2005-02-20 Thread Nigel Sandever
On Sun, 20 Feb 2005 03:17:19 -0600, [EMAIL PROTECTED] (Rod Adams) wrote: --020209010404060902000407 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Nigel Sandever wrote: On Sat, 19 Feb 2005 18:42:36 +1100, [EMAIL PROTECTED] (Damian

Re: Junction Values

2005-02-20 Thread Eirik Berg Hanssen
Rod Adams [EMAIL PROTECTED] writes: $re1 = /^ -[x]* x -[x]* $/; # match a string with exactly one 'x' in it. $re2 = /^ -[y]* y -[y]* $/; # ditto 'y' $re3 = /^ -[z]* z -[z]* $/; # ditto 'z' $re7 = none($re1, $re2, $re3); # matches if there are 0 or 2+ of each of x,y,z.

Re: Junction Values

2005-02-20 Thread Nicholas Clark
On Sun, Feb 20, 2005 at 07:41:16PM +1100, Damian Conway wrote: Given this: my $x = set(1..3); my $y = set(1,3,5,7,9); my $n = 2; $x | $y # set(1,2,3,5,7,9) $x $y # set(1,3) $x - $y # set(2) !$x #

Re: Junction Values

2005-02-20 Thread Eirik Berg Hanssen
Rod Adams [EMAIL PROTECTED] writes: Eirik Berg Hanssen wrote: Rod Adams [EMAIL PROTECTED] writes: $re1 = /^ -[x]* x -[x]* $/; # match a string with exactly one 'x' in it. $re2 = /^ -[y]* y -[y]* $/; # ditto 'y' $re3 = /^ -[z]* z -[z]* $/; # ditto 'z' $re7 = none($re1,

Re: Junction Values

2005-02-20 Thread Uri Guttman
NC == Nicholas Clark [EMAIL PROTECTED] writes: NC On Sun, Feb 20, 2005 at 07:41:16PM +1100, Damian Conway wrote: NC Given this: my $x = set(1..3); my $y = set(1,3,5,7,9); my $n = 2; $x | $y # set(1,2,3,5,7,9) $x $y # set(1,3) $x - $y # set(2) !$x

Re: Junction Values

2005-02-20 Thread Damian Conway
Nicholas Clark wrote: On Sun, Feb 20, 2005 at 07:41:16PM +1100, Damian Conway wrote: Given this: my $x = set(1..3); my $y = set(1,3,5,7,9); my $n = 2; $x | $y # set(1,2,3,5,7,9) $x $y # set(1,3) $x - $y # set(2) !$x

Re: Junction Values

2005-02-20 Thread Eirik Berg Hanssen
Eirik Berg Hanssen [EMAIL PROTECTED] writes: Rod Adams [EMAIL PROTECTED] writes: Eirik Berg Hanssen wrote: Rod Adams [EMAIL PROTECTED] writes: $re1 = /^ -[x]* x -[x]* $/; # match a string with exactly one 'x' in it. $re2 = /^ -[y]* y -[y]* $/; # ditto 'y' $re3 = /^ -[z]* z -[z]*

Re: Junction Values

2005-02-20 Thread Patrick R. Michaud
On Sun, Feb 20, 2005 at 10:46:15PM +0100, Eirik Berg Hanssen wrote: Eirik Berg Hanssen [EMAIL PROTECTED] writes: Rod Adams [EMAIL PROTECTED] writes: $re1 = /^ -[x]* x -[x]* $/; # match a string with exactly one 'x' $re2 = /^ -[y]* y -[y]* $/; # ditto 'y' $re3 = /^ -[z]* z -[z]*

Re: Junction Values

2005-02-20 Thread Matt Fowles
Damian~ On Mon, 21 Feb 2005 08:29:40 +1100, Damian Conway [EMAIL PROTECTED] wrote: Nicholas Clark wrote: On Sun, Feb 20, 2005 at 07:41:16PM +1100, Damian Conway wrote: Given this: my $x = set(1..3); my $y = set(1,3,5,7,9); my $n = 2; $x | $y

Re: Junction Values

2005-02-19 Thread Damian Conway
Hmm. On rereading my last message, I feel that it comes across as angry, and critical of this entire discussion or perhaps of particular participants. That was certainly not my intent and I apologize if that's how it appeared. I genuinely respect the contributions of every person on this

Re: Junction Values

2005-02-19 Thread Autrijus Tang
On Fri, Feb 18, 2005 at 11:31:54PM -0800, Brent 'Dax' Royal-Gordon wrote: Junctions are intended to ultimately be used in boolean tests. That's why the values of the junction have an any/all/one/none relationship. The proper data structure here is an array. (Actually, ironically enough,

Re: Junction Values

2005-02-19 Thread Rod Adams
Brent 'Dax' Royal-Gordon wrote: Rod Adams [EMAIL PROTECTED] wrote: The caller is not in a position to know if the callee is internally structured in such a way that passing in a raw junction makes sense. Sure they are. It's called reading the documentation. If it doesn't say it can

Re: Junction Values

2005-02-19 Thread Rod Adams
Damian Conway wrote: Rod Adams wrote: All I want now is for autothreading to be explicit. It already *is*. The only way that: is_prime($x) can ever autothread is if $x holds a junction. But that can now only happen if there's an explicit Cuse junctions in scope where $x was assigned to (or

Re: Junction Values

2005-02-19 Thread Rod Adams
Damian Conway wrote: Hmm. On rereading my last message, I feel that it comes across as angry, and critical of this entire discussion or perhaps of particular participants. That was certainly not my intent and I apologize if that's how it appeared. I genuinely respect the contributions of

Re: Junction Values

2005-02-19 Thread Damian Conway
Rod Adams wrote: I had not caught the difference between: use junctions; $x = 6|7|8; if is_prime($x) {...} and if is_prime(6|7|8) {...} There isn't one. Is this new, or yet another important detail I missed along the way? Or is this a side effect of not being able to store a Junction,

Set sigils (was: Re: Junction Values)

2005-02-19 Thread Ashley Winters
On Sat, 19 Feb 2005 15:20:59 -0600, Rod Adams [EMAIL PROTECTED] wrote: Positions I still stand by: - Sets belong in the language, and need more support. This can likely be done at the module level, but I'd like them better incorporated, preferably with their own sigil. However, I believe

Re: Junction Values

2005-02-19 Thread Patrick R. Michaud
On Sat, Feb 19, 2005 at 02:40:00PM -0600, Rod Adams wrote: I addressed earlier concept of how does perl know when there are side effects, particularly with the execution path can weave to parts written in pure-parrot. Patrick responded by implying that there was no such side effect

Re: Junction Values

2005-02-19 Thread Damian Conway
Rod Adams wrote: Simply put, I want my junctions. Standard in Perl 6. I want my hyper operator superstrength arrays. Standard in Perl 6. I want them both at the same time. Standard in Perl 6. I never want to see implicit threading. Ever. If this is the only stumbling block, then it's easily

Re: Junction Values

2005-02-19 Thread Brent 'Dax' Royal-Gordon
Damian Conway [EMAIL PROTECTED] wrote: Yes, it's a side-effect of the new default prohibition on junction assignments (though I'm still working hard to convince everyone that that prohibition cripples junctions and that having to use junctions before you can assign a basic Perl 6 scalar

Re: Junction Values

2005-02-19 Thread Rod Adams
Damian Conway wrote: Rod Adams wrote: I never want to see implicit threading. Ever. If this is the only stumbling block, then it's easily solved. Instead of ruining junctions by imposing all kinds of complex and annoying hoops and hurdles (i.e. Cuse junctions and Cno junctions), we can just

Re: Junction Values

2005-02-18 Thread Brent 'Dax' Royal-Gordon
Rod Adams [EMAIL PROTECTED] wrote: Larry Wall wrote: Junctions can short circuit when they feel like it, and might in some cases do a better job of picking the evaluation order than a human. I was afraid someone was going to say that. And I now must convert my reservations about junction

Re: Junction Values

2005-02-18 Thread David Wheeler
On Feb 18, 2005, at 2:04 AM, Brent 'Dax' Royal-Gordon wrote: Junctions are equivalent to the English sentence Get eggs, bacon, and toast from the store. (In Perl, that'd be something like C $store-get(eggs bacon toast) .) It's just a bit of orthogonality that allows you to give eggs, bacon,

Re: Junction Values

2005-02-18 Thread Rod Adams
Brent 'Dax' Royal-Gordon wrote: Rod Adams [EMAIL PROTECTED] wrote: Larry Wall wrote: Junctions can short circuit when they feel like it, and might in some cases do a better job of picking the evaluation order than a human. I was afraid someone was going to say that. And I now must

Re: Junction Values

2005-02-18 Thread Rod Adams
Larry Wall wrote: The need for junctions first became evident when we found ourselves filling the ~~ tables with various sorts of weird non-symmetries. ~~ can easily be called the DWIM compare operator. It even looks like you're waving your hands, asking for some strange voodoo to happen. It

Re: Junction Values

2005-02-18 Thread Luke Palmer
Rod Adams writes: Junctions are intended to be used mainly within conditionals and other statements; If the set of these other statements is limited, consider creating a Junction class (which needs a use Junction; to activate), which overloads the various comparison operators for when a

Re: Junction Values

2005-02-18 Thread Jonathan Scott Duff
On Fri, Feb 18, 2005 at 12:42:31PM -0600, Rod Adams wrote: No, but nor does it have a concept quite like a variable. Which significantly weakens the mapping naturally to human linguistic structures argument, IMO. Why exactly? It's just the variable-nature of variables that isn't exactly

Re: Junction Values

2005-02-18 Thread Rod Adams
Luke Palmer wrote: Rod Adams writes: Junctions are intended to be used mainly within conditionals and other statements; If the set of these other statements is limited, consider creating a Junction class (which needs a use Junction; to activate), which overloads the various comparison

Re: Junction Values

2005-02-18 Thread Ashley Winters
On Fri, 18 Feb 2005 12:47:51 -0700, Luke Palmer [EMAIL PROTECTED] wrote: Run through your mind how this would be done with a junction in $x. Particularly focus on: 2..sqrt($x) What the hell does that mean? Do you get a junction of lists out? Or does sqrt die because it's not

Re: Junction Values

2005-02-18 Thread Eirik Berg Hanssen
Ashley Winters [EMAIL PROTECTED] writes: On Fri, 18 Feb 2005 12:47:51 -0700, Luke Palmer [EMAIL PROTECTED] wrote: Run through your mind how this would be done with a junction in $x. Particularly focus on: 2..sqrt($x) What the hell does that mean? Do you get a junction of lists out?

Re: Junction Values

2005-02-18 Thread Ashley Winters
On Fri, 18 Feb 2005 23:12:40 +0100, Eirik Berg Hanssen [EMAIL PROTECTED] wrote: Ashley Winters [EMAIL PROTECTED] writes: On Fri, 18 Feb 2005 12:47:51 -0700, Luke Palmer [EMAIL PROTECTED] wrote: Run through your mind how this would be done with a junction in $x. Particularly focus on:

Re: Junction Values

2005-02-18 Thread Ashley Winters
On Fri, 18 Feb 2005 14:35:53 -0800, Ashley Winters [EMAIL PROTECTED] wrote: 1 .. sqrt(10) - LazyList of (1..3) 1 .. sqrt(10|20) - Junction of any(1,2,3, 1,2,3,4) LazyList does Iterator, but Junction does not. You'd have to use (1 .. sqrt(3|6)).values to iterate through the possible values

Re: Junction Values

2005-02-18 Thread Craig DeForest
Hmmm... It seems that this way does lie madness -- there's a fundamental ambiguity between autothreading happening inside or outside the declared loop, and there's no least surprising way to implement it. Certainly inside the loop is the easiest and most natural to implement, but that acts

Re: Junction Values

2005-02-18 Thread Rod Adams
Craig DeForest wrote: Hmmm... It seems that this way does lie madness -- there's a fundamental ambiguity between autothreading happening inside or outside the declared loop, and there's no least surprising way to implement it. Certainly inside the loop is the easiest and most natural to

Re: Junction Values

2005-02-18 Thread Brent 'Dax' Royal-Gordon
Rod Adams [EMAIL PROTECTED] wrote: if $x == 3|4|5|6 {...} would thread over infix:== without any funkiness, since we'll assume operators are well written, and can take junctions as parameters, same as: if is_prime(3|4|5|6) {...} Would pass the junction to is_prime, to

Re: Junction Values

2005-02-18 Thread Brent 'Dax' Royal-Gordon
Rod Adams [EMAIL PROTECTED] wrote: Luke Palmer wrote: 2..sqrt($x) What the hell does that mean? Do you get a junction of lists out? Or does sqrt die because it's not expecting a junction? What on earth does C for (2..sqrt(3|5)) {...} mean in the current state of junctions? In

Re: Junction Values

2005-02-18 Thread Rod Adams
Brent 'Dax' Royal-Gordon wrote: Rod Adams [EMAIL PROTECTED] wrote: Luke Palmer wrote: 2..sqrt($x) What the hell does that mean? Do you get a junction of lists out? Or does sqrt die because it's not expecting a junction? What on earth does C for (2..sqrt(3|5)) {...} mean in the

Re: Junction Values

2005-02-18 Thread Rod Adams
Brent 'Dax' Royal-Gordon wrote: Rod Adams [EMAIL PROTECTED] wrote: if $x == 3|4|5|6 {...} would thread over infix:== without any funkiness, since we'll assume operators are well written, and can take junctions as parameters, same as: if is_prime(3|4|5|6) {...} Would pass the

Re: Junction Values

2005-02-18 Thread Brent 'Dax' Royal-Gordon
Rod Adams [EMAIL PROTECTED] wrote: Suppose funky_test is a derivative of C printf . Only this printf let's you feed it a junction for the format, and it will sort through them and see which one matches best depending on actual number of parameters, parameter types, etc. Ordinarily, this would

Re: Junction Values

2005-02-18 Thread Damian Conway
Rod Adams wrote: All I want now is for autothreading to be explicit. It already *is*. The only way that: is_prime($x) can ever autothread is if $x holds a junction. But that can now only happen if there's an explicit Cuse junctions in scope where $x was assigned to (or the explicit use

Re: Junction Values

2005-02-17 Thread Rod Adams
Brent 'Dax' Royal-Gordon wrote: Rod Adams [EMAIL PROTECTED] wrote: Larry Wall wrote: That, and we'd like a novice to be able to write given $x { when 1 | 2 | 3 {...} when 4 | 5 | 6 {...} } Or just change Cwhen to accept a list of things to compare against, followed by a

Re: Junction Values

2005-02-17 Thread Larry Wall
On Thu, Feb 17, 2005 at 02:18:55AM -0600, Rod Adams wrote: : The simple if is: : : if $x ~~ (1,2,3,4) {...} # parens needed here since , is lower than ~~ : in precedence. That is asking if $x is a list containing 1,2,3,4. : Same for unless/while/until. And all of this from the entirely useful

Re: Junction Values

2005-02-17 Thread John Macdonald
On Thu, Feb 17, 2005 at 09:06:47AM -0800, Larry Wall wrote: Junctions can short circuit when they feel like it, and might in some cases do a better job of picking the evaluation order than a human. Hmm, yes, there is an interesting interaction with lazy evaluation ranges here. $x = any( 1

Re: Junction Values

2005-02-17 Thread Rod Adams
Larry Wall wrote: On Thu, Feb 17, 2005 at 02:18:55AM -0600, Rod Adams wrote: : The simple if is: : : if $x ~~ (1,2,3,4) {...} # parens needed here since , is lower than ~~ : in precedence. That is asking if $x is a list containing 1,2,3,4. Quoting S04: $_ $xType of Match

Re: Junction Values

2005-02-16 Thread Eirik Berg Hanssen
Jonathan Scott Duff [EMAIL PROTECTED] writes: On Wed, Feb 16, 2005 at 12:17:35PM +1100, Damian Conway wrote: none($a, $a) == undef True. Isn't this one false in the case when $a is undef? Since it is numerical comparison, it is false as long as $a == 0. (I would hope.) Eirik -- So

Re: Junction Values

2005-02-16 Thread Nigel Sandever
On Wed, 16 Feb 2005 12:17:35 +1100, [EMAIL PROTECTED] (Damian Conway) wrote: ..values tells you what raw values are inside the junction. The other kind of introspection that's desirable is: what raw values can *match* this junction. There would probably be a .states method for that. To

Re: Junction Values

2005-02-16 Thread Patrick R. Michaud
On Wed, Feb 16, 2005 at 01:06:22PM +, Nigel Sandever wrote: Any chance that you could provide one or two simple but realistic examples of using Junctions and their operators? I'll give it a shot, but keep in mind that I'm somewhat new to this also. :-) First, junctions are an easy way

Re: Junction Values

2005-02-16 Thread Nigel Sandever
On Wed, 16 Feb 2005 09:18:42 -0600, [EMAIL PROTECTED] (Patrick R. Michaud) wrote: On Wed, Feb 16, 2005 at 01:06:22PM +, Nigel Sandever wrote: Any chance that you could provide one or two simple but realistic examples of using Junctions and their operators? I'll give it a shot,

Re: Junction Values

2005-02-16 Thread Patrick R. Michaud
On Wed, Feb 16, 2005 at 06:04:37PM +, Nigel Sandever wrote: On Wed, 16 Feb 2005 09:18:42 -0600, [EMAIL PROTECTED] (Patrick R. Michaud) wrote: And for fun, try writing the equivalent of if $x == one($a, $b, $c, $d) { ... } without a junction. (Okay, one can cheat with Cgrep.)

Re: Junction Values

2005-02-16 Thread Larry Wall
On Wed, Feb 16, 2005 at 01:55:31PM -0600, Patrick R. Michaud wrote: : And to : anticipate the followup question of Well, why not make features such : as junctions into optional modules?, I think a partial answer is that : features like these really need deep language support to work : effectively

Re: Junction Values

2005-02-16 Thread Rod Adams
Patrick R. Michaud wrote: On Wed, Feb 16, 2005 at 06:04:37PM +, Nigel Sandever wrote: If the hyper operator returned one boolean result for each comparison it made, and if a list of boolean values in a boolean context collapsed to a count of the trues/1s it contained, I think those would

Re: Junction Values

2005-02-16 Thread Rod Adams
Larry Wall wrote: That, and we'd like a novice to be able to write given $x { when 1 | 2 | 3 {...} when 4 | 5 | 6 {...} } Or just change Cwhen to accept a list of things to compare against, followed by a coderef. -- Rod Adams

Re: Junction Values

2005-02-16 Thread Ashley Winters
On Wed, 16 Feb 2005 14:29:14 -0600, Rod Adams [EMAIL PROTECTED] wrote: Larry Wall wrote: That, and we'd like a novice to be able to write given $x { when 1 | 2 | 3 {...} when 4 | 5 | 6 {...} } Or just change Cwhen to accept a list of things to compare against,

Re: Junction Values

2005-02-15 Thread Damian Conway
Rod Adams wrote: Okay, so we've established that: $x = any(3,4,5); @l = $x.values.sort; Leaves us with @l == (3,4,5), and that makes a fair amount of sense. What do the following evaluate to: @l1 = all(3,4,5).values.sort; Same. @l2 = one(3,4,5).values.sort; Same. @l3 = none(3,4,5).values.sort;

Re: Junction Values

2005-02-15 Thread Jonathan Scott Duff
On Wed, Feb 16, 2005 at 12:17:35PM +1100, Damian Conway wrote: none($a, $a) == undef True. Isn't this one false in the case when $a is undef? -Scott -- Jonathan Scott Duff [EMAIL PROTECTED]

Re: Junction Values

2005-02-15 Thread Damian Conway
Jonathan Scott Duff wrote: none($a, $a) == undef True. Isn't this one false in the case when $a is undef? Yes. Apologies for not being more precise. Damian

Re: Junction Values

2005-02-15 Thread Patrick R. Michaud
On Wed, Feb 16, 2005 at 12:17:35PM +1100, Damian Conway wrote: Rod Adams wrote: On a slightly different topic, do the following equivalences work: [...] none($a, $a) == undef True. Scott already caught (and Damian acknowledged) this one, it's false if $a == undef. none($a,$a,$b) ==

Re: Junction Values

2005-02-15 Thread Rod Adams
Damian Conway wrote: .values tells you what raw values are inside the junction. The other kind of introspection that's desirable is: what raw values can *match* this junction. There would probably be a .states method for that. To see the difference between the two, consider: my $ideal_partner

Re: Junction Values

2005-02-15 Thread Rod Adams
Patrick R. Michaud wrote: none(none($a,$b),none($c,$d)) == none($a,$b,$c,$d) True. H... - none(none($a,$b) == none($a,$b,$c,$d), none($c,$d) == none($a,$b,$c,$d)) - none(none($a == none($a,$b,$c,$d), $b == none($a,$b,$c,$d)), none($c ==

Re: Junction Values

2005-02-15 Thread Damian Conway
Patrick R. Michaud wrote: none(none($a,$b),none($c,$d)) == none($a,$b,$c,$d) True. H... - none(none($a,$b) == none($a,$b,$c,$d), none($c,$d) == none($a,$b,$c,$d)) RHS distributes first. So the expansion is this instead... - none(none(none($a,$b),none($c,$d)) == $a,

Re: Junction Values

2005-02-15 Thread Patrick R. Michaud
On Wed, Feb 16, 2005 at 02:53:15PM +1100, Damian Conway wrote: Patrick R. Michaud wrote: none(none($a,$b),none($c,$d)) == none($a,$b,$c,$d) True. H... - none(none($a,$b) == none($a,$b,$c,$d), none($c,$d) == none($a,$b,$c,$d)) RHS distributes first. So the

Re: Junction Values

2005-02-15 Thread Damian Conway
Patrick R. Michaud wrote: RHS distributes first. So the expansion is this instead... Ummm, okay, but that's not what I interpreted from S09, where it says that the left-most conjunction or injunction is autothreaded first. In this I've also assumed that $a == $b is equivalent to