Re: a junction or not

2009-03-17 Thread Jon Lang
Darren Duncan wrote:
>
> Jon Lang wrote:
>>
>> Darren Duncan wrote:
>>> I would assume that invoking .perl on a Junction would result in Perl
>>> code
>>> consisting of the appropriate any/all/etc expression. -- Darren Duncan
>>
>> Tough to parse, though; and feels like a kludge.  I expect better of Perl
>> 6.
>
> What do you mean by "tough to parse" and "feels like a kludge"?

If I'm understanding Larry correctly, then given:

my $choice = any(1..10);

$choice.perl will return the same thing that the following would:

any($choice.eigenstates.«perl)

That is, it would return a Junction of Str, not a Str.  So the
question is how to get something that returns an expression to the
effect of:

'any(' ~ $choice.eigenstates.«perl.join(',') ~ ')'

Or, if I'm reading Larry incorrectly and $choice.perl provides the
latter, how do you get the former (without knowing ahead of time that
$choice is an any-junction)?

--

The other question is: given $choice as defined above, how do I find
out which type of junction it is?  Do I somehow call something that
would produce the latter string, and then extract the first word from
it?  Or is there a more direct way to find out which kind of Junction
you're dealing with?

-- 
Jonathan "Dataweaver" Lang


Re: a junction or not

2009-03-17 Thread David Green

On 2009-Mar-17, at 2:16 am, Jon Lang wrote:

$choice.perl will return the same thing that the following would:
any($choice.eigenstates.«perl)

That is, it would return a Junction of Str, not a Str.  So the
question is how to get something that returns an expression to the
effect of:
'any(' ~ $choice.eigenstates.«perl.join(',') ~ ')'


say $choice.perl

...which will ultimately call (junction-of-.perl's).Str, and  
Str(Junction:) is what produces the "any(XXX)" string.  [Unless it  
ends up being implemented some other way, of course!]




The other question is: given $choice as defined above, how do I find
out which type of junction it is?


I guess really Junctions need two public methods: .eigenstates for the  
values, and, er, .eigenop(?!) to return how they're joined -- I'm  
thinking it would return a code ref, i.e. &any, &all, etc.



-David



r25880 - docs/Perl6/Spec

2009-03-17 Thread pugs-commits
Author: lwall
Date: 2009-03-18 02:28:39 +0100 (Wed, 18 Mar 2009)
New Revision: 25880

Modified:
   docs/Perl6/Spec/S03-operators.pod
   docs/Perl6/Spec/S04-control.pod
Log:
create more semantic distance between terms and 0-ary functions


Modified: docs/Perl6/Spec/S03-operators.pod
===
--- docs/Perl6/Spec/S03-operators.pod   2009-03-18 01:03:18 UTC (rev 25879)
+++ docs/Perl6/Spec/S03-operators.pod   2009-03-18 01:28:39 UTC (rev 25880)
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall 
   Date: 8 Mar 2004
-  Last Modified: 12 Mar 2009
+  Last Modified: 17 Mar 2009
   Number: 3
-  Version: 158
+  Version: 159
 
 =head1 Overview
 
@@ -303,14 +303,6 @@
 its left, so it binds tighter than comma on the left but looser than
 comma on the right--see List prefix precedence below.
 
-=item *
-
-0-ary functions
-
-self
-undef
-rand
-
 =back
 
 =head2 Method postfix precedence
@@ -1009,7 +1001,7 @@
 to C<$_> in Perl 6.
 
 There is no unary C function in Perl 6, though there is a C<.rand>
-method call and a 0-ary C term.
+method call and an argumentless C term.
 
 =over
 
@@ -1746,7 +1738,7 @@
 
 The function can be 0-ary as well:
 
-() ... &rand   # list of random numbers
+() ... { rand }# list of random numbers
 
 The function may also be slurpy (*-ary), in which case all the
 preceding values are passed in (which means they must all be cached
@@ -3627,7 +3619,7 @@
 then you shouldn't worry about it, because unlike previous versions,
 Perl 6 never guesses whether the next thing is a term or operator.
 In this case it is always expecting a term unless C is predeclared
-to be a 0-ary sub.]
+to be a type or value name.]
 
 The upgrade never happens on the "blunt" end of a hyper.  If you write
 

Modified: docs/Perl6/Spec/S04-control.pod
===
--- docs/Perl6/Spec/S04-control.pod 2009-03-18 01:03:18 UTC (rev 25879)
+++ docs/Perl6/Spec/S04-control.pod 2009-03-18 01:28:39 UTC (rev 25880)
@@ -12,9 +12,9 @@
 
   Maintainer: Larry Wall 
   Date: 19 Aug 2004
-  Last Modified: 4 Mar 2009
+  Last Modified: 17 Mar 2009
   Number: 4
-  Version: 73
+  Version: 74
 
 This document summarizes Apocalypse 4, which covers the block and
 statement syntax of Perl.
@@ -95,7 +95,7 @@
 a variable in the current package.
 
 The new C declarator introduces a lexically scoped name
-for a compile-time constant, either a variable or a 0-ary sub, which
+for a compile-time constant, either a variable or named value, which
 may be initialized with a pseudo-assignment:
 
 constant Num $pi = 3;