just laugh your heart out
As sometimes Perl6 to Perl5 is explained as C++ to C: Newsgroups: rec.arts.humor Subject: The truth about 'C++' revealed Date: Tuesday, December 31, 2002 5:20 AM On the 1st of January, 1998, Bjarne Stroustrup gave an interview to the IEEE's 'Computer' magazine. Naturally, the editors thought he would be giving a retrospective view of seven years of object-oriented design, using the language he created. By the end of the interview, the interviewer got more than he had bargained for and, subsequently, the editor decided to suppress its contents, 'for the good of the industry' but, as with many of these things, there was a leak. Here is a complete transcript of what was was said, unedited, and unrehearsed, so it isn't as neat as planned interviews. __ Interviewer: Well, it's been a few years since you changed the world of software design, how does it feel, looking back? Stroustrup: Actually, I was thinking about those days, just before you arrived. Do you remember? Everyone was writing 'C' and, the trouble was, they were pretty damn good at it. Universities got pretty good at teaching it, too. They were turning out competent - I stress the word 'competent' - graduates at a phenomenal rate. That's what caused the problem. Interviewer: problem? Stroustrup: Yes, problem. Remember when everyone wrote Cobol? Interviewer: Of course, I did too Stroustrup: Well, in the beginning, these guys were like demi-gods. Their salaries were high, and they were treated like royalty. Interviewer: Those were the days, eh? Stroustrup: Right. So what happened? IBM got sick of it, and invested millions in training programmers, till they were a dime a dozen. Interviewer: That's why I got out. Salaries dropped within a year, to the point where being a journalist actually paid better. Stroustrup: Exactly. Well, the same happened with 'C' programmers. Interviewer: I see, but what's the point? Stroustrup: Well, one day, when I was sitting in my office, I thought of this little scheme, which would redress the balance a little. I thought 'I wonder what would happen, if there were a language so complicated, so difficult to learn, that nobody would ever be able to swamp the market with programmers? Actually, I got some of the ideas from X10, you know, X windows. That was such a bitch of a graphics system, that it only just ran on those Sun 3/60 things. They had all the ingredients for what I wanted. A really ridiculously complex syntax, obscure functions, and pseudo-OO structure. Even now, nobody writes raw X-windows code. Motif is the only way to go if you want to retain your sanity. [NJW Comment: That explains everything. Most of my thesis work was in raw X-windows. :)] Interviewer: You're kidding...? Stroustrup: Not a bit of it. In fact, there was another problem. Unix was written in 'C', which meant that any 'C' programmer could very easily become a systems programmer. Remember what a mainframe systems programmer used to earn? Interviewer: You bet I do, that's what I used to do. Stroustrup: OK, so this new language had to divorce itself from Unix, by hiding all the system calls that bound the two together so nicely. This would enable guys who only knew about DOS to earn a decent living too. Interviewer: I don't believe you said that... Stroustrup: Well, it's been long enough, now, and I believe most people have figured out for themselves that C++ is a waste of time but, I must say, it's taken them a lot longer than I thought it would. Interviewer: So how exactly did you do it? Stroustrup: It was only supposed to be a joke, I never thought people would take the book seriously. Anyone with half a brain can see that object-oriented programming is counter-intuitive, illogical and inefficient. Interviewer: What? Stroustrup: And as for 're-useable code' - when did you ever hear of a company re-using its code? Interviewer: Well, never, actually, but... Stroustrup: There you are then. Mind you, a few tried, in the early days. There was this Oregon company - Mentor Graphics, I think they were called - really caught a cold trying to rewrite everything in C++ in about '90 or '91. I felt sorry for them really, but I thought people would learn from their mistakes. Interviewer: Obviously, they didn't? Stroustrup: Not in the slightest. Trouble is, most companies hush-up all their major blunders, and explaining a $30 million loss to the shareholders would have been difficult. Give them their due, though, they made it work in the end. Interviewer: They did? Well, there you are then, it proves O-O works. Stroustrup: Well, almost. The executable was so huge, it took five minutes to load, on an HP workstation, with 128MB of RAM. Then it ran like treacle. Actually, I thought this would be a major stumbling-block, and I'd get found out within a week, but nobody cared. Sun and HP were only too glad to sell enormously powerful boxes, with huge resourc
[svn:perl6-synopsis] r10304 - doc/trunk/design/syn
Author: larry Date: Wed Jul 19 11:21:01 2006 New Revision: 10304 Modified: doc/trunk/design/syn/S02.pod doc/trunk/design/syn/S03.pod doc/trunk/design/syn/S04.pod Log: Generalize long dot to "unspace" to futureproof against grammar mods. (And also to allow suppression of any curly-at-the-end-of-line misparse. :) Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podWed Jul 19 11:21:01 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 10 Aug 2004 - Last Modified: 18 July 2006 + Last Modified: 19 July 2006 Number: 2 - Version: 51 + Version: 52 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -173,6 +173,17 @@ =item * +In fact, any whitespace (including comments) may be hidden by prefixing +it with C<\>. It does not have to end with a dot. It's just that +the normal use of a you-don't-see-this-space is typically to put +a dotted postfix on the next line. But it also lets you continue +the line in any situation where a newline might confuse the parser, +regardless of the currently installed parser. (Unless, of course, +you override the unspace rule itself...) Although we say that the +unspace hides the whitespace from the parser, line numbers are still counted. + +=item * + In general, whitespace is optional in Perl 6 except where it is needed to separate constructs that would be misconstrued as a single token or other syntactic unit. (In other words, Perl 6 follows the standard @@ -210,9 +221,13 @@ .++ $x\# comment - # more comment + # inside long dot .++ +$x\# comment + # inside "unspace" +++ # (but long dot may be preferred...) + $x\#『 comment more comment 』.++ @@ -266,7 +281,7 @@ postfix dot will be taken to be the start of some kind of method call syntax, whether long-dotty or not. (The C<.123> form with a leading dot is still allowed however when a term is expected, and is equivalent -to C<0.123>.) +to C<0.123> rather than C<$_.123>.) =back Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podWed Jul 19 11:21:01 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 8 Mar 2004 - Last Modified: 18 Jul 2006 + Last Modified: 19 Jul 2006 Number: 3 - Version: 50 + Version: 51 =head1 Changes to existing operators @@ -95,10 +95,14 @@ =item * The scalar comma C<,> now constructs a C object from its operands. You have to use a C<[-1]> subscript to get the last one. -=item * The backslash operator captures its arguments, and returns an +=item * The unary backslash operator captures its arguments, and returns an object representing those arguments. You can I this object in several ways to retrieve different parts of the arguments; see the -definition of C in S02 for details. +definition of C in S02 for details. (No whitespace is allowed +after the backslash because that would instead start an "unspace", that is, +an escaped sequence of whitespace or comments. See S02 for details. +However, oddly enough, because of that unspace rule, saying C<\\ $foo> +turns out to be equivalent to C<\$foo>.) =item * The old scalar C<..> flipflop operator is now done with C operator. (C<..> now always produces a C object @@ -329,10 +333,11 @@ of postfix operators. =item * A list operator's arguments are also terminated by a closure -that is not followed by a comma or colon. (And a semicolon is implied if -the closure is the final thing on a line.) This final closure may be -followed by a postfix, in which case the postfix is applied to the result -of the entire list operator. +that is not followed by a comma or colon. (And a semicolon is implied +if the closure is the final thing on a line. Use an "unspace" to +suppress that.) This final closure may be followed by a postfix, +in which case the postfix is applied to the result of the entire +list operator. =item * A function predeclared as 0-ary is never considered list operator, though it allows an optional set of empty parentheses. Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podWed Jul 19 11:21:01 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 19 Aug 2004 - Last Modified: 16 July 2006 + Last Modified: 18 July 2006 Number: 4 - Version: 27 + Version: 28 This document summarizes Apocalypse 4, which covers the block and statement sy
[svn:perl6-synopsis] r10305 - doc/trunk/design/syn
Author: larry Date: Wed Jul 19 11:27:37 2006 New Revision: 10305 Modified: doc/trunk/design/syn/S03.pod doc/trunk/design/syn/S04.pod Log: two brainos, please ignore Modified: doc/trunk/design/syn/S03.pod == --- doc/trunk/design/syn/S03.pod(original) +++ doc/trunk/design/syn/S03.podWed Jul 19 11:27:37 2006 @@ -286,7 +286,7 @@ parentheses or a colon.) If the next item after the list operator is either an infix operator -or a term, a syntax error. [Conjecture: this may be relaxed in +or a term, a syntax error is reported. [Conjecture: this may be relaxed in non-strict mode.] Examples: Modified: doc/trunk/design/syn/S04.pod == --- doc/trunk/design/syn/S04.pod(original) +++ doc/trunk/design/syn/S04.podWed Jul 19 11:27:37 2006 @@ -12,7 +12,7 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 19 Aug 2004 - Last Modified: 18 July 2006 + Last Modified: 19 July 2006 Number: 4 Version: 28
[svn:perl6-synopsis] r10306 - doc/trunk/design/syn
Author: larry Date: Wed Jul 19 12:21:59 2006 New Revision: 10306 Modified: doc/trunk/design/syn/S02.pod Log: .as now reserved for type conversion, use .fmt to sprintf. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podWed Jul 19 12:21:59 2006 @@ -14,7 +14,7 @@ Date: 10 Aug 2004 Last Modified: 19 July 2006 Number: 2 - Version: 52 + Version: 53 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -281,7 +281,7 @@ postfix dot will be taken to be the start of some kind of method call syntax, whether long-dotty or not. (The C<.123> form with a leading dot is still allowed however when a term is expected, and is equivalent -to C<0.123> rather than C<$_.123>.) +to C<0.123> rather than C<$_.123.) =back @@ -620,10 +620,10 @@ =item * To get a formatted representation of any scalar data value, use -the C<.as('%03d')> method to do an implicit sprintf on the value. +the C<.fmt('%03d')> method to do an implicit sprintf on the value. To format an array value separated by commas, supply a second argument: -C<.as('%03d', ', ')>. To format a hash value or list of pairs, include -formats for both key and value in the first string: C<< .as('%s: %s', "\n") >>. +C<.fmt('%03d', ', ')>. To format a hash value or list of pairs, include +formats for both key and value in the first string: C<< .fmt('%s: %s', "\n") >>. =item * @@ -1505,11 +1505,11 @@ In other words, this is legal: -"Val = $a.ord.as('%x')\n" +"Val = $a.ord.fmt('%x')\n" and is equivalent to -"Val = { $a.ord.as('%x') }\n" +"Val = { $a.ord.fmt('%x') }\n" =item *
[svn:perl6-synopsis] r10307 - doc/trunk/design/syn
Author: larry Date: Wed Jul 19 12:25:16 2006 New Revision: 10307 Modified: doc/trunk/design/syn/S02.pod Log: typo from particle++ Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podWed Jul 19 12:25:16 2006 @@ -281,7 +281,7 @@ postfix dot will be taken to be the start of some kind of method call syntax, whether long-dotty or not. (The C<.123> form with a leading dot is still allowed however when a term is expected, and is equivalent -to C<0.123> rather than C<$_.123.) +to C<0.123> rather than C<$_.123>.) =back
[svn:perl6-synopsis] r10308 - doc/trunk/design/syn
Author: audreyt Date: Wed Jul 19 13:12:50 2006 New Revision: 10308 Modified: doc/trunk/design/syn/S02.pod Log: * S02 proof-editing with Uri Guttman: Batch #1. These edits introduce no semantic changes to the spec; it's all strictly English cleanups. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podWed Jul 19 13:12:50 2006 @@ -14,7 +14,7 @@ Date: 10 Aug 2004 Last Modified: 19 July 2006 Number: 2 - Version: 53 + Version: 54 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -57,8 +57,8 @@ since they're bidirectional but not in the Ps/Pe set. Characters with no corresponding closing character do not qualify -as opening brackets. This includes the second section of the BidiMirroring -data table, as well as C and C. +as opening brackets. This includes the second section of the Unicode +BidiMirroring data table, as well as C and C. If a character is already used in Ps/Pe mappings, then its entry in BidiMirroring is ignored. Therefore C maps to C, @@ -86,10 +86,10 @@ Multiline comments are provided by extending the syntax of POD to nest C<=begin comment>/C<=end comment> correctly without the need -for C<=cut>. (Doesn't have to be "comment"--any unrecognized POD -stream will do to make it a comment. Bare C<=begin> and C<=end> -probably aren't good enough though, unless you want all your comments -to end up in the manpage...) +for C<=cut>. The format name does not have to be C -- any +unrecognized format name will do to make it a comment. (However, +bare C<=begin> and C<=end> probably aren't good enough, because all +comments in them will show up in the formatted output.) We have single paragraph comments with C<=for comment> as well. That lets C<=for> keep its meaning as the equivalent of a C<=begin> @@ -102,7 +102,8 @@ =item * Embedded comments are supported as a variant on quoting syntax, introduced -by C<#> plus any user-selected bracket characters (see definition above): +by C<#> plus any user-selected bracket characters (as defined in +L above): say #( embedded comment ) "hello, world!"; @@ -112,25 +113,29 @@ embedded comments 」.say; -There must be no space between the # and the opening bracket character. -(There may be the I of space for some double-wide -characters, however, such as the corner quotes above.) Brackets may -be nested following the same policy as ordinary quote brackets. +Brackets may be nested, following the same policy as ordinary quote brackets. + +There must be no space between the C<#> and the opening bracket character. +(There may be the I of space for some double-wide +characters, however, such as the corner quotes above.) + +=item * As a special case to facilitate commenting out sections of code with -C, C<#> on the left margin is always considered a line-end -comment rather than an embedded comment, even if followed by a -bracketing character. +C, C<#> on the beginning of line is always considered a line-end +comment rather than an embedded comment, even if followed by a bracketing +character. =item * -For all quoting constructs that use user-selected brackets, multiple, -adjacent, identical opening brackets must always be matched by an -equal number of adjacent closing brackets. Bracket counting naturally -applies only to sets of brackets of the same length: +For all quoting constructs that use user-selected brackets, you can open +with multiple identical bracket characters, which must by closed by the +same number of closing brackets. Counting of nested brackets applies only +to pairs of brackets of the same length as the opening brackets: say #{{ - Comment contains unmatched } and { { { { plus a counted {{ ... }} pair. +This comment contains unmatched } and { { { { (ignored) +Plus a nested {{ ... }} pair(counted) }} q<< <> >> # says "<>" Note however that bare circumfix or postcircumfix C<<< <<...>> >>> is @@ -187,8 +192,8 @@ In general, whitespace is optional in Perl 6 except where it is needed to separate constructs that would be misconstrued as a single token or other syntactic unit. (In other words, Perl 6 follows the standard -"longest-token" principle, or in the cases of large constructs, a -"prefer shifting to reducing" principle. See Grammatical Categories +I principle, or in the cases of large constructs, a +I principle. See L below for more on how a Perl program is analyzed into tokens.) This is an unchanging deep rule, but the surface ramifications of it @@ -315,10 +320,10 @@ =item * -Properties applied to compile-time objects such as variables and -classes are also called B. Traits are not expected to change -at run time. Changing run-time properties should be done vi
[svn:perl6-synopsis] r10312 - doc/trunk/design/syn
Author: audreyt Date: Wed Jul 19 15:10:38 2006 New Revision: 10312 Modified: doc/trunk/design/syn/S02.pod Log: * S02 proof-editing with Uri Guttman: Batch #2. * One semantic change to address an unspecified point: plural magicals like @?BLOCK etc are ordered from innermost to outermost (i.e. in the same order as lookups.) Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podWed Jul 19 15:10:38 2006 @@ -14,7 +14,7 @@ Date: 10 Aug 2004 Last Modified: 19 July 2006 Number: 2 - Version: 54 + Version: 55 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -461,9 +461,10 @@ respectively, and do not promote to arbitrary precision, though larger representations are always allowed for temporary values. Unless qualified with a number of bits, C and C types default -to the largest native types that run at full speed. Untyped numeric -scalars use C and C semantics rather than C and C. +to the largest native types that run at full speed. +Numeric values in untyped variables use C and C semantics +rather than C and C. =item * @@ -586,7 +587,7 @@ =item * -The C<$pkg'var> syntax is dead. Use C<$pkg::var> instead. +The C<$Package'var> syntax is gone. Use C<$Package::var> instead. =item * @@ -601,15 +602,19 @@ @@ multislice view of @ Within a declaration, the C<&> sigil also declares the visibility of the -subroutine name without the sigil within the scope of the declaration. +subroutine name without the sigil within the scope of the declaration: + +my &func := sub { say "Hi" }; +func; # calls &func Within a signature or other declaration, the C<::> sigil followed by an -identifier marks a parametric type that also declares the visibility +identifier marks a type variable that also declares the visibility of a package/type name without the sigil within the scope of the declaration. The first such declaration within a scope is assumed to be an unbound type, and takes the actual type of its associated argument. With subsequent declarations in the same scope the use of the sigil is optional, since the bare type name is also declared. + A declaration nested within must not use the sigil if it wishes to refer to the same type, since the inner declaration would rebind the type. (Note that the signature of a pointy block counts as part @@ -658,15 +663,17 @@ =item * -To get a Perlish representation of any data value, use the C<.perl> -method. This will put quotes around strings, square brackets around -list values, curlies around hash values, constructors around objects, -etc., such that standard Perl could reparse the result. +To get a Perlish representation of any object, use the C<.perl> method. +Like the C module in Perl 5, the C<.perl> method will put +quotes around strings, square brackets around list values, curlies around +hash values, constructors around objects, etc., so that Perl can evaluate +the result back to the same object. =item * -To get a formatted representation of any scalar data value, use -the C<.fmt('%03d')> method to do an implicit sprintf on the value. +To get a formatted representation of any scalar value, use the +C<.fmt('%03d')> method to do an implicit C on the value. + To format an array value separated by commas, supply a second argument: C<.fmt('%03d', ', ')>. To format a hash value or list of pairs, include formats for both key and value in the first string: C<< .fmt('%s: %s', "\n") >>. @@ -710,16 +717,16 @@ values. There's a new C<:=> binding operator that lets you bind names to Array and Hash objects without copying, in the same way as subroutine arguments are bound to formal parameters. See S06 -for more about parameter binding. +for more about binding. =item * -An argument list object (C) may be created with backslashed parens: +An argument list may be captured into an object with backslashed parens: $args = \(1,2,3,:mice) -Values in C are parsed as ordinary expressions, marked as invocant, -positional, named, and so on. +Values in a C object are parsed as ordinary expressions, marked as +invocant, positional, named, and so on. Like C objects, C objects are immutable in the abstract, but evaluate their arguments lazily. Before everything inside a C is @@ -757,22 +764,20 @@ =item * -A signature object (C) may be created with coloned parens: +A signature object (C) may be created with colon-prefixed parens: -my ::MySig = :(Int,Num,Complex, Status :mice) +my ::MySig ::= :(Int, Num, Complex, Status :mice) -A signature's values are parsed as declarations rather than ordinary -expressions. You may not put arbitrary expressions, but you may, for -instance stack multiple types that all must match: +Expressions inside the signature a
Patch for S02
Hi, all~ I found some nits while copying Perl 6 Synopsis 2 by hand. The patch created by my TortoiseSVN for S02 has been pasted at the end of the mail. Cheers, Agent Index: D:/projects/Perl6-Syn/S02.pod === --- D:/projects/Perl6-Syn/S02.pod (revision 10313) +++ D:/projects/Perl6-Syn/S02.pod (working copy) @@ -743,8 +743,8 @@ $args = \3; # same as "$args = \(3)" $$args; # same as "$args as Scalar" or "Scalar($args)" -@$args; # same as '$args as Array" or "Array($args)" -%$args; # same as '$args as Hash" or "Hash($args)" +@$args; # same as "$args as Array" or "Array($args)" +%$args; # same as "$args as Hash" or "Hash($args)" When cast into an array, you can access all the positional arguments; into a hash, all named arguments; into a scalar, its invocant. @@ -789,7 +789,7 @@ Whitespace is not allowed before the parens, but there is a corresponding C<.()> operator, plus the "long dot" forms that allow -you to insert optional whitespace and comments between dots: +you to insert optional whitespace and comments between the backslash and dot: &foo\ .($arg1, $arg2); &foo\#[ @@ -1064,7 +1064,7 @@ not see any lexical variables or their values, unless you copy those values into C<%*ENV> to change what subprocesses see: -temp %*ENV{LANG} = $+LANG; # may be modifed by parent +temp %*ENV{LANG} = $+LANG; # may be modified by parent system "greet"; =item *
[svn:perl6-synopsis] r10314 - doc/trunk/design/syn
Author: audreyt Date: Wed Jul 19 20:02:34 2006 New Revision: 10314 Modified: doc/trunk/design/syn/S02.pod Log: * S02: Typo fixes from Agent Zhang and TimToady++. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podWed Jul 19 20:02:34 2006 @@ -399,7 +399,7 @@ respectively on the array. The same methods apply to strings as well. There is no C<.length> method for either arrays or strings, because C -does not specify an unit. +does not specify a unit. =item * @@ -743,8 +743,8 @@ $args = \3; # same as "$args = \(3)" $$args; # same as "$args as Scalar" or "Scalar($args)" -@$args; # same as '$args as Array" or "Array($args)" -%$args; # same as '$args as Hash" or "Hash($args)" +@$args; # same as "$args as Array" or "Array($args)" +%$args; # same as "$args as Hash" or "Hash($args)" When cast into an array, you can access all the positional arguments; into a hash, all named arguments; into a scalar, its invocant. @@ -789,7 +789,8 @@ Whitespace is not allowed before the parens, but there is a corresponding C<.()> operator, plus the "long dot" forms that allow -you to insert optional whitespace and comments between dots: +you to insert optional whitespace and comments between the backslash +and the dot: &foo\ .($arg1, $arg2); &foo\#[ @@ -1064,7 +1065,7 @@ not see any lexical variables or their values, unless you copy those values into C<%*ENV> to change what subprocesses see: -temp %*ENV{LANG} = $+LANG; # may be modifed by parent +temp %*ENV{LANG} = $+LANG; # may be modified by parent system "greet"; =item *
Re: Patch for S02
在 2006/7/19 下午 10:16 時,Agent Zhang 寫到: I found some nits while copying Perl 6 Synopsis 2 by hand. The patch created by my TortoiseSVN for S02 has been pasted at the end of the mail. Thanks, applied as r10314. Audrey PGP.sig Description: This is a digitally signed message part