Re: base-4 literals
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Nov 17 2010, at 05:16 , Larry Wall wrote: On Tue, Nov 16, 2010 at 12:11:01PM -0800, Darren Duncan wrote: : Carl Mäsak wrote: : Darren (): : While I haven't seen any prior art on this, I'm thinking that it would be : nice for a sense of completeness or parity to have an 0a syntax specific to : base-4 that complements the 4 that we have now for bases 2,8,16,10. : : You're joking, right? : : No, its a serious idea, just not so conventional. -- Darren Duncan The lack of base 4 numbers in Real Life seems to me to justify the convention. Do you have a use case? Real Life on Earth is base-4 coded :-p FYI we already have :412301230 which is ALREADY supported. If you want to use ACGT instead, just apply grammar or tr... hey, do we have tr/// equivalent already? Dan the Base-4 Coded Creature -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (Darwin) iEYEARECAAYFAkzi+RoACgkQErJia/WXtBvXUACfeqzcxEpkEL5SrPgcwAwkYK+t LhwAni5fE4lADkIkp/wHgXWZm65FYJco =1QQG -END PGP SIGNATURE-
The exact value of infinity [Was: Re: sprintf and snake envy]
On Jul 05, 2006, at 01:25 , Larry Wall wrote: What made me laugh is that Pugs knows the exact value of infinity: pugs my $a = {$^lang has $^c.as('%03d') quote types.}(:c (Inf),:langPerl) Perl has 1797693134862315907729305190789024733617976978942306572734300811577326 7580550096313270847732240753602112011387987139335765878976881441662249 2847430639474124377767893424865485276302219601246094119453082952085005 7688381506823424628814739131105408272371633505106845862982399472459384 79716304835356329624224137216 quote types. Larry, you almost wrecked my MacBook Pro with the coffee I was sipping :) I think I found the reason why Pugs knows the exact value of infinity. That's GHC that tells pugs the exact value thereof. This is Infinity according to Pugs. ./src/Pugs/AST/Internals.hs doCast (VStr Inf) = return $ 1/0 And this is what GHC thinks what Infinity is. Prelude 2^1023 == 1/0 False Prelude 2^1024 == 1/0 True Dan the Pugs Walker
placeholder vs. lexical variables
Folks, I found this when I was playing w/ pugs. pugs { $^x }.(42) 42 pugs { my $z; $^x }.(42) *** Undeclared variable: $^x at interactive line 1, column 10-14 So far as I see s06, there's nothing wrong w/ the statement above. I just want to make sure this is not a perl6 feature. I found this when I tried { my %n; { %n{ $^n } ||= ($^n = 2 ?? 1 !! ?BLOCK($^n-1) + ? BLOCK($^n-2)) }.($^n) }.(42) This fails on pugs while - $n { my %n; { %n{ $^n } ||= ($^n = 2 ?? 1 !! ?BLOCK($^n-1) + ?BLOCK($^n-2)) }.($n) }.(42) beautifully returns 267914296. Dan the Yet Another Pugs Addict
slurp, quine and context sensitivity
Folks, This is a poetic quine (or quine-maker) in perl5. open myself, $0 and print myself; The same thing in perl6 would be: my $self = open $*PROGRAM_NAME; for =$self { say } or my $self = open $*PROGRAM_NAME; say for =$self; or my $self = slurp $*PROGRAM_NAME; print $self; or even $*PROGRAM_NAME.slurp.map:{ print }; The last example must not be $*PROGRAM_NAME.slurp.print; You can check it out by running the code below; ## $*PROGRAM_NAME.slurp.print ## Will print: ##$*PROGRAM_NAME.slurp.print## This is because print() (and say()) expects list context and slurp() passes an array of chomped strings. When it comes to autoboxing, the context-sensitivity of builtins may bite you like this. With that understood, I would welcome if we have a version of slurp() which unconditionally returns a scalar. Say swallow()? Of course it is as easy to implement as the following; sub swallow($file){ my $content = slurp $file; return $content }; But like say(), I would love to have something like that as a builtin. Or am I getting too much ruby recently? Dan the Perl6 Addict
Re: slurp, quine and context sensitivity
On Apr 08, 2006, at 18:45 , Damian Conway wrote: Dan Kogai wrote: With that understood, I would welcome if we have a version of slurp () which unconditionally returns a scalar. That'd be: ~slurp $file; :-) Very clever. But still not good enough when it comes to autoboxing. { ~slurp }($*PROGRAM_NAME).print and even (~slurp $*PROGRAM_NAME).print works as expected but since ~slurp $file is really ~(slurp $file), $*PROGRAM_NAME.~slurp.print does not. The problem of ~stringify, ?boolify, and +numify is that they are infix operators so it goes the opposite direction. Oh, while I was testing all these on pugs, I came across this. ## say $*PROGRAM_NAME.slurp.elems; ## This says 1 but ## my @lines = $*PROGRAM_NAME.slurp; say @lines.elems; ## says 3. This I am confused. Dan the Perl6 Golfer on the Bunker
Re: slurp, quine and context sensitivity
On Apr 08, 2006, at 19:34 , Dan Kogai wrote: does not. The problem of ~stringify, ?boolify, and +numify is that they are infix operators so it goes the opposite direction. s/infix/prefix/ Sorry. Dan the Perl6 Golfer on the Bunker
How do you use a built-in class as a base class?
Folks, With Perl6, we have singleton methods as $me.meta.add_method(me = sub{ ... }); But is there a way to, say, add methods within lexical scope? Take URI on Perl 5. URI behaves both as an object my $uri = URI-new(http://dev.perl.org/perl6/;); print $uri-path; # /perl6/ But it also behaves as an ordinary string. print $uri; # http://dev.perl.org/perl6/; In Perl5, this is done by overloading q(). If you want anything like this, you needed overloading. But in Perl6, I assume you'd go like class URI is Str { method path(){ # } } So you don't have to resort to overloading. Now the questions are: 1. How are you going to initialize? my URI $uri .= .new(http://dev.perl.org/perl6/;); or my $uri = URI.new(http://dev.perl.org/perl6/;); or my URI $uri = http://dev.perl.org/perl6/;; ? 2. How do the method access its internal string. Via $?SELF ? Or should I use roles instead of classes in this kind of case? What I want is make something like a smart builtin classes within Perl 6 semantics. You don't want to go like $uri.meta.add_method('path' = ...), right? I know how to do that in Perl 5 (possible but difficult). I know how to do that in Javascript (eazy but Str.prototype.yourmeth = function() {...} makes ALL STRINGS smart). What's the recommended way in Perl 6? Dan the Object Disoriented
Bugs Manifesto Released!
[April 1st, 2006, 00:00 GMT+9] Larry Wall and Audrey Tang jointly announced that Parrot, Pugs, and all language-related projects be dysintegrated to Bugs. Bugs have ruled this planet for half a billion years and they shall do so for for years to come. Beats heck out of avians, mammals, reptiles or gems. Their Manifesto is now available at http://blog.livedoor.jp/dankogai/mov/lamdaorz.mov Stay tuned! Dan the Deranged, Infested, and Undefined, Reporting Live from Triassic
Re: Renaming grep
On Nov 19, 2005, at 13:08 , Chip Salzenberg wrote: On Sat, Nov 19, 2005 at 05:46:51AM +0200, Ilmari Vacklin wrote: I don't much like it - it looks like a mistyped 'shift'. Is 'filter' too long? I usually avoid P6L discussions, but: GNU Make has filter and filter-out, and I've always found the polarity hard to remember. I like grep. I like grep, too. FYI google gave me 6,650,000 greps and 4,390,000 sifts. IMHO grep is popular enough. Well, google gave me some 158,000,000 filters but that's rather too common and ambiguous. Note filter does not always sift (i.e. perl - ple '$_=$.:$_'). Dan the (grepp|sift|filter)ed Man
Re: Perl 6 fears
Here is my part. On Oct 24, 2005, at 07:20 , Juerd wrote: I've created pugs/docs/quickref/fears, a list of Perl 6 fears. Feel free to add your own, or fears you heard about! [snip] : FEAR: Perl 6 has too many operators! FEAR: Perl 6 has so many operators that it runs out of Unicode character repertoire :) # Time to learn (Hanzi|Kanji) for that? : FEAR: I will never be able to type Unicode ops! FEAR: I will need to hack an input method just to type those ops! : FEAR: Unicode ops cannot be read by me! FEAR: Unicode ops cannot be read by the compiler! : FEAR: Perl 6 will be too much like Haskell! Perl 6 will be too much like Ruby! # IMHO it already is and I love it! : FEAR: Perl 6 is made for big programs, not for oneliners and short : scripts! FEAR: Unicode ops of Perl 6 ought to make short scripts easier but how the heck can I type in those on shell? Dan the Perl 6 User -- Whatever that Means
Avoid the Yen Sign [Was: Re: new sigil]
Maeda-san and the list members, Thank you for raising this issue and sorry for not raising this myself. On Oct 22, 2005, at 19:42 , Kaoru Maeda wrote: If we find a lot of yen sign as zip-operator in the standard library, we have a big question: Give up either Perl6 or Windows. Which do we abandon? And I suppose the answer would be We have a lot of substitutes to Perl6: Ruby, Perl5, etc. In Japan, yes is synonym to backslash. We wish to retain this legacy. Zip-operator is far less important than regex-escape, string- escape, and take-reference operator. To make the matter worse, there are not just one yen sign in Unicode. Take a look at this. ¥ U+00A5 YEN SIGN ¥ U+FFE5 FULLWIDTH YEN SIGN Tough they look and groks the same to human, computers handle them differently. This happened when Unicode Consortium decided to make BMP round-trippable against legacy encodings. They were distinct in JIS standards, so happened Unicode. Maybe we should avoid other symbols like this for sigils -- those not in ASCII that have 'fullwidth' variations. q($) and q(\) are okay (or too late) because they are already in ASCII. q(¥) should be avoided because you can hardly tell the difference from q(¥) in the display. But this will also outlaw the cent sign. I have attached a list of those affected. As you see, most are with ASCII equivalents but some are not. Dan the Man with Too Many Signs to Deal With % grep FULLWIDTH /usr/local/lib/perl5/5.8.7/unicore/Name.pl | perl - Mencoding=utf8 -aple '$_=chr(hex($F[0])).\t.$_' ! FF01FULLWIDTH EXCLAMATION MARK " FF02FULLWIDTH QUOTATION MARK # FF03FULLWIDTH NUMBER SIGN $ FF04FULLWIDTH DOLLAR SIGN % FF05FULLWIDTH PERCENT SIGN & FF06FULLWIDTH AMPERSAND ' FF07FULLWIDTH APOSTROPHE ( FF08FULLWIDTH LEFT PARENTHESIS ) FF09FULLWIDTH RIGHT PARENTHESIS * FF0AFULLWIDTH ASTERISK + FF0BFULLWIDTH PLUS SIGN , FF0CFULLWIDTH COMMA - FF0DFULLWIDTH HYPHEN-MINUS . FF0EFULLWIDTH FULL STOP / FF0FFULLWIDTH SOLIDUS 0 FF10FULLWIDTH DIGIT ZERO 1 FF11FULLWIDTH DIGIT ONE 2 FF12FULLWIDTH DIGIT TWO 3 FF13FULLWIDTH DIGIT THREE 4 FF14FULLWIDTH DIGIT FOUR 5 FF15FULLWIDTH DIGIT FIVE 6 FF16FULLWIDTH DIGIT SIX 7 FF17FULLWIDTH DIGIT SEVEN 8 FF18FULLWIDTH DIGIT EIGHT 9 FF19FULLWIDTH DIGIT NINE : FF1AFULLWIDTH COLON ; FF1BFULLWIDTH SEMICOLON < FF1CFULLWIDTH LESS-THAN SIGN = FF1DFULLWIDTH EQUALS SIGN > FF1EFULLWIDTH GREATER-THAN SIGN ? FF1FFULLWIDTH QUESTION MARK @ FF20FULLWIDTH COMMERCIAL AT A FF21FULLWIDTH LATIN CAPITAL LETTER A B FF22FULLWIDTH LATIN CAPITAL LETTER B C FF23FULLWIDTH LATIN CAPITAL LETTER C D FF24FULLWIDTH LATIN CAPITAL LETTER D E FF25FULLWIDTH LATIN CAPITAL LETTER E F FF26FULLWIDTH LATIN CAPITAL LETTER F G FF27FULLWIDTH LATIN CAPITAL LETTER G H FF28FULLWIDTH LATIN CAPITAL LETTER H I FF29FULLWIDTH LATIN CAPITAL LETTER I J FF2AFULLWIDTH LATIN CAPITAL LETTER J K FF2BFULLWIDTH LATIN CAPITAL LETTER K L FF2CFULLWIDTH LATIN CAPITAL LETTER L M FF2DFULLWIDTH LATIN CAPITAL LETTER M N FF2EFULLWIDTH LATIN CAPITAL LETTER N O FF2FFULLWIDTH LATIN CAPITAL LETTER O P FF30FULLWIDTH LATIN CAPITAL LETTER P Q FF31FULLWIDTH LATIN CAPITAL LETTER Q R FF32FULLWIDTH LATIN CAPITAL LETTER R S FF33FULLWIDTH LATIN CAPITAL LETTER S T FF34FULLWIDTH LATIN CAPITAL LETTER T U FF35FULLWIDTH LATIN CAPITAL LETTER U V FF36FULLWIDTH LATIN CAPITAL LETTER V W FF37FULLWIDTH LATIN CAPITAL LETTER W X FF38FULLWIDTH LATIN CAPITAL LETTER X Y FF39FULLWIDTH LATIN CAPITAL LETTER Y Z FF3AFULLWIDTH LATIN CAPITAL LETTER Z [ FF3BFULLWIDTH LEFT SQUARE BRACKET \ FF3CFULLWIDTH REVERSE SOLIDUS ] FF3DFULLWIDTH RIGHT SQUARE BRACKET ^ FF3EFULLWIDTH CIRCUMFLEX ACCENT _ FF3FFULLWIDTH LOW LINE ` FF40FULLWIDTH GRAVE ACCENT a FF41FULLWIDTH LATIN SMALL LETTER A b FF42FULLWIDTH LATIN SMALL LETTER B c FF43FULLWIDTH LATIN SMALL LETTER C d
FYI: Lambda Calculus on Perl 6
Folks, I recently needed to write a series of codes on lambda calculus in perl. As MJD has shown Perl 5 can handle lambda calculus but I am beginning to get tired of whole bunch of 'my $x = shift' needed. our $ZERO = sub { my $f = shift; sub { my $x = shift; $x }}; our $SUCC = sub { my $n = shift; sub { my $f = shift; sub { my $x = shift; $f-($n-($f)($x)) }}}; our $ADD = sub{ my $m = shift; sub { my $n = shift; sub { my $f = shift; sub { my $x = shift; $m-($f)($n-($f)($x)) ; our $MULT = sub { my $m = shift; sub { my $n = shift; sub { my $f = shift; $m-($n-($f)) }}}; our $POW = sub { my $m = shift; sub { my $n = shift; $n-($m) }}; And I found that these can be made much, much simpler and more intuitive with Perl 6, even more so than scheme! our $ZERO = sub($f){ sub($x){ $x }}; our $SUCC = sub($n){ sub($f){ sub($x){ $f.($n.($f)($x)) }}}; our $ADD = sub($m){ sub($n){ sub($f){ sub($x){ $m.($f)($n.($f) ($x)) ; our $MULT = sub($m){ sub($n){ sub($f){ $m.($n.($f)) }}}; our $POW = sub($m){ sub($n){ $n.($m) }}; You can even make it simpler by removing dots but I leave it that way because it looks more like the original notation that way (i.e. zero := λf.λx.x). Runs perfectly fine on Pugs 6.2.8. Add the code below and see it for yourself. my $one = $SUCC.($ZERO); my $two = $SUCC.($one); my $four= $ADD.($two)($two); my $eight = $MULT.($two)($four); my $sixteen = $POW.($four)($two); for($one, $two, $four, $eight, $sixteen) - $n { $n.(sub($i){ 1 + $i})(0).say }; Maybe we can use this for advocacy. Dan the Perl 6 User Now P.S. I am surprised to find Pugs does not include this kind of sample scripts.
Re: Time::Local
On Aug 17, 2005, at 00:29 , Larry Wall wrote: which gives us these possibilities. 大務big / (perform) duty Perl6 to people here. 太夢fat, big / dream Perl6 for the rest of us. 対夢oppose, against, pair / dream Pugs? 待夢wait / dream Perl6 to Oreilly ? 滞夢stop, stagnate / dream Perl6 to kansai.pm :) All sounds pretty perl6 to me. Oh, be careful of this one. 台無stand, platform / not, none, cease to be Usually this one reads 'Dai-Nashi' (kun-yomi), meaning to blow from grounds up. Dan the Man from a Place with Too Many Puns and Funs
Unicode operators [Was: Re: UTF-8 and Unicode FAQ, demos]
On Tuesday, Nov 5, 2002, at 04:58 Asia/Tokyo, Larry Wall wrote: (B It would be really funny to use cent $B!q(B, pound $B!r(B, or yen (J\(B as a sigil, (B though... (B (BWhich 'yen' ? I believe you already know \ (U+005c - REVERSE SOLIDUS) (Bis prited as a yen figure in most of Japanese platforms so yen is (Balready everywhere :) (B (BOne big problem for introducing Unicode operator is that there are too (Bmany symbols that look the same but with different code points (Unicode (Bconsortium has so done to make its capitalist members happy so their (Bproprietary symbols in their legacy codes are preserved). Therefore I (Bobject to the idea of making Unicode operator "standard", however (Badvanced that particular operator would be. At the same time, things (Blike "use (more) operators = taste;" is very welcome. i.e. (B (B use operators = "smooth"; (B $hashref = $B!j(B%hash # U+2640 FEMALE SIGN (B $value = $hashref$B!i(B{key}; # U+2642 MALE SIGN (B (B People who believe slippery slope arguments should never go skiing. (B (BI don't want perl6 to be as "tough" as skiing, though. (B (B On the other hand, even the useful slippery slopes have "beginner" (B slopes. I think one advantage of using Unicode for advanced features (B is that it *looks* scary. So in general we should try to keep the (B basic features in ASCII, and only use Unicode where there be dragons. (B (BHeck. We already have source filters in perl5 and I'm pretty much sure (Bsomeone will just invent yet another 'use operators = "ascii";' kind (Bof stuff in perl6. I thought "use English" was already enough. (B (B It will certainly be possible to write APL in Perl, but if you do, (B you'll get what you deserve. (B (BAnd even APL has j. Methinks the question is now whether you make APL (Bout of j or j out of APL. (B $BCF(B the $B!i(B with Too Many Symbols to Deal With (B (BP.S. Here is even wilder idea than Unicode operators. Why don't we (Bjust make perl6 XML-based and allow inline objects to be operators? (B (Bperl (B$two = $one operator src="plus.png" $one; (B/perl (B (B. Yuck!
Re: perl6 operator precedence table
On Friday, Oct 11, 2002, at 23:21 Asia/Tokyo, Aaron Crane wrote: Vaguely heretical, I know, but I'd be inclined to do something like this: Perl 5 Proposed Perl 6 $x $y $x $y $x || $y $x | $y $x $ybitand($x, $y) $x | $ybitor($x, $y) Objection, your honor. perl5 ($x $y) might be uncommon enough to justify this. But how about = vs. =, |= vs. ||= ? Those are both used very often so by saving one symbol we lose consistency. Dan |= MAN | FATHER | PERL5POTER | tobe-user-(PERL6)