perl.perl6.language http://www.nntp.perl.org/group/perl.perl6.language/ ... Copyright 1998-2008 perl.org Sun, 27 Jul 2008 08:10:49 +0000 ask@perl.org [svn:perl6-synopsis] r14570 - doc/trunk/design/syn by larry Author: larry<br/>Date: Sat Jul 26 21:04:50 2008<br/>New Revision: 14570<br/><br/>Modified:<br/> doc/trunk/design/syn/S09.pod<br/><br/>Log:<br/>Allow stackable subscript declarations and (--&gt;type)<br/><br/><br/>Modified: doc/trunk/design/syn/S09.pod<br/>==============================================================================<br/>--- doc/trunk/design/syn/S09.pod (original)<br/>+++ doc/trunk/design/syn/S09.pod Sat Jul 26 21:04:50 2008<br/>@@ -713,6 +713,12 @@<br/> # Same...<br/> @calendar[ **{July; 1..3}; *-3..*-1]<br/> <br/>+It is also possible to stack subscript declarations of various<br/>+types, including a final normal signature to specify named args<br/>+and return type:<br/>+<br/>+ my @array[10]{&#39;a&#39;..&#39;z&#39;}(:$sparse --&gt; MyType);<br/>+<br/> =head1 PDL support<br/> <br/> An array C&lt;@array&gt; can be tied to a PDL at declaration time:<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29400.html Sat, 26 Jul 2008 21:04:58 +0000 [svn:perl6-synopsis] r14569 - doc/trunk/design/syn by larry Author: larry<br/>Date: Fri Jul 25 23:27:45 2008<br/>New Revision: 14569<br/><br/>Modified:<br/> doc/trunk/design/syn/S02.pod<br/><br/>Log:<br/>\d123 is now \c123 to avoid confusion with \d character class<br/><br/><br/>Modified: doc/trunk/design/syn/S02.pod<br/>==============================================================================<br/>--- doc/trunk/design/syn/S02.pod (original)<br/>+++ doc/trunk/design/syn/S02.pod Fri Jul 25 23:27:45 2008<br/>@@ -12,9 +12,9 @@<br/> <br/> Maintainer: Larry Wall &lt;larry@wall.org&gt;<br/> Date: 10 Aug 2004<br/>- Last Modified: 2 Apr 2008<br/>+ Last Modified: 25 Jul 2008<br/> Number: 2<br/>- Version: 132<br/>+ Version: 133<br/> <br/> This document summarizes Apocalypse 2, which covers small-scale<br/> lexical items and typological issues. (These Synopses also contain<br/>@@ -2174,8 +2174,7 @@<br/> Characters indexed by hex numbers can be interpolated into strings<br/> by introducing with C&lt;&quot;\x&quot;&gt;, followed by either a bare hex number<br/> (C&lt;&quot;\x263a&quot;&gt;) or a hex number in square brackets (C&lt;&quot;\x[263a]&quot;&gt;).<br/>-Similarly, C&lt;&quot;\o12&quot;&gt; and C&lt;&quot;\o[12]&quot;&gt; interpolate octals, while<br/>-C&lt;&quot;\d1234&quot;&gt; and C&lt;&quot;\d[1234]&quot;&gt; interpolate decimals--but generally<br/>+Similarly, C&lt;&quot;\o12&quot;&gt; and C&lt;&quot;\o[12]&quot;&gt; interpolate octals--but generally<br/> you should be using hex in the world of Unicode. Multiple characters<br/> may be specified within any of the bracketed forms by separating the<br/> numbers with comma: C&lt;&quot;\x[41,42,43]&quot;&gt;. You must use the bracketed<br/>@@ -2725,10 +2724,19 @@<br/> <br/> [Note: none of the official Unicode character names contains comma.]<br/> <br/>+You may also put one or more decimal numbers inside the square brackets:<br/>+<br/>+ &quot;\c[13,10]&quot; # CRLF<br/>+<br/>+Any single decimal number may omit the brackets:<br/>+<br/>+ &quot;\c8&quot; # backspace<br/>+<br/> (Within a regex you may also use C&lt;\C&gt; to match a character that is<br/> not the specified character.)<br/> <br/>-If the character following C&lt;\c&gt; or C&lt;\C&gt; is not a left square bracket,<br/>+If the character following C&lt;\c&gt; or C&lt;\C&gt; is neither a left square bracket<br/>+nor a decimal digit,<br/> the single following character is turned into a control character by<br/> the usual trick of XORing the 64 bit. This allows C&lt;\c@&gt; for NULL<br/> and C&lt;\c?&gt; for DELETE, but note that the ESCAPE character may not be<br/>@@ -2736,6 +2744,7 @@<br/> <br/> \e<br/> \c[ESCAPE]<br/>+ \c27<br/> \x1B<br/> \o33<br/> <br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29399.html Fri, 25 Jul 2008 23:27:54 +0000 Perl6::Str on CPAN by Moritz Lenz Hi,<br/><br/>today I released Perl6::Str to CPAN. It&#39;s a module for grapheme level<br/>string handling, and the methods are modeled closely after those of Perl 6.<br/><br/>I cheated a bit in that I didn&#39;t implement codepoint and byte level<br/>semantics, since perl 5 supports them natively already.<br/><br/>It lacks some features, some features aren&#39;t properly tested yet (like<br/>normalization), and some aren&#39;t planned at all (pack/unpack for example).<br/><br/>It&#39;s also meant as an inspiration: grapheme level string handling<br/>doesn&#39;t have to be hard (it just becomes hard if you optimize the code ...)<br/><br/>All comments are welcome.<br/><br/>Cheers,<br/>Moritz<br/><br/>-- <br/>Moritz Lenz<br/>http://moritz.faui2k3.org/ | http://perl-6.de/<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29398.html Mon, 21 Jul 2008 05:01:27 +0000 Re: meta_postfix:<*> by Aristotle Pagaltzis * Larry Wall &lt;larry@wall.org&gt; [2008-07-16 19:45]:<br/>&gt; Speaking on behalf of the mere mortal, My Eyes Glaze Over.<br/><br/>Yeah, this proposal seems to be slipping into APL territory.<br/><br/>Regards,<br/>-- <br/>Aristotle Pagaltzis // &lt;http://plasmasturm.org/&gt;<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29397.html Fri, 18 Jul 2008 01:00:11 +0000 [svn:perl6-synopsis] r14568 - doc/trunk/design/syn by larry Author: larry<br/>Date: Thu Jul 17 11:05:58 2008<br/>New Revision: 14568<br/><br/>Modified:<br/> doc/trunk/design/syn/S09.pod<br/><br/>Log:<br/>typo from DietCoke++<br/><br/><br/>Modified: doc/trunk/design/syn/S09.pod<br/>==============================================================================<br/>--- doc/trunk/design/syn/S09.pod (original)<br/>+++ doc/trunk/design/syn/S09.pod Thu Jul 17 11:05:58 2008<br/>@@ -789,7 +789,7 @@<br/> @x[0;1;42]<br/> @x[0..10; 1,0; 1..*:by(2)]<br/> <br/>-Built-in array types are expected succeed either way, even if<br/>+Built-in array types are expected to succeed either way, even if<br/> the cascaded subscript form must be implemented inefficiently by<br/> constructing temporary slice objects for later subscripts to use.<br/> (User-defined types may choose not to support the cascaded form, but<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29396.html Thu, 17 Jul 2008 11:11:18 +0000 [svn:perl6-synopsis] r14567 - doc/trunk/design/syn by larry Author: larry<br/>Date: Thu Jul 17 10:57:24 2008<br/>New Revision: 14567<br/><br/>Modified:<br/> doc/trunk/design/syn/S09.pod<br/><br/>Log:<br/>Equivalence of cascaded and semicolon subscript forms suggested by nick++<br/><br/><br/>Modified: doc/trunk/design/syn/S09.pod<br/>==============================================================================<br/>--- doc/trunk/design/syn/S09.pod (original)<br/>+++ doc/trunk/design/syn/S09.pod Thu Jul 17 10:57:24 2008<br/>@@ -12,9 +12,9 @@<br/> <br/> Maintainer: Larry Wall &lt;larry@wall.org&gt;<br/> Date: 13 Sep 2004<br/>- Last Modified: 27 May 2008<br/>+ Last Modified: 17 July 2008<br/> Number: 9<br/>- Version: 27<br/>+ Version: 28<br/> <br/> =head1 Overview<br/> <br/>@@ -776,6 +776,27 @@<br/> <br/> @x[0;1;42]<br/> <br/>+=head1 Cascaded subscripting of multidimensional arrays<br/>+<br/>+For all multidimensional array types, it is expected that cascaded subscripts:<br/>+<br/>+ @x[0][1][42]<br/>+ @x[0..10][1,0][1..*:by(2)]<br/>+<br/>+will either fail or produce the same results as the equivalent<br/>+semicolon subscripts:<br/>+<br/>+ @x[0;1;42]<br/>+ @x[0..10; 1,0; 1..*:by(2)]<br/>+<br/>+Built-in array types are expected succeed either way, even if<br/>+the cascaded subscript form must be implemented inefficiently by<br/>+constructing temporary slice objects for later subscripts to use.<br/>+(User-defined types may choose not to support the cascaded form, but<br/>+if so, they should fail rather than providing different semantics.)<br/>+As a consequence, for built-in types of declared shape, the appropriate<br/>+number of cascaded subscripts may always be optimized into the<br/>+semicolon form.<br/> <br/> =head1 The semicolon operator<br/> <br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29395.html Thu, 17 Jul 2008 11:01:07 +0000 Re: $foo[0][0] versus $foo[0;0] by Nicholas Clark On Wed, Jul 16, 2008 at 10:04:03AM -0700, Larry Wall wrote:<br/>&gt; On Sun, Jul 13, 2008 at 02:17:10PM -0500, Adrian Kreher wrote:<br/>&gt; : Hi,<br/>&gt; : <br/>&gt; : I&#39;m reviewing the tests in S09, and the file <br/>&gt; : t/spec/S02-builtin_data_types/multi_dimensional_array.t uses the [0][0] <br/>&gt; : indexing format interchangeably with [0;0].<br/>&gt; : <br/>&gt; : These two formats mean two different things, correct? The [0][0] form isn&#39;t <br/>&gt; : mentioned much in the spec, nor is [0;0] or if they interact somehow.<br/>&gt; <br/>&gt; I think they should come out to meaning the same thing, though the<br/>&gt; [0][0] form may be less efficient if it has to temporarily construct<br/>&gt; a slice of the next dimension of the array. On the other hand, a<br/>&gt; na&iuml;ve implementation of the multidimensional subscripter might just do<br/>&gt; the same thing internally for the semicolon, so it could be a wash.<br/><br/>Would it be counter-productive to specify that the implementation is allowed<br/>to compile time optimise [$a][$b] etc to [$a;$b] etc?<br/><br/>I&#39;m assuming that it is allowed for the implementation of a multidmentional<br/>array to have different semantics for [$a][$b] and [$a;$b], but that seems<br/>to violate good sense, much like overloading a class in Perl 5 (or any other<br/>language) such that (++$a) and ($a + 1) are not the same.<br/><br/>Nicholas Clark<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29394.html Thu, 17 Jul 2008 08:03:33 +0000 [svn:perl6-synopsis] r14566 - doc/trunk/design/syn by larry Author: larry<br/>Date: Wed Jul 16 23:52:23 2008<br/>New Revision: 14566<br/><br/>Modified:<br/> doc/trunk/design/syn/S04.pod<br/><br/>Log:<br/>suggestion from moritz++ that POST blocks be allowed to see the return value<br/><br/><br/>Modified: doc/trunk/design/syn/S04.pod<br/>==============================================================================<br/>--- doc/trunk/design/syn/S04.pod (original)<br/>+++ doc/trunk/design/syn/S04.pod Wed Jul 16 23:52:23 2008<br/>@@ -14,7 +14,7 @@<br/> Date: 19 Aug 2004<br/> Last Modified: 16 July 2008<br/> Number: 4<br/>- Version: 67<br/>+ Version: 68<br/> <br/> This document summarizes Apocalypse 4, which covers the block and<br/> statement syntax of Perl.<br/>@@ -1060,6 +1060,14 @@<br/> before C&lt;BEGIN&gt;, C&lt;CHECK&gt;, or C&lt;INIT&gt;, since those are done at compile or<br/> process initialization time).<br/> <br/>+For blocks such as C&lt;KEEP&gt; and C&lt;POST&gt; that are run when exiting a<br/>+scope normally, the return value (if any) from that scope is available<br/>+as the current topic. (It is presented as a C&lt;Capture&gt; object.)<br/>+The topic of the outer block is still available as C&lt;&lt; OUTER::&lt;$_&gt; &gt;&gt;.<br/>+Whether the return value is modifiable may be a policy of the block<br/>+in question. In particular, the return value should not be modified<br/>+within a C&lt;POST&gt; block, but a C&lt;LEAVE&gt; block could be more liberal.<br/>+<br/> =head1 Statement parsing<br/> <br/> In this statement:<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29393.html Wed, 16 Jul 2008 23:53:08 +0000 [svn:perl6-synopsis] r14565 - doc/trunk/design/syn by larry Author: larry<br/>Date: Wed Jul 16 23:26:04 2008<br/>New Revision: 14565<br/><br/>Modified:<br/> doc/trunk/design/syn/S04.pod<br/><br/>Log:<br/>clarification suggested by Bob Rogers++<br/><br/><br/>Modified: doc/trunk/design/syn/S04.pod<br/>==============================================================================<br/>--- doc/trunk/design/syn/S04.pod (original)<br/>+++ doc/trunk/design/syn/S04.pod Wed Jul 16 23:26:04 2008<br/>@@ -1276,8 +1276,8 @@<br/> symbol tables visible at compile time, this binds to the compile-time<br/> view of the lexical scopes. (At run-time, the initial run-time view<br/> of these scopes is copied from the compiler&#39;s view of them, so that<br/>-initializations carry over, for instance.) At run time, whenever such<br/>-a subroutine needs to be cloned, an additional C&lt;:=&gt; binding is done<br/>+initializations carry over, for instance.) At run time, when such<br/>+a subroutine is cloned, an additional C&lt;:=&gt; binding is done<br/> at clone time to the same symbol table entry that the original C&lt;::=&gt;<br/> was bound to. (The binding is not restored on exit from the current<br/> lexical scope; this C&lt;:=&gt; binding records the I&lt;last&gt; cloning, not<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29392.html Wed, 16 Jul 2008 23:26:13 +0000 Re: Complex planes by Brandon S. Allbery KF8NH <br/>On 2008 Jul 16, at 18:48, Jon Lang wrote:<br/><br/>&gt; Moritz Lenz wrote:<br/>&gt;&gt; Principle of least surprise:<br/>&gt;&gt;<br/>&gt;&gt; Suppose sqrt(1) returns any(1, -1):<br/>&gt;&gt; if sqrt($x) &lt; 0.5 { do something }<br/>&gt;&gt;<br/>&gt;&gt; I can see the big, fat WTF written in the face of programmer who <br/>&gt;&gt; tries<br/>&gt;&gt; to debug that code, and doesn&#39;t know about junctions. It just won&#39;t <br/>&gt;&gt; DTRT.<br/>&gt;<br/>&gt; This is closely related to my original point. In particular, if<br/>&gt; you&#39;re unwilling to have sqrt return junctions of distinct values, you<br/>&gt; don&#39;t really want to mess with junctions of a single complex value on<br/>&gt; different planes, either.<br/><br/>I suggest that the base library not bother with any of this; if <br/>someone wants it they can load a FullComplex module or something like <br/>that.<br/><br/>-- <br/>brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com<br/>system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu<br/>electrical and computer engineering, carnegie mellon university KF8NH<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29391.html Wed, 16 Jul 2008 17:50:24 +0000 Re: Complex planes by Jon Lang Mark Biggar wrote:<br/>&gt; Let&#39;s worry about getting principal values, branch cuts and handling signed zeros correct before dealing with the interaction of junctions and multi-valued complex functions.<br/><br/>Indeed.<br/><br/>&gt; BTW, two good references on this that we might want to plagiarizer.....I mean borrow from are the Ada Refernece Manual and the Common LISP Reference Manual. Both go into great detail on this subject.<br/><br/>I&#39;ve just reviewed the Ada Reference Manual&#39;s take on this topic, and<br/>it did indeed address a few wrinkles that I overlooked.<br/><br/>Basic rule: Complex.modulus &gt;= 0; Complex.arg ~~ -pi .. pi.<br/><br/>I&#39;m not fully up on the lingo; so I&#39;m going to invent some: Number $x<br/>is &#39;indefinite&#39; if it is defined but has a value of Inf, NaN, or the<br/>like. It is &#39;definite&#39; if it is defined and not indefinite.<br/><br/>If either .re or .im is indefinite, the complex number is indefinite.<br/><br/>If signed zeroes are used, then a definite complex number can always<br/>be assigned to one of the four quadrants. (In particular, if .im ==<br/>-0, the number falls in one of the lower quadrants, and .arg == -pi or<br/>-0, depending on whether .re is negative or positive, respectively; if<br/>.im == +0, the number falls in one of the upper quadrants, and .arg ==<br/>pi or +0. It is impossible for .arg to be indefinite if both .re and<br/>.im are definite: complex zeroes are &quot;signed&quot; by a definite .arg.)<br/>Conjecture: signed zeroes should be accompanied by signed infinities:<br/>as with zeroes, the &quot;sign&quot; of a complex infinity is a definite<br/>argument.<br/><br/>Without signed zeroes, a definite complex number can be assigned to<br/>one of the four quadrants, to the positive or negative real number<br/>axes, to the positive or negative imaginary number axes, or to the<br/>origin. Under this scheme, some modifications and caveats need to be<br/>stated: .arg ~~ -pi ^.. pi. (So if the number falls on the negative<br/>real number line, .arg == pi.) If the number is zero, .arg is<br/>indefinite. If the number is indefinite, .arg is indefinite. If .re<br/>is indefinite, then .im is indefinite, and vice versa.<br/><br/>The first paradigm has fewer special cases than the second one, but<br/>has several &quot;redundancies&quot; of the same nature as signed zeroes; the<br/>second paradigm more closely reflects what a mathematician would<br/>expect when seeing a complex number, but has several incongruities<br/>that might give a programmer headaches.<br/><br/>-- <br/>Jonathan &quot;Dataweaver&quot; Lang<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29390.html Wed, 16 Jul 2008 17:17:48 +0000 Re: Complex planes by Larry Wall It seems like my smiley went completely whoosh...<br/><br/>Larry<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29389.html Wed, 16 Jul 2008 16:03:30 +0000 [svn:perl6-synopsis] r14564 - doc/trunk/design/syn by larry Author: larry<br/>Date: Wed Jul 16 15:53:34 2008<br/>New Revision: 14564<br/><br/>Modified:<br/> doc/trunk/design/syn/S04.pod<br/><br/>Log:<br/>typo from Brandon++<br/><br/><br/>Modified: doc/trunk/design/syn/S04.pod<br/>==============================================================================<br/>--- doc/trunk/design/syn/S04.pod (original)<br/>+++ doc/trunk/design/syn/S04.pod Wed Jul 16 15:53:34 2008<br/>@@ -1290,7 +1290,7 @@<br/> do not need a compile-time C&lt;::=&gt; binding, but like global subs,<br/> they perform a C&lt;:=&gt; binding to the lexical symbol at clone time<br/> (again, conceptually at the entry to the outer lexical scope, but<br/>-possible deferred.)<br/>+possibly deferred.)<br/> <br/> sub foo {<br/> # conceptual cloning happens to both blocks below<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29388.html Wed, 16 Jul 2008 15:53:42 +0000 Re: [svn:perl6-synopsis] r14563 - doc/trunk/design/syn by Brandon S. Allbery KF8NH Minor typo:<br/><br/>On 2008 Jul 16, at 15:56, larry@cvs.perl.org wrote:<br/><br/>&gt; +(again, conceptually at the entry to the outer lexical scope, but<br/>&gt; +possible deferred.)<br/>&gt;<br/>&gt; sub foo {<br/><br/>&quot;possibly&quot;<br/><br/>-- <br/>brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com<br/>system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu<br/>electrical and computer engineering, carnegie mellon university KF8NH<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29387.html Wed, 16 Jul 2008 15:50:17 +0000 Re: Complex planes by Jon Lang Moritz Lenz wrote:<br/>&gt; If the programmer errs on what he thinks is in a variable, it&#39;ll always<br/>&gt; be a bug.<br/><br/>Yes; but some bugs are easier to make, and harder to catch, than others.<br/><br/>&gt; Principle of least surprise:<br/>&gt;<br/>&gt; Suppose sqrt(1) returns any(1, -1):<br/>&gt; if sqrt($x) &lt; 0.5 { do something }<br/>&gt;<br/>&gt; I can see the big, fat WTF written in the face of programmer who tries<br/>&gt; to debug that code, and doesn&#39;t know about junctions. It just won&#39;t DTRT.<br/><br/>This is closely related to my original point. In particular, if<br/>you&#39;re unwilling to have sqrt return junctions of distinct values, you<br/>don&#39;t really want to mess with junctions of a single complex value on<br/>different planes, either.<br/><br/>&gt;&gt;&gt;&gt; And even then, I&#39;m concerned that it might very quickly get out of<br/>&gt;&gt;&gt;&gt; hand. Consider:<br/>&gt;&gt;&gt;&gt;<br/>&gt;&gt;&gt;&gt; pow(1, 1/pi() ) :any - 1<br/>&gt;&gt;&gt;&gt;<br/>&gt;&gt;&gt;&gt; (I think I got that right...)<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; Not quite. Afaict the only functions that might return a junction are<br/>&gt;&gt;&gt; Complex.angle and Complex.log.<br/>&gt;&gt;<br/>&gt;&gt; Why is that?<br/>&gt;<br/>&gt; As I pointed out above it&#39;s insane to return a junction of logically<br/>&gt; distinct values.<br/><br/>It&#39;s only insane if the programmer isn&#39;t expecting it - which goes<br/>back to my first point of making sure that the programmer explicitly<br/>asked for it before giving it to him.<br/><br/>&gt; It might even be insane to do it for Complex.log:<br/><br/>Agreed: if you are uncomfortable with sqrt(1) returning a junction of<br/>distinct values, then Complex.log should likewise not return a<br/>junction of distinct values.<br/><br/>&gt; I think that I don&#39;t have to comment on the rest of the mail to make<br/>&gt; clear that Larry&#39;s proposal, although being quite interesting, is a very<br/>&gt; bad idea to actually implement (and very hard to implement as well)<br/>&gt; (unless somebody comes to its rescue with a really clever idea on how to<br/>&gt; resolve all these weirdnesses).<br/><br/>Well... yes and no. Remember, I started off by recommending against<br/>Larry&#39;s proposal. I haven&#39;t changed my mind, although I think that<br/>it&#39;s worth exploring whether or not an alternate treatment of complex<br/>numbers is doable.<br/><br/>-- <br/>Jonathan &quot;Dataweaver&quot; Lang<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29386.html Wed, 16 Jul 2008 15:48:58 +0000 Re: Complex planes by mark.a.biggar Let&#39;s worry about getting principal values, branch cuts and handling signed zeros correct before dealing with the interaction of junctions and multi-valued complex functions.<br/><br/>--<br/>Mark Biggar<br/>mark@biggar.org<br/>mark.a.biggar@comcast.net<br/>mbiggar@paypal.com<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29385.html Wed, 16 Jul 2008 15:23:59 +0000 Re: Complex planes by Moritz Lenz Jon Lang wrote:<br/>&gt; Moritz Lenz wrote:<br/>&gt;&gt; Jon Lang wrote:<br/>&gt;&gt;&gt; By the principle of least surprise, I&#39;d recommend against this. Most<br/>&gt;&gt;&gt; programmers, when they see &#39;sqrt(1)&#39;, will expect a return value of 1,<br/>&gt;&gt;<br/>&gt;&gt; And that&#39;s what they get unless they write it as sqrt(1 + 0i).<br/>&gt; <br/>&gt; I suppose that you _could_ use the programmer&#39;s choice of whether or<br/>&gt; not to use complex numbers in the argument list as the indicator of<br/>&gt; whether to return one answer or a junction of them. Of course, this<br/>&gt; could lead to subtle bugs where the programmer assigns a complex value<br/>&gt; to $x and later takes the sqrt($x), but forgets that he assigned a<br/>&gt; complex number earlier. This may or may not be sufficient grounds for<br/>&gt; requiring an explicit declaration that you want junctions.<br/><br/>If the programmer errs on what he thinks is in a variable, it&#39;ll always<br/>be a bug.<br/><br/>&gt;&gt;&gt; and won&#39;t want to jump through the hurdles involved in picking &#39;1&#39; out<br/>&gt;&gt;&gt; of &#39;any(1, -1)&#39;.<br/>&gt;&gt;<br/>&gt;&gt; 1 and -1 aren&#39;t just separated by a complex plane, they are really<br/>&gt;&gt; distinct numbers<br/>&gt; <br/>&gt; True enough. I fail to see how that invalidates my point, though: if<br/>&gt; you&#39;re going to mess with multiple complex planes, why wouldn&#39;t you<br/>&gt; also address the issue of distinct numbers as well? <br/><br/>Principle of least surprise:<br/><br/>Suppose sqrt(1) returns any(1, -1):<br/>if sqrt($x) &lt; 0.5 { do something }<br/><br/>I can see the big, fat WTF written in the face of programmer who tries<br/>to debug that code, and doesn&#39;t know about junctions. It just won&#39;t DTRT.<br/><br/>&gt; The latter issue<br/>&gt; is intimately connected to the former, as I demonstrate below.<br/>&gt; <br/>&gt;&gt;&gt; And even then, I&#39;m concerned that it might very quickly get out of<br/>&gt;&gt;&gt; hand. Consider:<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; pow(1, 1/pi() ) :any - 1<br/>&gt;&gt;&gt;<br/>&gt;&gt;&gt; (I think I got that right...)<br/>&gt;&gt;<br/>&gt;&gt; Not quite. Afaict the only functions that might return a junction are<br/>&gt;&gt; Complex.angle and Complex.log.<br/>&gt; <br/>&gt; Why is that? <br/><br/>As I pointed out above it&#39;s insane to return a junction of logically<br/>distinct values. It might even be insane to do it for Complex.log:<br/><br/>my $a = (Num::e * 1i).log.angle;<br/><br/>What do you expect $a to be?<br/><br/>Let&#39;s see, 1i can be written as exp(1i*(1/2 + 2 *$k) * pi), for Int $k.<br/>So log(Nom::e * 1i) would<br/>1 + any(..., -1.5 * pi, 0.5 * pi, 2.5 * pi, 4.5*pi)*1i<br/>if you imagine this, all these values have re = 1, and lie on a straight<br/>line. So their angle are discrete (but not dense) values between -pi and<br/>+pi. There&#39; no way you can represent that in finite space without a fair<br/>bit of algebra, something we don&#39;t want to burden on our implementors.<br/>And somehow I also don&#39;t think that meets the &quot;principle of least<br/>surprise&quot; criterion.<br/><br/>I think that I don&#39;t have to comment on the rest of the mail to make<br/>clear that Larry&#39;s proposal, although being quite interesting, is a very<br/>bad idea to actually implement (and very hard to implement as well)<br/>(unless somebody comes to its rescue with a really clever idea on how to<br/>resolve all these weirdnesses).<br/><br/>Cheers,<br/>Moritz<br/><br/>-- <br/>Moritz Lenz<br/>http://moritz.faui2k3.org/ | http://perl-6.de/<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29384.html Wed, 16 Jul 2008 15:05:53 +0000 Re: Complex planes by Jon Lang Moritz Lenz wrote:<br/>&gt; Jon Lang wrote:<br/>&gt;&gt; By the principle of least surprise, I&#39;d recommend against this. Most<br/>&gt;&gt; programmers, when they see &#39;sqrt(1)&#39;, will expect a return value of 1,<br/>&gt;<br/>&gt; And that&#39;s what they get unless they write it as sqrt(1 + 0i).<br/><br/>I suppose that you _could_ use the programmer&#39;s choice of whether or<br/>not to use complex numbers in the argument list as the indicator of<br/>whether to return one answer or a junction of them. Of course, this<br/>could lead to subtle bugs where the programmer assigns a complex value<br/>to $x and later takes the sqrt($x), but forgets that he assigned a<br/>complex number earlier. This may or may not be sufficient grounds for<br/>requiring an explicit declaration that you want junctions.<br/><br/>&gt;&gt; and won&#39;t want to jump through the hurdles involved in picking &#39;1&#39; out<br/>&gt;&gt; of &#39;any(1, -1)&#39;.<br/>&gt;<br/>&gt; 1 and -1 aren&#39;t just separated by a complex plane, they are really<br/>&gt; distinct numbers<br/><br/>True enough. I fail to see how that invalidates my point, though: if<br/>you&#39;re going to mess with multiple complex planes, why wouldn&#39;t you<br/>also address the issue of distinct numbers as well? The latter issue<br/>is intimately connected to the former, as I demonstrate below.<br/><br/>&gt;&gt; And even then, I&#39;m concerned that it might very quickly get out of<br/>&gt;&gt; hand. Consider:<br/>&gt;&gt;<br/>&gt;&gt; pow(1, 1/pi() ) :any - 1<br/>&gt;&gt;<br/>&gt;&gt; (I think I got that right...)<br/>&gt;<br/>&gt; Not quite. Afaict the only functions that might return a junction are<br/>&gt; Complex.angle and Complex.log.<br/><br/>Why is that? Complex numbers can exist on multiple complex planes<br/>even if you don&#39;t explicitly look at the angle. One example of this<br/>phenomenon in action takes the form of a &#39;proof&#39; that 1 == -1:<br/><br/> 1 == sqrt(1) == sqrt(-1 * -1) == sqrt(-1) * sqrt(-1) == i * i == -1<br/>#&lt; Assumes complex numbers throughout. &gt;<br/><br/>The equality between the first and second steps means that the 1<br/>inside the sqrt can only have an angle that is a multiple of 4pi.<br/>Because of this, the -1&#39;s that appear in the third step cannot exist<br/>on the same complex plane with each other: e.g., if the first one has<br/>an angle of pi, the second has to have an angle of -pi, 3pi, 7pi,<br/>11pi, ... As a result of this, the signs of the sqrts in the fourth<br/>step must be opposed: if the first sqrt(-1) returns i, the second<br/>sqrt(-1) must return -i, and vice versa. That means that there&#39;s a<br/>negative term missing in the fifth step, which would cancel out the<br/>negative term that appears in the final step. At the very least, we<br/>need to add infix:&lt;**&gt; and all related functions (e.g., sqrt) to the<br/>list of functions that might return a junction.<br/><br/>And when and if Perl 6 adds constraint programming to its repertoire,<br/>it will have to be smart enough to properly constrain complex planes<br/>as well as complex values.<br/><br/>--<br/><br/>Bringing this back down a bit closer to Earth: if you supply a complex<br/>number using rectilinear coordinates, a case could be made that you&#39;ve<br/>provided insufficient information, and that the complex number ought<br/>to be stored as a junction of all of the different complex plane<br/>representations for that otherwise-distinct value. If you supply a<br/>complex number using polar coordinates, you have been able to supply<br/>the choice of complex plane as well as a distinct value; so only one<br/>representation should be stored. That is:<br/><br/> (1 + 0 * i).angle == any (0, 2 * pi, 4 * pi, ...);<br/> exp(0 * i).angle == 0;<br/> exp(2 * pi * i).angle == 2 * pi;<br/><br/>So:<br/><br/> (1 + 0 * i) == any (exp(0), exp(2 * pi * i), exp(4 * pi * i), ...);<br/><br/>Extending this further: exp($C) effectively reinterprets a complex<br/>number&#39;s rectilinear coordinates as polar coordinates, and log($C)<br/>does the inverse. So as long as $C contains a single value, exp($C)<br/>should always return a complex number that exists on a single complex<br/>plane, established by $C&#39;s imaginary component; conversely, log($C)<br/>ought to return a complex value that is represented on every possible<br/>complex plane, since neither the angle nor the magnitude of $C<br/>provides enough information to determine which plane to use.<br/><br/>Of course, there may be (and probably are) technical difficulties that<br/>make this unworkable.<br/><br/>&gt;&gt; Since pi is an irrational number, there are infinitely many distinct<br/>&gt;&gt; results to raising 1 to the power of 1/pi.<br/>&gt;<br/>&gt; No. exp($x) is a single, well-defined value.<br/><br/>True, as long as $x is a single, well-defined value.<br/><br/>But I wasn&#39;t talking about exp($x); I was talking about pow($x, $y),<br/>$x ** $y, sqrt($x), and so on. Just as:<br/><br/> sqrt(1 + 0 * i) == sqrt(any(exp(0), exp(2 * pi * i), exp(4 * pi *<br/>i), ...)) == any(exp(0), exp(pi * i), exp(2 * pi * i), ...)<br/><br/>it is also the case that:<br/><br/> (1 + 0 * i) ** pi == any(exp(0), exp(2 * pi * i), exp(4 * pi * i),<br/>...) ** pi == any(exp(0), exp(2 * pi * pi * i), exp(4 * pi * pi * i),<br/>...)<br/><br/>And all of those answers are distinct values.<br/><br/>&gt; But you do have a point that we can&#39;t really use infinite junctions<br/>&gt; unless we can ensure that we can do all sorts of arithmetics with it<br/>&gt; without losing laziness. And I don&#39;t think we can prove that (but I<br/>&gt; might give it it shot if I have some spare time)<br/><br/>Just noting that we&#39;re not totally in disagreement. :P<br/><br/>-- <br/>Jonathan &quot;Dataweaver&quot; Lang<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29383.html Wed, 16 Jul 2008 14:17:47 +0000 [svn:perl6-synopsis] r14563 - doc/trunk/design/syn by larry Author: larry<br/>Date: Wed Jul 16 12:56:34 2008<br/>New Revision: 14563<br/><br/>Modified:<br/> doc/trunk/design/syn/S04.pod<br/><br/>Log:<br/>[S04] another whack at defining consistent closure semantics<br/><br/><br/>Modified: doc/trunk/design/syn/S04.pod<br/>==============================================================================<br/>--- doc/trunk/design/syn/S04.pod (original)<br/>+++ doc/trunk/design/syn/S04.pod Wed Jul 16 12:56:34 2008<br/>@@ -12,9 +12,9 @@<br/> <br/> Maintainer: Larry Wall &lt;larry@wall.org&gt;<br/> Date: 19 Aug 2004<br/>- Last Modified: 12 July 2008<br/>+ Last Modified: 16 July 2008<br/> Number: 4<br/>- Version: 66<br/>+ Version: 67<br/> <br/> This document summarizes Apocalypse 4, which covers the block and<br/> statement syntax of Perl.<br/>@@ -1253,27 +1253,64 @@<br/> is free to turn unreferenced closures into mere blocks of code.<br/> It is also free to turn referenced closures into mere anonymous<br/> subroutines if the block does not refer to any external lexicals that<br/>-should themselves be cloned. In particular, named subroutines in any<br/>-scope do not consider themselves closures unless you take a reference<br/>-to them. So<br/>+should themselves be cloned. (When we say &quot;clone&quot;, we mean the way<br/>+the system takes a snapshot of the routine&#39;s lexical scope and binds<br/>+it to the current instance of the routine so that if you ever use<br/>+the current reference to the routine, it gets the current snapshot<br/>+of its world in terms of the lexical symbols that are visible to it.)<br/>+<br/>+All remaining blocks are conceptually cloned into closures as soon<br/>+as the lexical scope containing them is entered. (This may be done<br/>+lazily as long as consistent semantics are preserved, so a block<br/>+that is never executed and never has a reference taken can avoid<br/>+cloning altogether. Execution or reference taking forces cloning<br/>+in this case--references are not allowed to be lazily cloned, since<br/>+no guarantee can be made that the scope needed for cloning will<br/>+remain in existence over the life of the reference.)<br/>+<br/>+In particular, named subroutines are a special problem when embedded in<br/>+a changing lexical scope (when they make reference to it). The binding<br/>+of such a definition to a name within a symbol table counts as taking<br/>+a reference, so at compile time there is an initial C&lt;::=&gt; binding<br/>+to the symbol table entry in question. For &quot;global&quot; bindings to<br/>+symbol tables visible at compile time, this binds to the compile-time<br/>+view of the lexical scopes. (At run-time, the initial run-time view<br/>+of these scopes is copied from the compiler&#39;s view of them, so that<br/>+initializations carry over, for instance.) At run time, whenever such<br/>+a subroutine needs to be cloned, an additional C&lt;:=&gt; binding is done<br/>+at clone time to the same symbol table entry that the original C&lt;::=&gt;<br/>+was bound to. (The binding is not restored on exit from the current<br/>+lexical scope; this C&lt;:=&gt; binding records the I&lt;last&gt; cloning, not<br/>+the currently in-use cloning, so any use of the global reference must<br/>+take into consideration that it is functioning only as a cache of the<br/>+most recent cloning, not as a surrogate for the current lexical scope.)<br/>+<br/>+Lexical names do not share this problem, since the symbol goes out<br/>+of scope synchronously with its usage. Unlike global subs, they<br/>+do not need a compile-time C&lt;::=&gt; binding, but like global subs,<br/>+they perform a C&lt;:=&gt; binding to the lexical symbol at clone time<br/>+(again, conceptually at the entry to the outer lexical scope, but<br/>+possible deferred.)<br/> <br/> sub foo {<br/>+ # conceptual cloning happens to both blocks below<br/> my $x = 1;<br/>- my sub bar { print $x } # not cloned yet<br/>- my &amp;baz = { bar(); print $x }; # cloned immediately<br/>- my $code = &amp;bar; # now bar is cloned<br/>+ my sub bar { print $x } # already conceptualy cloned, but can be lazily deferred<br/>+ my &amp;baz := { bar(); print $x }; # block is cloned immediately, forcing cloning of bar<br/>+ my $code = &amp;bar; # this would also force bar to be cloned<br/> return &amp;baz;<br/> }<br/> <br/>-When we say &quot;clone&quot;, we mean the way the system takes a snapshot of the<br/>-routine&#39;s lexical scope and binds it to the current instance of the routine<br/>-so that if you ever use the current reference to the routine, it gets<br/>-the current snapshot of its world, lexically speaking. (When we say that<br/>-named subroutines do not consider themselves closures, this is a bit of a<br/>-fib, since we must, in fact, take a reference to the subroutine in order to<br/>-store it into the symbol table! But this operation happens at compile time<br/>-so the lexical scopes in view are just the initial prototype lexical scopes<br/>-visible to the compiler.)<br/>+In particular, blocks of inline control flow need not be cloned until<br/>+called. [Note: this is currently a potential problem for user-defined<br/>+constructs, since you have to take references to blocks to pass them<br/>+to whatever is managing the control flow. Perhaps the laziness can<br/>+be deferred through Captures to binding time, so a slurpy of block<br/>+refs doesn&#39;t clone them all prematurely. On the other hand, this<br/>+either means the Capture must be smart enough to keep track of the<br/>+lexical scope it came from so that it can pass the info to the cloner,<br/>+or it means that we need some special fat not-cloned-yet references<br/>+that can carry the info lazily. Neither approach is pretty.]<br/> <br/> Some closures produce C&lt;Code&gt; objects at compile time that cannot be<br/> cloned, because they&#39;re not attached to any runtime code that can<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29382.html Wed, 16 Jul 2008 12:56:45 +0000 Re: Complex planes by Moritz Lenz Jon Lang wrote:<br/>&gt; Larry Wall wrote:<br/>&gt;&gt; On Tue, Jul 15, 2008 at 03:30:24PM +0200, Moritz Lenz wrote:<br/>&gt;&gt; : Today bacek++ implement complex logarithms in rakudo, and one of the<br/>&gt;&gt; : tests failed because it assumed the result to be on a different complex<br/>&gt;&gt; : plane. (log(-1i) returned 0- 1.5708i, while 0 + 3/2*1i was expected).<br/>&gt;&gt; :<br/>&gt;&gt; : Should we standardize on one complex plane (for example -pi &lt;= $c.angle<br/>&gt;&gt; : &lt; pi like Complex.angle does)? Or simply fix the test to be agnostic to<br/>&gt;&gt; : complex planes?<br/>&gt;&gt;<br/>&gt;&gt; Standardizing on one complex plane is the normal solution, though<br/>&gt;&gt; this being Perl 6, there&#39;s probably a better solution using infinite<br/>&gt;&gt; Junctions if we can assume them to be both sufficiently lazy and<br/>&gt;&gt; sufficiently intelligent... :)<br/>&gt; <br/>&gt; By the principle of least surprise, I&#39;d recommend against this. Most<br/>&gt; programmers, when they see &#39;sqrt(1)&#39;, will expect a return value of 1,<br/><br/>And that&#39;s what they get unless they write it as sqrt(1 + 0i).<br/><br/>&gt; and won&#39;t want to jump through the hurdles involved in picking &#39;1&#39; out<br/>&gt; of &#39;any(1, -1)&#39;. <br/><br/>1 and -1 aren&#39;t just separated by a complex plain, they are really<br/>distinct numbers<br/><br/>&gt; That said, I&#39;m not necessarily opposed to these<br/>&gt; functions including something like an &#39;:any&#39; or &#39;:all&#39; adverb that<br/>&gt; causes them to return a junction of all possible answers; but this<br/>&gt; should be something that you have to explicitly ask for.<br/>&gt; <br/>&gt; And even then, I&#39;m concerned that it might very quickly get out of<br/>&gt; hand. Consider:<br/>&gt; <br/>&gt; pow(1, 1/pi() ) :any - 1<br/>&gt; <br/>&gt; (I think I got that right...)<br/><br/>Not quite. Afaict the only functions that might return a junction are<br/>Complex.angle and Complex.log.<br/><br/>But having<br/> $compl.angle &gt; pi<br/>always yield True would be quite weird ;-)<br/><br/>&gt; Since pi is an irrational number, there are infinitely many distinct<br/>&gt; results to raising 1 to the power of 1/pi.<br/><br/>No. exp($x) is a single, well-defined value.<br/><br/>&gt; (All but one of them are<br/>&gt; complex numbers, and all of them have a magnitude of 1, differing only<br/>&gt; in their angles.) Thus, pow(1, 1/pi() ) :any would have to return a<br/>&gt; junction of an indefinitely long lazy list. Now subtract 1 from that<br/>&gt; junction. Do you have to flatten the list in order to do so,<br/>&gt; subtracting one from each item in the list? <br/><br/>Obviously we&#39;d have to avoid that if there&#39;s any infinite list/junction<br/>involved somewhere ;-)<br/><br/>But you do have a point that we can&#39;t really use infinite junctions<br/>unless we can ensure that we can do all sorts of arithmetics with it<br/>without loosing lazyness. And I don&#39;t think we can prove that (but I<br/>might give it it shot if I have some spare time)<br/><br/>&gt; Or is there a reasonable<br/>&gt; way to modify the list generator to incorporate the subtraction?<br/>&gt; <br/>&gt; Or how about:<br/>&gt; <br/>&gt; sqrt(1):any + sqrt(1):any<br/>&gt; <br/>&gt; --<br/>&gt; <br/>&gt; In any case, there&#39;s the matter of what to do when you only want one<br/>&gt; answer, and not a junction of them. IMHO, we should standardize the<br/>&gt; angles on &#39;-pi ^.. pi&#39;. My reasoning is as follows: if the imaginary<br/>&gt; component is positive, the angle should be positive; if the imaginary<br/>&gt; component is negative, the angle should be negative. If the imaginary<br/>&gt; component is zero and the real component is not negative, the angle<br/>&gt; should be zero. And the square root of -1 should be i, not -i; so if<br/>&gt; the imaginary component is zero and the real component is negative,<br/>&gt; the angle should be positive, not negative.<br/>&gt; <br/><br/><br/>-- <br/>Moritz Lenz<br/>http://moritz.faui2k3.org/ | http://perl-6.de/<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29381.html Wed, 16 Jul 2008 12:33:01 +0000 Re: Complex planes by Jon Lang Larry Wall wrote:<br/>&gt; On Tue, Jul 15, 2008 at 03:30:24PM +0200, Moritz Lenz wrote:<br/>&gt; : Today bacek++ implement complex logarithms in rakudo, and one of the<br/>&gt; : tests failed because it assumed the result to be on a different complex<br/>&gt; : plane. (log(-1i) returned 0- 1.5708i, while 0 + 3/2*1i was expected).<br/>&gt; :<br/>&gt; : Should we standardize on one complex plane (for example -pi &lt;= $c.angle<br/>&gt; : &lt; pi like Complex.angle does)? Or simply fix the test to be agnostic to<br/>&gt; : complex planes?<br/>&gt;<br/>&gt; Standardizing on one complex plane is the normal solution, though<br/>&gt; this being Perl 6, there&#39;s probably a better solution using infinite<br/>&gt; Junctions if we can assume them to be both sufficiently lazy and<br/>&gt; sufficiently intelligent... :)<br/><br/>By the principle of least surprise, I&#39;d recommend against this. Most<br/>programmers, when they see &#39;sqrt(1)&#39;, will expect a return value of 1,<br/>and won&#39;t want to jump through the hurdles involved in picking &#39;1&#39; out<br/>of &#39;any(1, -1)&#39;. That said, I&#39;m not necessarily opposed to these<br/>functions including something like an &#39;:any&#39; or &#39;:all&#39; adverb that<br/>causes them to return a junction of all possible answers; but this<br/>should be something that you have to explicitly ask for.<br/><br/>And even then, I&#39;m concerned that it might very quickly get out of<br/>hand. Consider:<br/><br/> pow(1, 1/pi() ) :any - 1<br/><br/>(I think I got that right...)<br/><br/>Since pi is an irrational number, there are infinitely many distinct<br/>results to raising 1 to the power of 1/pi. (All but one of them are<br/>complex numbers, and all of them have a magnitude of 1, differing only<br/>in their angles.) Thus, pow(1, 1/pi() ) :any would have to return a<br/>junction of an indefinitely long lazy list. Now subtract 1 from that<br/>junction. Do you have to flatten the list in order to do so,<br/>subtracting one from each item in the list? Or is there a reasonable<br/>way to modify the list generator to incorporate the subtraction?<br/><br/>Or how about:<br/><br/> sqrt(1):any + sqrt(1):any<br/><br/>--<br/><br/>In any case, there&#39;s the matter of what to do when you only want one<br/>answer, and not a junction of them. IMHO, we should standardize the<br/>angles on &#39;-pi ^.. pi&#39;. My reasoning is as follows: if the imaginary<br/>component is positive, the angle should be positive; if the imaginary<br/>component is negative, the angle should be negative. If the imaginary<br/>component is zero and the real component is not negative, the angle<br/>should be zero. And the square root of -1 should be i, not -i; so if<br/>the imaginary component is zero and the real component is negative,<br/>the angle should be positive, not negative.<br/><br/>-- <br/>Jonathan &quot;Dataweaver&quot; Lang<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29380.html Wed, 16 Jul 2008 12:15:49 +0000 Re: meta_postfix:<*> by Larry Wall On Sun, Jul 13, 2008 at 12:46:30PM +0200, TSa (Thomas Sandla&szlig;) wrote:<br/>: HaloO,<br/>: <br/>: I know that the hot phase of the operator discussions are over.<br/>: But here&#39;s a little orthogonalizing idea from my side. The observation<br/>: is that * can be regarded as repeated addition: 5 * 3 == 5 + 5 + 5<br/>: and ** as repeated multiplication. Now imagine having a meta_postfix:&lt;*&gt;<br/>: that gives +* as multiplication (perhaps abbreviated as *) and ** as<br/>: (integer) exponentiation. We can then continue with replication as ~*<br/>: for strings and ,* for lists thus freeing x and xx as some generic<br/>: multiplication operators.<br/><br/>I think this is not going to fly from the standpoint of keeping common<br/>operators visually distinct. Also, how will you parse 1..* and such?<br/><br/>(Another consideration is that every time you add another metaoperator<br/>you&#39;re potentially exploding the number of operators that the longest<br/>token matcher needs to deal with, though STD currently cheats on this.)<br/><br/>: The meta * also is useful e.g. as (1,2) Z* 3 === (1,1,1),(2,2,2). Also<br/>: when we apply it to unary postfix as well: $x++* 3 === $x++.++.++ which<br/>: is useful when $x is of some class with overloaded ++ where the single<br/>: steps are important. The meta postfix * could also be stacked and tetration<br/>: falls out naturally as ***.<br/><br/>Speaking on behalf of the mere mortal, My Eyes Glaze Over.<br/><br/>Speaking as a parser writer, you&#39;re confusing the parser with a<br/>metaoperator that changes expectation of term vs infix.<br/><br/>Sepaking as a programmer, $x++.++.++ won&#39;t do what you seem to think it does.<br/><br/>: With + as the default case for meta_postfix:&lt;*&gt; we win the advantage that<br/>: we have +* and * as multiplication operators with the latter being a special<br/>: form of the former. But for Vectors +* would automatically yield the scalar<br/>: multiplication infix:&lt;+*&gt;:(Vector,Num) when infix:&lt;+&gt;:(Vector,Vector) is<br/>: defined as expected.<br/><br/>You can, of course, do anything you like with your own copy, but the<br/>standard reserves most of Unicode as the playground of mathematicians,<br/>so please leave our poor little * alone. :)<br/><br/>Larry<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29379.html Wed, 16 Jul 2008 10:43:44 +0000 Re: Complex planes by Larry Wall On Tue, Jul 15, 2008 at 03:30:24PM +0200, Moritz Lenz wrote:<br/>: Today bacek++ implement complex logarithms in rakudo, and one of the<br/>: tests failed because it assumed the result to be on a different complex<br/>: plane. (log(-1i) returned 0- 1.5708i, while 0 + 3/2*1i was expected).<br/>: <br/>: Should we standardize on one complex plane (for example -pi &lt;= $c.angle<br/>: &lt; pi like Complex.angle does)? Or simply fix the test to be agnostic to<br/>: complex planes?<br/><br/>Standardizing on one complex plane is the normal solution, though<br/>this being Perl 6, there&#39;s probably a better solution using infinite<br/>Junctions if we can assume them to be both sufficiently lazy and<br/>sufficiently intelligent... :)<br/><br/>Larry<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29378.html Wed, 16 Jul 2008 10:10:29 +0000 Re: $foo[0][0] versus $foo[0;0] by Larry Wall On Sun, Jul 13, 2008 at 02:17:10PM -0500, Adrian Kreher wrote:<br/>: Hi,<br/>: <br/>: I&#39;m reviewing the tests in S09, and the file <br/>: t/spec/S02-builtin_data_types/multi_dimensional_array.t uses the [0][0] <br/>: indexing format interchangeably with [0;0].<br/>: <br/>: These two formats mean two different things, correct? The [0][0] form isn&#39;t <br/>: mentioned much in the spec, nor is [0;0] or if they interact somehow.<br/><br/>I think they should come out to meaning the same thing, though the<br/>[0][0] form may be less efficient if it has to temporarily construct<br/>a slice of the next dimension of the array. On the other hand, a<br/>na&iuml;ve implementation of the multidimensional subscripter might just do<br/>the same thing internally for the semicolon, so it could be a wash.<br/><br/>Larry<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29377.html Wed, 16 Jul 2008 10:04:34 +0000 Re: Parrot 0.6.4 by François Perrad Bernhard Schmalhofer a &eacute;crit :<br/>&gt; Hi,<br/>&gt; <br/>&gt; on behalf of the Parrot team, I&#39;m proud to announce the release of <br/>&gt; Parrot 0.6.4<br/>&gt; &quot;St. Vincent Amazon.&quot;<br/>&gt; <br/><br/>As usual, the Windows setup is available on <br/>http://parrotwin32.sourceforge.net/<br/><br/>Fran&ccedil;ois.<br/><br/>&gt; Parrot 0.6.4 is available via CPAN, or follow the download<br/>&gt; instructions at http://parrotcode.org/source.html. For those who would <br/>&gt; like to develop on<br/>&gt; Parrot, or help develop Parrot itself, we recommend using Subversion on<br/>&gt; the source code repository to get the latest and best Parrot code.<br/>&gt; <br/>&gt; Parrot 0.6.4 News:<br/>&gt; - Documentation<br/>&gt; + removed a lot of old information from the FAQ<br/>&gt; + improved function level documentation<br/>&gt; - Configuration<br/>&gt; + removed the configuration item &#39;has_gnu_m4&#39;<br/>&gt; + refactored ICU-detection<br/>&gt; - Languages<br/>&gt; + ChitChat<br/>&gt; - improved the Smalltalk implementation<br/>&gt; + Pipp<br/>&gt; - renamed Plumhead to Pipp<br/>&gt; - support for a lot of builtin functions.<br/>&gt; - Pipp now uses PHP specific data types.<br/>&gt; - converted from PCT with TGE to PCT with NQP actions<br/>&gt; - improvements in the PCT variant by using optok parsing<br/>&gt; - start of object support<br/>&gt; + pir<br/>&gt; - simple assignments work<br/>&gt; + json<br/>&gt; - added a PCT-based implementation of JSON parsing<br/>&gt; + lolcode<br/>&gt; - improved handling of symbols<br/>&gt; - added support for block handling<br/>&gt; - added support for globals<br/>&gt; + Lua<br/>&gt; - more tests<br/>&gt; + Rakudo<br/>&gt; - updated Range implementation<br/>&gt; - added enums<br/>&gt; - added generic type declarations (::T)<br/>&gt; - added runtime mixing of roles with &#39;does&#39; and &#39;but&#39;<br/>&gt; - added generic type declarations<br/>&gt; - fixed handling of implicit lexicals ($_, $!, and $/)<br/>&gt; - fixed implicit method calls on $_<br/>&gt; - improved complex math builtins, added Complex<br/>&gt; - moved many builtins to class Any<br/>&gt; - declaration of lists of variables now work<br/>&gt; - improved test infrastructure<br/>&gt; - 910 additional passing spec tests since last release<br/>&gt; - more convergence with STD.pm grammar<br/>&gt; - added named 0-ary parsing and ops<br/>&gt; - Compilers<br/>&gt; + PCT:<br/>&gt; - allowed subroutine and method names to be a PAST tree that produces <br/>&gt; the name<br/>&gt; - Improved lexical handling<br/>&gt; - Tools<br/>&gt; + pbc_disassemble renamed from disassemble<br/>&gt; - Implementation<br/>&gt; + allowed .macro_const in PIR<br/>&gt; + added the flag :lexid(...) for subroutines<br/>&gt; + made multiple dispatch work for sub types<br/>&gt; + fixed garbage collection bug related to the metadata attached to a <br/>&gt; PMC_EXT structure<br/>&gt; + added a warning when using deprecated opcodes<br/>&gt; + simplified the stacks implementation<br/>&gt; + fixed C++ build<br/>&gt; + improved closure and lexical support<br/>&gt; + improved IMCC register allocator<br/>&gt; + added cache for all runtime-constant strings, reducing memory usage<br/>&gt; - Miscellaneous<br/>&gt; + improved OpenGL/GLU/GLUT bindings<br/>&gt; + added a standard profile for Perl::Critic coding standard testing<br/>&gt; + added support for smoke testing with Smolder<br/>&gt; + enabled use of Test::Harness 3.0 if available, but don&#39;t require it <br/>&gt; for &#39;make test&#39;<br/>&gt; + added the executable &#39;parrot_config&#39; to query Parrot configuration<br/>&gt; <br/>&gt; <br/>&gt; Many thanks to all our contributors for making this possible, and our <br/>&gt; sponsors<br/>&gt; for supporting this project. Our next scheduled release is August 19th <br/>&gt; 2008.<br/>&gt; <br/>&gt; Enjoy!<br/>&gt; <br/>&gt; <br/>&gt; <br/>&gt; <br/>&gt; <br/><br/><br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29376.html Wed, 16 Jul 2008 05:19:24 +0000 Re: meta_postfix:<*> by Jon Lang Kealey, Martin, wrote:<br/>&gt; Nice idea; introduces one particular ambiguity though: would<br/>&gt;<br/>&gt; $m ** $n<br/>&gt;<br/>&gt; then be<br/>&gt;<br/>&gt; pow($m, $n)<br/>&gt;<br/>&gt; or<br/>&gt;<br/>&gt; pow($n, $m)<br/>&gt;<br/>&gt; ?<br/><br/>Neither. As with the reducing meta-operator, you would need to have<br/>the ability to define an operator that takes precedence over a meta&#39;d<br/>operator, for those cases where a particular combination of symbols<br/>has a meaning that is either more broad or incompatible with what the<br/>replication meta would supply. Conveniently, &#39;**&#39; is one such<br/>operator. To whit:<br/><br/>In &#39;$count *op $value&#39; and &#39;$value op* $count&#39;, $count must be an<br/>unsigned integer of some sort: it&#39;s nonsense to replicate an operation<br/>half of a time, or negative two times, or i times. However, &#39;$base **<br/>$power&#39; places no such restrictions on either $base or $power; thus,<br/>it needs to be separately defined. The fact that its behavior<br/>coincides with a replicator appended to a multiplication operator when<br/>the power is an unsigned integer is merely a convenient coincidence as<br/>far as the compiler is concerned.<br/><br/>That said, there _is_ still some potential ambiguity if you have<br/>operators that begin or end with &#39;*&#39;. For instance: let&#39;s say that<br/>you want to apply replication to exponentials: does &#39;$m *** $n&#39; mean<br/>&#39;$m repetitions of $n ** $n&#39;, or does it mean &#39;$m ** $m, repeated $n<br/>times&#39;? The longest-token rule resolves this dilemma in favor of the<br/>latter.<br/><br/>-- <br/>Jonathan &quot;Dataweaver&quot; Lang<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29375.html Tue, 15 Jul 2008 20:45:51 +0000 Re: meta_postfix:<*> by Jon Lang Dave Whipp wrote:<br/><br/>&gt; Jon Lang wrote:<br/>&gt;<br/>&gt;&gt; So you&#39;re suggesting that<br/>&gt;&gt;<br/>&gt;&gt; A op* n<br/>&gt;&gt;<br/>&gt;&gt; should map to<br/>&gt;&gt;<br/>&gt;&gt; [op] A xx n<br/>&gt;&gt;<br/>&gt;<br/>&gt; I don&#39;t think that that mapping works for Thomas&#39; proposal of a repetition<br/>&gt; count on post-increment operator. I.e.<br/>&gt;<br/>&gt; $a ++* 3<br/>&gt;<br/>&gt; is not the same as<br/>&gt;<br/>&gt; [++] $a xx 3<br/>&gt;<br/>&gt; (which I think is a syntax error)<br/><br/><br/>It is.<br/><br/><br/>&gt; Also, he&#39;s suggesting getting rid of the &quot;xx&quot; operator, and replacing it<br/>&gt; with &quot;,*&quot; -- I&#39;m sure I could get used to that<br/>&gt;<br/><br/>Currently, it&#39;s being assumed that the repetition meta-operator will be<br/>appended to the operator, followed by the repetition count:<br/><br/> $value op* $count<br/><br/>This makes it difficult to apply the replication meta-operator to a prefix<br/>operator. However, a second option could be provided, where the<br/>meta-operator gets prepended:<br/><br/> $count *op $value<br/><br/>So:<br/><br/> 5 *, $n === $n ,* 5 === $n, $n, $n, $n, $n<br/> $n ++* 5 === (((($n++)++)++)++)++<br/> 5 *++ $n === ++(++(++(++(++$n))))<br/><br/>And obviously the metaoperator is nonsensical when applied to a binary<br/>operator with different types of values on its left and right sides.<br/><br/>As with other meta-operators, it should be possible to explicitly define a<br/>symbol that would otherwise be interpreted as a meta&#39;d operator, because of<br/>efficiency; because the operator in question has capabilities above and<br/>beyond what the meta-operator would indicate; or because the operator in<br/>question doesn&#39;t bear any resemblance to the replicated use of a shorter<br/>operator. In particular, ** would be overloaded in this manner: to make<br/>reasonable sense, the count of a repetition meta-operator must be an<br/>unsigned integer of some sort, whereas exponents can be any type of number.<br/>Heck, they don&#39;t even have to be real.<br/><br/>-- <br/>Jonathan &quot;Dataweaver&quot; Lang<br/><br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29374.html Tue, 15 Jul 2008 16:56:25 +0000 Re: meta_postfix:<*> by Dave Whipp Jon Lang wrote:<br/>&gt; So you&#39;re suggesting that<br/>&gt; <br/>&gt; A op* n<br/>&gt; <br/>&gt; should map to<br/>&gt; <br/>&gt; [op] A xx n<br/><br/>I don&#39;t think that that mapping works for Thomas&#39; proposal of a <br/>repetition count on post-increment operator. I.e.<br/><br/> $a ++* 3<br/><br/>is not the same as<br/><br/> [++] $a xx 3<br/><br/>(which I think is a syntax error)<br/><br/>and also not the same as<br/><br/> $a++ * 3<br/><br/>Also, he&#39;s suggesting getting rid of the &quot;xx&quot; operator, and replacing it <br/>with &quot;,*&quot; -- I&#39;m sure I could get used to that<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29373.html Tue, 15 Jul 2008 16:20:03 +0000 Parrot 0.6.4 by Bernhard Schmalhofer Hi,<br/><br/>on behalf of the Parrot team, I&#39;m proud to announce the release of <br/>Parrot 0.6.4<br/>&quot;St. Vincent Amazon.&quot;<br/><br/>Parrot 0.6.4 is available via CPAN, or follow the download<br/>instructions at http://parrotcode.org/source.html. For those who would <br/>like to develop on<br/>Parrot, or help develop Parrot itself, we recommend using Subversion on<br/>the source code repository to get the latest and best Parrot code.<br/><br/>Parrot 0.6.4 News:<br/>- Documentation<br/> + removed a lot of old information from the FAQ<br/> + improved function level documentation<br/>- Configuration<br/> + removed the configuration item &#39;has_gnu_m4&#39;<br/> + refactored ICU-detection<br/>- Languages<br/> + ChitChat<br/> - improved the Smalltalk implementation<br/> + Pipp<br/> - renamed Plumhead to Pipp<br/> - support for a lot of builtin functions.<br/> - Pipp now uses PHP specific data types.<br/> - converted from PCT with TGE to PCT with NQP actions<br/> - improvements in the PCT variant by using optok parsing<br/> - start of object support<br/> + pir<br/> - simple assignments work<br/> + json<br/> - added a PCT-based implementation of JSON parsing<br/> + lolcode<br/> - improved handling of symbols<br/> - added support for block handling<br/> - added support for globals<br/> + Lua<br/> - more tests<br/> + Rakudo<br/> - updated Range implementation<br/> - added enums<br/> - added generic type declarations (::T)<br/> - added runtime mixing of roles with &#39;does&#39; and &#39;but&#39;<br/> - added generic type declarations<br/> - fixed handling of implicit lexicals ($_, $!, and $/)<br/> - fixed implicit method calls on $_<br/> - improved complex math builtins, added Complex<br/> - moved many builtins to class Any<br/> - declaration of lists of variables now work<br/> - improved test infrastructure<br/> - 910 additional passing spec tests since last release<br/> - more convergence with STD.pm grammar<br/> - added named 0-ary parsing and ops<br/>- Compilers<br/> + PCT:<br/> - allowed subroutine and method names to be a PAST tree that <br/>produces the name<br/> - Improved lexical handling<br/>- Tools<br/> + pbc_disassemble renamed from disassemble<br/>- Implementation<br/> + allowed .macro_const in PIR<br/> + added the flag :lexid(...) for subroutines<br/> + made multiple dispatch work for sub types<br/> + fixed garbage collection bug related to the metadata attached to a <br/>PMC_EXT structure<br/> + added a warning when using deprecated opcodes<br/> + simplified the stacks implementation<br/> + fixed C++ build<br/> + improved closure and lexical support<br/> + improved IMCC register allocator<br/> + added cache for all runtime-constant strings, reducing memory usage<br/>- Miscellaneous<br/> + improved OpenGL/GLU/GLUT bindings<br/> + added a standard profile for Perl::Critic coding standard testing<br/> + added support for smoke testing with Smolder<br/> + enabled use of Test::Harness 3.0 if available, but don&#39;t require it <br/>for &#39;make test&#39;<br/> + added the executable &#39;parrot_config&#39; to query Parrot configuration<br/><br/><br/>Many thanks to all our contributors for making this possible, and our <br/>sponsors<br/>for supporting this project. Our next scheduled release is August 19th <br/>2008.<br/><br/>Enjoy!<br/><br/><br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29372.html Tue, 15 Jul 2008 07:51:39 +0000 Complex planes by Moritz Lenz Today bacek++ implement complex logarithms in rakudo, and one of the<br/>tests failed because it assumed the result to be on a different complex<br/>plane. (log(-1i) returned 0- 1.5708i, while 0 + 3/2*1i was expected).<br/><br/>Should we standardize on one complex plane (for example -pi &lt;= $c.angle<br/>&lt; pi like Complex.angle does)? Or simply fix the test to be agnostic to<br/>complex planes?<br/><br/>Cheers,<br/>Moritz<br/><br/>-- <br/>Moritz Lenz<br/>http://moritz.faui2k3.org/ | http://perl-6.de/<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29371.html Tue, 15 Jul 2008 06:30:46 +0000 $foo[0][0] versus $foo[0;0] by Adrian Kreher Hi,<br/><br/>I&#39;m reviewing the tests in S09, and the file <br/>t/spec/S02-builtin_data_types/multi_dimensional_array.t uses the [0][0] <br/>indexing format interchangeably with [0;0].<br/><br/>These two formats mean two different things, correct? The [0][0] form isn&#39;t <br/>mentioned much in the spec, nor is [0;0] or if they interact somehow.<br/><br/>Thanks,<br/>-- <br/>Adrian Kreher<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29370.html Sun, 13 Jul 2008 12:17:27 +0000 Re: meta_postfix:<*> by Jon Lang So you&#39;re suggesting that<br/><br/> A op* n<br/><br/>should map to<br/><br/> [op] A xx n<br/><br/>?<br/><br/>-- <br/>Jonathan &quot;Dataweaver&quot; Lang<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29369.html Sun, 13 Jul 2008 10:01:59 +0000 meta_postfix:<*> by TSa HaloO,<br/><br/>I know that the hot phase of the operator discussions are over.<br/>But here&#39;s a little orthogonalizing idea from my side. The observation<br/>is that * can be regarded as repeated addition: 5 * 3 == 5 + 5 + 5<br/>and ** as repeated multiplication. Now imagine having a meta_postfix:&lt;*&gt;<br/>that gives +* as multiplication (perhaps abbreviated as *) and ** as<br/>(integer) exponentiation. We can then continue with replication as ~*<br/>for strings and ,* for lists thus freeing x and xx as some generic<br/>multiplication operators.<br/><br/>The meta * also is useful e.g. as (1,2) Z* 3 === (1,1,1),(2,2,2). Also<br/>when we apply it to unary postfix as well: $x++* 3 === $x++.++.++ which<br/>is useful when $x is of some class with overloaded ++ where the single<br/>steps are important. The meta postfix * could also be stacked and tetration<br/>falls out naturally as ***.<br/><br/>With + as the default case for meta_postfix:&lt;*&gt; we win the advantage that<br/>we have +* and * as multiplication operators with the latter being a special<br/>form of the former. But for Vectors +* would automatically yield the scalar<br/>multiplication infix:&lt;+*&gt;:(Vector,Num) when infix:&lt;+&gt;:(Vector,Vector) is<br/>defined as expected.<br/><br/><br/>Regards, TSa.<br/>-- <br/>&quot;The unavoidable price of reliability is simplicity&quot; -- C.A.R. Hoare<br/>&quot;Simplicity does not precede complexity, but follows it.&quot; -- A.J. Perlis<br/>1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29368.html Sun, 13 Jul 2008 03:46:48 +0000 S04-related closure question by Patrick R. Michaud What would be the expected output from the following?<br/><br/> my $a = foo();<br/> my $b;<br/><br/> {<br/> my $x = 1;<br/> sub get_x() { return $x; }<br/> sub foo() { return &amp;get_x; }<br/> $b = foo();<br/> }<br/><br/> my $c = foo();<br/><br/> say &quot;a: &quot;, $a();<br/> say &quot;b: &quot;, $b();<br/> say &quot;c: &quot;, $c();<br/><br/>As a followup question, what about...?<br/><br/> my @array;<br/> for 1..3 -&gt; $x {<br/> sub get_x() { return $x; }<br/> push @array, &amp;get_x;<br/> }<br/><br/> for @array -&gt; $f { say $f(); }<br/><br/>Pm<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29367.html Sat, 12 Jul 2008 19:52:42 +0000 Re: Question about .sort and .reduce by Larry Wall On Fri, Jul 11, 2008 at 09:01:09AM -0500, Patrick R. Michaud wrote:<br/>: I&#39;m not entirely certain if any of the following <br/>: examples with adverbial blocks would also work. I&#39;m guessing<br/>: they do, but could use confirmation.<br/>: <br/>: sort @a, :{ $^a &lt;=&gt; $^b };<br/>: sort @a :{ $^a &lt;=&gt; $^b };<br/>: sort :{ $^a &lt;=&gt; $^b }, @a;<br/>: @a.sort: :{ $^a &lt;=&gt; $^b };<br/><br/>I think they all work, but the second one is fragile and will break<br/>if you replace @a with an expression containing an operator that the<br/>adverb would attach itself to instead of to the sort, since adverbs<br/>in infix position always pick the most recent operator (that isn&#39;t<br/>hidden inside brackets or parens).<br/><br/>Larry<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29366.html Sat, 12 Jul 2008 11:19:35 +0000 Re: Question about .sort and .reduce by Larry Wall On Fri, Jul 11, 2008 at 03:27:26PM +0200, TSa wrote:<br/>&gt; HaloO,<br/>&gt;<br/>&gt; Patrick R. Michaud wrote:<br/>&gt;&gt; S29 doesn&#39;t show a &#39;sort&#39; method defined on block/closure<br/>&gt;&gt; invocants... should there be? <br/>&gt;<br/>&gt; I doubt that. And to my eyes it looks funny. Only real block<br/>&gt; methods should be useful and since the class is mostly known<br/>&gt; at parse time unapplicable methods should be a compile error.<br/>&gt;<br/>&gt; my &amp;f = { $^a &lt;=&gt; $^b }.assuming($^a = 3);<br/>&gt;<br/>&gt; say f(3); # prints 0<br/>&gt;<br/>&gt; Would that be valid? I mean the usuage of automatic variables<br/>&gt; in the assuming method?<br/><br/>No, that could not work, because $^a = 3 would be in an rvalue context<br/>and refer to the block around the entire statement as a different<br/>parameter. Setting a named parameter with .assuming must use named<br/>argument notation:<br/><br/> my &amp;f = { $^a &lt;=&gt; $^b }.assuming(:a(3));<br/><br/>Also, it may well be that f(3) will say Order::Same rather than 0. :)<br/><br/>Larry<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29365.html Sat, 12 Jul 2008 11:06:27 +0000 [svn:perl6-synopsis] r14562 - doc/trunk/design/syn by larry Author: larry<br/>Date: Sat Jul 12 10:50:57 2008<br/>New Revision: 14562<br/><br/>Modified:<br/> doc/trunk/design/syn/S04.pod<br/><br/>Log:<br/>[S04] small clarification to whether named subs are really closures<br/><br/><br/>Modified: doc/trunk/design/syn/S04.pod<br/>==============================================================================<br/>--- doc/trunk/design/syn/S04.pod (original)<br/>+++ doc/trunk/design/syn/S04.pod Sat Jul 12 10:50:57 2008<br/>@@ -12,9 +12,9 @@<br/> <br/> Maintainer: Larry Wall &lt;larry@wall.org&gt;<br/> Date: 19 Aug 2004<br/>- Last Modified: 2 Apr 2008<br/>+ Last Modified: 12 July 2008<br/> Number: 4<br/>- Version: 65<br/>+ Version: 66<br/> <br/> This document summarizes Apocalypse 4, which covers the block and<br/> statement syntax of Perl.<br/>@@ -1268,7 +1268,12 @@<br/> When we say &quot;clone&quot;, we mean the way the system takes a snapshot of the<br/> routine&#39;s lexical scope and binds it to the current instance of the routine<br/> so that if you ever use the current reference to the routine, it gets<br/>-the current snapshot of its world, lexically speaking.<br/>+the current snapshot of its world, lexically speaking. (When we say that<br/>+named subroutines do not consider themselves closures, this is a bit of a<br/>+fib, since we must, in fact, take a reference to the subroutine in order to<br/>+store it into the symbol table! But this operation happens at compile time<br/>+so the lexical scopes in view are just the initial prototype lexical scopes<br/>+visible to the compiler.)<br/> <br/> Some closures produce C&lt;Code&gt; objects at compile time that cannot be<br/> cloned, because they&#39;re not attached to any runtime code that can<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29364.html Sat, 12 Jul 2008 10:51:06 +0000 Re: Question about .sort and .reduce by Patrick R. Michaud On Fri, Jul 11, 2008 at 03:27:26PM +0200, TSa wrote:<br/>&gt; &gt;Note that we already have:<br/>&gt; &gt;<br/>&gt; &gt; my @s = sort { $^a &lt;=&gt; $^b }, @a;<br/>&gt; &gt; my @s = @a.sort { $^a &lt;=&gt; $^b };<br/>&gt; <br/>&gt; Is that the adverbial block syntax? If not how<br/>&gt; would it look?<br/><br/>The adverbial block syntax would be:<br/><br/> @a.sort:{ $^a &lt;=&gt; $^b };<br/> sort(@a) :{ $^a &lt;=&gt; $^b };<br/><br/>I&#39;m not entirely certain if any of the following <br/>examples with adverbial blocks would also work. I&#39;m guessing<br/>they do, but could use confirmation.<br/><br/> sort @a, :{ $^a &lt;=&gt; $^b };<br/> sort @a :{ $^a &lt;=&gt; $^b };<br/> sort :{ $^a &lt;=&gt; $^b }, @a;<br/> @a.sort: :{ $^a &lt;=&gt; $^b };<br/><br/>Pm<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29363.html Fri, 11 Jul 2008 07:01:20 +0000 Re: Question about .sort and .reduce by TSa HaloO,<br/><br/>Patrick R. Michaud wrote:<br/>&gt; S29 doesn&#39;t show a &#39;sort&#39; method defined on block/closure<br/>&gt; invocants... should there be? <br/><br/>I doubt that. And to my eyes it looks funny. Only real block<br/>methods should be useful and since the class is mostly known<br/>at parse time unapplicable methods should be a compile error.<br/><br/> my &amp;f = { $^a &lt;=&gt; $^b }.assuming($^a = 3);<br/><br/> say f(3); # prints 0<br/><br/>Would that be valid? I mean the usuage of automatic variables<br/>in the assuming method?<br/><br/><br/>&gt; Note that we already have:<br/>&gt; <br/>&gt; my @s = sort { $^a &lt;=&gt; $^b }, @a;<br/>&gt; my @s = @a.sort { $^a &lt;=&gt; $^b };<br/><br/>Is that the adverbial block syntax? If not how<br/>would it look?<br/><br/> my @s = sort @a :{ $^a &lt;=&gt; $^b };<br/><br/>Or with a comma after @a?<br/><br/><br/>Regards, TSa.<br/>-- <br/><br/>&quot;The unavoidable price of reliability is simplicity&quot; -- C.A.R. Hoare<br/>&quot;Simplicity does not precede complexity, but follows it.&quot; -- A.J. Perlis<br/>1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29362.html Fri, 11 Jul 2008 06:27:41 +0000 Question about .sort and .reduce by Patrick R. Michaud <br/>t/spec/S29-list/sort.t has the following test:<br/><br/> my @a = (2, 45, 6, 1, 3);<br/> my @e = (1, 2, 3, 6, 45);<br/> my @s = { $^a &lt;=&gt; $^b }.sort: @a;<br/> is(@s, @e, &#39;... with closure as direct invocant&#39;);<br/><br/>S29 doesn&#39;t show a &#39;sort&#39; method defined on block/closure<br/>invocants... should there be? <br/><br/>Note that we already have:<br/><br/> my @s = sort { $^a &lt;=&gt; $^b }, @a;<br/> my @s = @a.sort { $^a &lt;=&gt; $^b };<br/><br/>A similar question applies for .reduce in S29-list/reduce.t :<br/><br/> is(({ $^a * $^b }.reduce: 1,2,3,4,5), 120, &quot;basic reduce works (3)&quot;);<br/><br/>Thanks!<br/><br/>Pm<br/> http://www.nntp.perl.org/group/perl.perl6.language/2008/07/msg29361.html Fri, 11 Jul 2008 06:00:32 +0000