base-4 literals
A simple proposal ... 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. With that addition, the line-up would look like this: 0b - binary (2) 0t - tetra (4) 0o - octal (8) 0d - decimal (10) 0x - hexidecimal (16) Another alterative for 0t is 0q (quad) but I like the look of 0t more because that character's glyph doesn't have a descender like the other 4. With numeric literals, it means we have an 0a form for every power of 2 between 1 and 4, rather than skipping one. Even more important, with blob literals, we have an 0a form for every power likely to be used period, since for all practical purposes they can only take literals in powers of 2 anyway. So, any thoughts on this? -- Darren Duncan
Re: base-4 literals
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? // Carl
Re: base-4 literals
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
Re: base-4 literals
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? Larry
Re: base-4 literals
On 11/16/2010 08:46 PM, Darren Duncan wrote: So, any thoughts on this? A wonderful application for a module. And don't we already have :41230 for base 4 literals? With a simple scheme that can be used up to base 36? Cheers, Moritz How thinks that Perl 6 should really become smaller over time, not larger
Re: base-4 literals
: 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? My reaction parallels that of Carl and Larry. Isn't the :4222 syntax sufficient? Unless you're manipulating a lot of bitstreams in pairwise increments, I don't see the point. Orthogonality for its own sake is not very Perlish... -- Mark J. Reed markjr...@gmail.com
Re: base-4 literals
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? Actually, the primary case I was thinking of was with blobs. S02 currently says: * Blob literals look similar to integer literals with radix markers, but use curlies instead of angles: :2{0010_1110_1000_10} a blob1, base 2, 1 bit per column :4{}a blob2, 2 bits per column :8{5235 0437 6} a blob3, 3 bits per column :16{A705E} a blob4, 4 bits per column Whitespace and underscores are allowed but ignored. Now, granted, all of the above examples use :N format, but if 0a formats actually are supported for blobs as I would expect given the above description, like this: 0b{0010_1110_1000_10} a blob1, base 2, 1 bit per column 0o{5235 0437 6} a blob3, 3 bits per column 0x{A705E} a blob4, 4 bits per column ... then for blobs in particular, I had thought it would be appropriate to have a base-4 version. But if there is no agreement, then so be it, I will retract my proposal. -- Darren Duncan
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-
Re: base-4 literals
Larry (), Dan (): 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 Heh. :) hey, do we have tr/// equivalent already? In S05? Yes, since the get-go. In Rakudo? You do know that it's freely available, right? :) (Sometimes the lack on grounding on this list in actual, working implementations has me flummoxed.) $ perl6 -e 'say GATTACA.trans(TCAG = 0123)' 3200212 The tr[][] form doesn't work yet, though. // Carl