Re: Getting Started - What to try?
Hi, John M. Dlugosz wrote: > I've installed the Win32 build of Pugs, but is appears to be incomplete. How > do I get the "real thing"? I've also heard that Pugs is in stasis, so is > this still a good way to write stuff and learn today? There is no "real thing" yet, which is why we're working on it ;-) > Likewise, how do I get synched up with the Parrot implementation? svn co https://svn.perl.org/parrot/trunk parrot cd parrot perl Makefile.PL && make cd src/languages/ make then you can fire up ../../parrot perl6.pbc and start playing. > I understand the most official grammar is being developed there. Not quite. The "official" grammar is in the pugs repo in src/perl6/, but it can't really run on anything yet. > Is there a grammar-checker tool that will help me to validate proposed Perl 6 > code fragments, even if I can't execute it yet? Not yet, but we hope to build one soon. > > In general, what are the various repositories and version-control systems > used? What ought I install and get working to join up with the Perl 6 > community? Both parrot and pugs use subversion aka svn. The parrot repo contains parrot, rakudo (perl6 on parrot) and various other languages, the pugs repo contains pugs, STD.pm (the grammar), some of synopsis (in docs/Perl6/Spec/), kp6 (in v6/v6-KindaPerl6), smop (in v6/smop/) and various other stuff. Cheers, Moritz -- Moritz Lenz http://moritz.faui2k3.org/ | http://perl-6.de/ signature.asc Description: OpenPGP digital signature
Re: Query re: duction and precedence.
HaloO, Darren Duncan wrote: For other operators, non-assoc etc, the work will probably all have to be linear. Eg difference|quotient|exponentiation. That's why I would rename the left and right operator associativity to left and right sequentiality. Note that there's a fundamental difference between difference and quotient on the one hand and exponentiation on the other. The former are defined as inverses of associative operations. The right inverse of exponentiation is logarithm which is not available as an operator for good reasons. In other words exponentiation as a binary operator is a bit dubious. Well, or we should spec 8 log 2 == 3 and bewail the fact that // is already taken for much more useful things. Something I'm wondering, though, realistically how often would one actually be reducing on an operator that is not associative? What practical use is there for [-] (3,4,5) for example? I see it as a convenient notation for 3 - ([+] 4,5) just as $x - $y means $x + -$y. Practical example is [-] $money, @bills which stresses the payment of the bills whereas in $money - [EMAIL PROTECTED] the summing-up of the bills visually outweighs the subtraction. Perl 6 might actually develop the idiom that [EMAIL PROTECTED] implies a special role of @array[0]. Regards, TSa. -- The Angel of Geometry and the Devil of Algebra fight for the soul of any mathematical being. -- Attributed to Hermann Weyl
Re: Getting Started - What to try?
On Mon, Mar 31, 2008 at 10:23:45AM +0200, Moritz Lenz wrote: > John M. Dlugosz wrote: > > I understand the most official grammar is being developed there. > > Not quite. The "official" grammar is in the pugs repo in src/perl6/, but > it can't really run on anything yet. This is correct -- the "official" grammar (STD.pm) is in pugs. However, Rakudo's grammar follows STD.pm as closely as it can and is reasonably close for most things. We'd definitely be interested to know about any places it's falling short. > > Is there a grammar-checker tool that will help me to validate > > proposed Perl 6 code fragments, even if I can't execute it yet? > > Not yet, but we hope to build one soon. OTOH, Rakudo can be used to check syntax (at least as much as it knows about) by using the --target=parse option. $ parrot perl6.pbc --target=parse [file] And we'd be really happy to try out any code fragments you may have and see if we can get them to parse and execute. We like it when we can get something new to work. :-) For example, the infix // operator and @*ARGS were added to Rakudo in direct response to Aaron Trevena wanting to get the Towers of Hanoi example [1] running. Specific questions or problems with Rakudo should probably go to [EMAIL PROTECTED], or find a Rakudo developer on #parrot or #perl6. And bug reports can be filed at <[EMAIL PROTECTED]>. Thanks! Pm [1] http://www.perlfoundation.org/perl6/index.cgi?tower_of_hanoi
podhtml.pl
> From: Agent Zhang > IMHO pod2html is old and broken in various ways. I think you should > use the tools provided by Pod::Simple instead. For the Synopses on > feather, we're using the podhtml.pl script (based on > Pod::Simple::HTML): > http://svn.pugscode.org/pugs/util/podhtm.pl > Hopefully you may find it useful :) > Cheers, > -agentzh Thanks, that works. I tweeked the style sheet to use preferred fonts, and also this tip I'd like to pass along: CODE:hover { background-color: yellow; } That makes it easy to isolate a code fragment from the surrounding text, especially when it is followed by punctuation belonging to the sentence. It only highlights when I mouse-over it, and is otherwise non-intrusive. --John -- Protect yourself from spam, use http://sneakemail.com
Re: Integerizing a rat involves truncating its tail
HaloO, Darren Duncan wrote: Or maybe your question is more about what method to use by default if users don't explicitly choose one? Yes. I thought we have gone over this in the div/mod discussion that ended with specifying floor semantics for %. I sort of hoped for a synopsis update with subject 'fossil spotted by TSa' or so :) Regards, TSa. -- The Angel of Geometry and the Devil of Algebra fight for the soul of any mathematical being. -- Attributed to Hermann Weyl
Re: Integerizing a rat involves truncating its tail
HaloO, I asked: just re-reading S03 I saw that it defines the Rat to Int conversion as truncation. Hmm, does assuming floor semantics reveal the availability of the tail function for Nums? (-1.25).tail == 0.75 Can it also be used as an lvalue? my Rat $x = -5/4; # note that this is (-5)/4 not -(5/4) $x.tail = 0; say $x; # -2 The idea here is that the tail of a Num points towards -Inf and ends at the next Int in that direction. So numbers are snakes crawling rightwards ;) Regards, TSa. -- The Angel of Geometry and the Devil of Algebra fight for the soul of any mathematical being. -- Attributed to Hermann Weyl
Re: Getting Started - Synopsis
On Mon, Mar 31, 2008 at 09:54:58AM +0800, Agent Zhang wrote: > On Sun, Mar 30, 2008 at 9:23 PM, Ryan Richter > <[EMAIL PROTECTED]> wrote: > > > > Actually, that cron job hasn't been working for a long time... > > > > I've just checked the cronjob mails and it seems to me that the > update-syn script is working fine. So the Synopses are still fresh :) Sorry, it's actually the html stuff from pugs that's not making it onto feather, e.g. syn_index.html. > I think you meant the auto-smoke script, which indeed has been failing > due to a build error while linking pugs (after make veryclean): Are you building it with GHC 6.6.1? I think that version doesn't work anymore. Maybe someone who's succeeded in building pugs lately can elaborate... -ryan
[svn:perl6-synopsis] r14530 - doc/trunk/design/syn
Author: larry Date: Mon Mar 31 10:00:05 2008 New Revision: 14530 Modified: doc/trunk/design/syn/S02.pod Log: Clarify what is meant by evaluating subscripts in list context. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podMon Mar 31 10:00:05 2008 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 10 Aug 2004 - Last Modified: 17 Mar 2008 + Last Modified: 31 Mar 2008 Number: 2 - Version: 130 + Version: 131 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -1366,6 +1366,12 @@ The context in which a subscript is evaluated is no longer controlled by the sigil either. Subscripts are always evaluated in list context. +(More specifically, they are evaluated in a variant of list context +known as I context, which preserves dimensional information +so that you can do multi-dimensional slices using semicolons. However, +each slice dimension evaluates its sublist in normal list context, +so functions called as part of a subscript don't see a slice context. +See S09 for more on slice context.) If you need to force inner context to item (scalar), we now have convenient single-character context specifiers such as + for numbers and ~ for strings:
[svn:perl6-synopsis] r14531 - doc/trunk/design/syn
Author: larry Date: Mon Mar 31 11:15:33 2008 New Revision: 14531 Modified: doc/trunk/design/syn/S03.pod Log: Some clarifications on Num and Int coercions. Removed lame joke about truncating rats. Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podMon Mar 31 11:15:33 2008 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 8 Mar 2004 - Last Modified: 17 Mar 2008 + Last Modified: 31 Mar 2008 Number: 3 - Version: 133 + Version: 134 =head1 Overview @@ -40,7 +40,7 @@ L Concatenation ~ X Junctive and & X Junctive or | ^ -L Named unary rand sleep abs +L Named unary sleep abs sin N Nonchaining infix but does <=> leg cmp .. ..^ ^.. ^..^ C Chaining infix!= == < <= > >= eq ne lt le gt ge ~~ === eqv !eqv L Tight and && @@ -221,7 +221,7 @@ =item * -Function call +Function call with parens: a(1) @@ -263,6 +263,14 @@ 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 @@ -568,10 +576,11 @@ +$x -Unlike in Perl 5, where C<+> is a no-op, this operator coerces -to numeric context in Perl 6. (It coerces only the value, not the -original variable.) The narrowest appropriate type of C, C, -or C will be returned. A string containing two integers +Unlike in Perl 5, where C<+> is a no-op, this operator coerces to +numeric context in Perl 6. (It coerces only the value, not the +original variable.) For values that are not already considered +numeric, the narrowest appropriate type of C, C, or +C will be returned; however, string containing two integers separated by a C will be returned as a C. Exponential notation and radix notations are recognized. @@ -721,7 +730,6 @@ from a lazy exception model.) Use of C on two C values results in a ratio of the C type. -Integerizing a rat involves truncating its tail. =item * @@ -941,16 +949,48 @@ =head2 Named unary precedence +Functions of one argument + +int +sleep +abs +sin +... # see S29 Functions + +Note that, unlike in Perl 5, you must use the C<.meth> forms to default +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. + =over =item * -Functions of one argument +C<< prefix: >> -rand sleep abs etc. +Coerces to type C. Floor semantics are used for fractional +values, including strings that appear to express fractional values. +That is, C must have the same result as C in all +cases. All implicit conversions to integer use the same semantics. -Note that, unlike in Perl 5, you must use the C<.meth> forms to default -to C<$_> in Perl 6. +(Note that, despite the fact that C is a valid native type +name, this function does not express conversion to that native type. +Such subtype conversions are done automatically upon assignment to +a subtyped container, and fail if the container cannot hold the value.) + +=item * + +C<< prefix: >> + +Suspends the current thread of execution for the specified number of seconds, +which may be fractional. + +=item * + +C<< prefix: >> + +Returns the absolute value of the specified argument. =back
Question on your last change to S02
The context in which a subscript is evaluated is no longer controlled by the sigil either. Subscripts are always evaluated in list context. +(More specifically, they are evaluated in a variant of list context +known as I context, which preserves dimensional information +so that you can do multi-dimensional slices using semicolons. However, +each slice dimension evaluates its sublist in normal list context, +so functions called as part of a subscript don't see a slice context. +See S09 for more on slice context.) So a function can only supply values for one dimension? Given @array[foo;bar] each function is called in list context and returns a list for one of the dimensions. But what if you wanted a function to replace the literal subscript in: @array[1,2;1;3] @array[foo] # what does foo return to be equiv to the first line? My guess is that I could write @array[@@ foo] or in a mixed example @array[1;@@ foo;2] # foo returns (1;1) In any case, examples such as these would help. --John
Buf/Str conversion functions
In S02, "If a buf type is initialized with a Unicode string value, the string is decomposed into Unicode codepoints,...If any other conversion is desired, it must be specified explicitly." In S29, there is nothing about functions in Buf, and nothing about functions that convert or initialize Str. Just where would this be, anyway? The concept of "initialization" is not a strong concept distinct from assignment like in C++. Any relationship between using the class name as a typecast, or defined assignment operators, is not specified (unless I overlooked it in a Snn I've not studied in detail yet). Anyway, I expect to see a function using Buf as a list operator that takes a Str, or an assignment operator with similar parameters, that also takes named parameters as conversion and error options. In whatever form, is anyone working on the definition of these functions? That's something I might work on, having been bothered by issues with existing conversion functions. In any case, would an example look something like this: my Buf $buf = $str :size(32) :precomposed :err(\&callme); where the adjectives are applied as arguments to the assignment operator? Or would it require calling Buf.new? Or is there a pre-defined relationship to the arguments taken by .new and the assignment? --John
RE: Query re: duction and precedence.
The inevitable question - why not support Polish Notation or Reverse Polish ? Well known to be easier to use, since it involves no ambiguities in regard to association, is notationally clearer (not needing parentheses). Seems to make it easier to analyze what one might want to mean by [op] (p1 p2 p3 ... ) E.g., Convention 1 [op] (p1 p2 p3 ... ) =by definition= p1 p2 op p3 op ... pN op Convention 2 [op] (p1 p2 p3 ... ) =by definition= p1 p2 p3 ... pN op op op ... op One could support both conventions (with notational differences) ... Example [^] (2 3 4) =defn 1= 2 3 ^ 4 ^ , i.e., (2^3)^4 [^] (2 3 4) = defn 2= 2 3 4 ^^ , i.e., (2^(3^4)) Etc. - Hugh Miller e-mail: [EMAIL PROTECTED] -Original Message- From: Darren Duncan [mailto:[EMAIL PROTECTED] Sent: Sunday, March 30, 2008 2:00 AM To: p6l Subject: Re: Query re: duction and precedence. Mark J. Reed wrote: > You anticipated me. So, is there a core method for > foldl/foldr/inject/reduce, or do you have to roll your own as in p5? > > On 3/29/08, Larry Wall <[EMAIL PROTECTED]> wrote: >> On Sat, Mar 29, 2008 at 10:18:53PM -0400, Mark J. Reed wrote: >> : In general, is >> : >> : [op] (p1,p2,p3,p4...) >> : >> : expected to return the same result as >> : >> : p1 op p2 op p3 op p4... >> : >> : including precedence considerations? >> >> Yes, in fact the section on Reduction Operators uses exponentiation >> obliquely in one of its examples of something that should work >> right-to-left. Admittedly it's not clearly stated there... >> >> But the basic idea is always that the reduction form should produce >> the same result as if you'd written it out with interspersed infixes. >> It's a linguistic construct, not a functional programming construct. >> It's not intended to be in the same league as foldl and foldr, and is >> only just slightly beyond a macro insofar as it can intersperse >> however many operators it needs to for an arbitrarily sized list. >> It's not making any attempt to deal with anonymous first-class >> functions though. Call a real function for that. :) I think it would be powerful while not too difficult for Perl 6's "reduce" to be able to do everything you'd get in functional programming, at least some of the time. Generally speaking, as long as the base operator is associative, then [op] *$seq_or_array_etc ... should auto-parallelize with a deterministic result; or as long as the base operator is both associative and commutative, then [op] *$set_or_bag_or_seq_or_array_etc ... should also auto-parallelize with a deterministic result. And then you get all the functional programming goodies. The first example works for string catenation, but the second doesn't; the second does work for sum|product|and|or|xor|union|intersection though. Some base operators have an identity value in case the input collection is empty, as is the case with the above operators, but others only work with a non-empty input, such as mean|median|mode. For other operators, non-assoc etc, the work will probably all have to be linear. Eg difference|quotient|exponentiation. Something I'm wondering, though, realistically how often would one actually be reducing on an operator that is not associative? What practical use is there for [-] (3,4,5) for example? Are you just supporting that with all operators for parsing rule simplicity as per a macro? I can understand that reasoning, but otherwise ... I would think it makes sense to restrict the use of the reduction meta-operator to just work over operators that are at least associative. -- Darren Duncan
Re: Query re: duction and precedence.
Well, all's fair if you predeclare, but a language whose main expression format is prefix or postfix is no longer Perl. Maybe Perlisp or Pforth. Plus, given the complex interactions of the various operators, many of which don't look like operators, it's not necessarily straightforward to provide, say, a "use rpn;" pragma. On 3/31/08, Miller, Hugh (hdmi) <[EMAIL PROTECTED]> wrote: > The inevitable question - why not support Polish Notation or Reverse > Polish ? Well known to be easier to use, since it involves no > ambiguities in regard to association, is notationally clearer (not > needing parentheses). Seems to make it easier to analyze what one might > want to mean by > > [op] (p1 p2 p3 ... ) > > E.g., > > Convention 1 > > [op] (p1 p2 p3 ... ) =by definition= p1 p2 op p3 op ... pN op > > Convention 2 > > [op] (p1 p2 p3 ... ) =by definition= p1 p2 p3 ... pN op op op ... > op > > One could support both conventions (with notational differences) ... > > Example > > [^] (2 3 4) =defn 1= 2 3 ^ 4 ^ , i.e., (2^3)^4 > > [^] (2 3 4) = defn 2= 2 3 4 ^^ , i.e., (2^(3^4)) > > Etc. > > - > Hugh Miller > e-mail: [EMAIL PROTECTED] > > > -Original Message- > From: Darren Duncan [mailto:[EMAIL PROTECTED] > Sent: Sunday, March 30, 2008 2:00 AM > To: p6l > Subject: Re: Query re: duction and precedence. > > Mark J. Reed wrote: > > You anticipated me. So, is there a core method for > > foldl/foldr/inject/reduce, or do you have to roll your own as in p5? > > > > On 3/29/08, Larry Wall <[EMAIL PROTECTED]> wrote: > >> On Sat, Mar 29, 2008 at 10:18:53PM -0400, Mark J. Reed wrote: > >> : In general, is > >> : > >> : [op] (p1,p2,p3,p4...) > >> : > >> : expected to return the same result as > >> : > >> : p1 op p2 op p3 op p4... > >> : > >> : including precedence considerations? > >> > >> Yes, in fact the section on Reduction Operators uses exponentiation > >> obliquely in one of its examples of something that should work > >> right-to-left. Admittedly it's not clearly stated there... > >> > >> But the basic idea is always that the reduction form should produce > >> the same result as if you'd written it out with interspersed infixes. > >> It's a linguistic construct, not a functional programming construct. > >> It's not intended to be in the same league as foldl and foldr, and is > > >> only just slightly beyond a macro insofar as it can intersperse > >> however many operators it needs to for an arbitrarily sized list. > >> It's not making any attempt to deal with anonymous first-class > >> functions though. Call a real function for that. :) > > I think it would be powerful while not too difficult for Perl 6's > "reduce" > to be able to do everything you'd get in functional programming, at > least some of the time. > > Generally speaking, as long as the base operator is associative, then > >[op] *$seq_or_array_etc > > ... should auto-parallelize with a deterministic result; or as long as > the base operator is both associative and commutative, then > >[op] *$set_or_bag_or_seq_or_array_etc > > ... should also auto-parallelize with a deterministic result. > > And then you get all the functional programming goodies. The first > example works for string catenation, but the second doesn't; the second > does work for sum|product|and|or|xor|union|intersection though. > > Some base operators have an identity value in case the input collection > is empty, as is the case with the above operators, but others only work > with a non-empty input, such as mean|median|mode. > > For other operators, non-assoc etc, the work will probably all have to > be linear. Eg difference|quotient|exponentiation. > > Something I'm wondering, though, realistically how often would one > actually be reducing on an operator that is not associative? What > practical use is there for [-] (3,4,5) for example? > > Are you just supporting that with all operators for parsing rule > simplicity as per a macro? I can understand that reasoning, but > otherwise ... > > I would think it makes sense to restrict the use of the reduction > meta-operator to just work over operators that are at least associative. > > -- Darren Duncan > -- Sent from Gmail for mobile | mobile.google.com Mark J. Reed <[EMAIL PROTECTED]>
Re: Getting Started - Synopsis
On Mon, Mar 31, 2008 at 8:59 PM, Ryan Richter <[EMAIL PROTECTED]> wrote: > Sorry, it's actually the html stuff from pugs that's not making it onto > feather, e.g. syn_index.html. > Ah...Thanks for the catch :) The index page was formerly a symbolic link to the syn_index.html in audreyt's pugs tree which is updated by the good old evalbot and evalbot has been abandoned for months. I've pointed it to my own pugs tree on feather now, which should be updated in the same pace of the update_syn script, i.e., every one hour. I've noticed the newly-added links to the POD version of the Synopses on the index page. Very cool! > > Are you building it with GHC 6.6.1? I think that version doesn't work > anymore. Maybe someone who's succeeded in building pugs lately can > elaborate... > It seems that I've been using GHC 6.8.2 on feather: [EMAIL PROTECTED]:~$ ghc -v Glasgow Haskell Compiler, Version 6.8.2, for Haskell 98, stage 2 booted by GHC version 6.6.1 I'll look into this later :) Thanks! -agentzh