Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
Steven D'Aprano st...@remove-this-c...e.com.au wrote: Now that I understand what the semantics of cout Hello world are, I don't have any problem with it either. It is a bit weird, Hello world cout would probably be better, but it's hardly the strangest design in any programming language, and it's probably influenced by input redirection using in various shells. I find it strange that you would prefer: Hello world cout over: cout Hello world The latter seems to me to be more in line with normal assignment: - Take what is on the right and make the left the same. I suppose it is because we read from left to right that the first one seems better to you. Another instance of how different we all are. It goes down to the assembler - there are two schools: mova,b - for Intel like languages, this means move b to a mova,b - for Motorola like languages, this means move a to b Gets confusing sometimes. - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
On Sun, 16 Aug 2009 09:24:36 +0200, Hendrik van Rooyen wrote: Steven D'Aprano st...@remove-this-c...e.com.au wrote: Now that I understand what the semantics of cout Hello world are, I don't have any problem with it either. It is a bit weird, Hello world cout would probably be better, but it's hardly the strangest design in any programming language, and it's probably influenced by input redirection using in various shells. I find it strange that you would prefer: Hello world cout over: cout Hello world The latter seems to me to be more in line with normal assignment: - Take what is on the right and make the left the same. I don't like normal assignment. After nearly four decades of mathematics and programming, I'm used to it, but I don't think it is especially good. It confuses beginners to programming: they get one set of behaviour drilled into them in maths class, and then in programming class we use the same notation for something which is almost, but not quite, the same. Consider the difference between: y = 3 + x x = z as a pair of mathematics expressions versus as a pair of assignments. What conclusion can you draw about y and z? Even though it looks funny due to unfamiliarity, I'd love to see the results of a teaching language that used notation like: 3 + x - y len(alist) - n Widget(1, 2, 3).magic - obj etc. for assignment. My prediction is that it would be easier to learn, and just as good for experienced coders. The only downside (apart from unfamiliarity) is that it would be a little bit harder to find the definition of a variable by visually skimming lines of code: your eyes have to zig-zag back and forth to find the end of the line, instead of running straight down the left margin looking for myvar = But it should be easy enough to search for - myvar. I suppose it is because we read from left to right that the first one seems better to you. Probably. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
On Aug 16, 4:22 am, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: I don't like normal assignment. After nearly four decades of mathematics and programming, I'm used to it, but I don't think it is especially good. It confuses beginners to programming: they get one set of behaviour drilled into them in maths class, and then in programming class we use the same notation for something which is almost, but not quite, the same. Consider the difference between: y = 3 + x x = z as a pair of mathematics expressions versus as a pair of assignments. What conclusion can you draw about y and z? Yeah, the syntax most commonly used for assignment today sucks. In the past, it was common to see languages with syntaxes like y - y + 1 or y := y + 1 or let y = y + 1 But these languages have mostly fallen out of favor. The popular statistical programming language R still uses the y - y + 1 syntax, though. Personally, my favorite is Lisp, which looks like (set! y (+ y 1)) or (let ((x 3) (y 4)) (foo x y)) I like to be able to read everything from left to right, and Lisp does that more than any other programming language. I would definitely not like a language that obscures assignment by moving it over to the right side of lines. |ouglas -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
Steven D'Aprano wrote: I don't like normal assignment. After nearly four decades of mathematics and programming, I'm used to it, but I don't think it is especially good. It confuses beginners to programming: they get one set of behaviour drilled into them in maths class, and then in programming class we use the same notation for something which is almost, but not quite, the same. Consider the difference between: y = 3 + x x = z as a pair of mathematics expressions versus as a pair of assignments. What conclusion can you draw about y and z? What you're saying is true, but it's still a matter of terminology. The symbol = means different things in different contexts, and mathematics and programming are very different ones indeed. The problem is compounded with early languages which lazily confused the two in different context, such as (but not exclusive to) BASIC using = for both assignment and equality testing in what are in esssence totally unrelated contexts. Even though it looks funny due to unfamiliarity, I'd love to see the results of a teaching language that used notation like: 3 + x - y len(alist) - n Widget(1, 2, 3).magic - obj etc. for assignment. My prediction is that it would be easier to learn, and just as good for experienced coders. This really isn't new at all. Reverse the arrow and the relationship to get:: y - x + 3 (and use a real arrow rather than ASCII) and that's assignment in APL and a common representation in pseudocode ever since. Change it to := and that's what Pascal used, as well as quite a few mathematical papers dealing with iterative computations, I might add. Once you get past the point of realizing that you really need to make a distinction between assignment and equality testing, then it's just a matter of choosing two different operators for the job. Whether it's -/= or :=/= or =/== or -/= (with reversed behavior for assignment) is really academic and a matter of taste at that point. Given the history of programming languages, it doesn't really look like the to-be-assigned variable being at the end of expression is going to get much play, since not a single major one I'm familiar with does it that way, and a lot of them have come up with the same convention independently and haven't seen a need to change. -- Erik Max Francis m...@alcyone.com http://www.alcyone.com/max/ San Jose, CA, USA 37 18 N 121 57 W AIM/Y!M/Skype erikmaxfrancis Get there first with the most men. -- Gen. Nathan Bedford Forrest, 1821-1877 -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
Douglas Alan wrote: Personally, my favorite is Lisp, which looks like (set! y (+ y 1)) For varying values of Lisp. `set!` is Scheme. -- Erik Max Francis m...@alcyone.com http://www.alcyone.com/max/ San Jose, CA, USA 37 18 N 121 57 W AIM/Y!M/Skype erikmaxfrancis Get there first with the most men. -- Gen. Nathan Bedford Forrest, 1821-1877 -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
On Aug 16, 4:48 am, Erik Max Francis m...@alcyone.com wrote: Douglas Alan wrote: Personally, my favorite is Lisp, which looks like (set! y (+ y 1)) For varying values of Lisp. `set!` is Scheme. Yes, I'm well aware! There are probably as many different dialects of Lisp as all other programming languages put together. |ouglas -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
On Sun, 16 Aug 2009 01:41:41 -0700, Douglas Alan wrote: I like to be able to read everything from left to right, and Lisp does that more than any other programming language. I would definitely not like a language that obscures assignment by moving it over to the right side of lines. One could argue that left-assigned-from-right assignment obscures the most important part of the assignment, namely *what* you're assigning, in favour of what you're assigning *to*. In any case, after half a century of left-from-right assignment, I think it's worth the experiment in a teaching language or three to try it the other way. The closest to this I know of is the family of languages derived from Apple's Hypertalk, where you do assignment with: put somevalue into name (Doesn't COBOL do something similar?) Beginners found that *very* easy to understand, and it didn't seem to make coding harder for experienced Hypercard developers. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
On Sunday 16 August 2009 12:18:11 Steven D'Aprano wrote: In any case, after half a century of left-from-right assignment, I think it's worth the experiment in a teaching language or three to try it the other way. The closest to this I know of is the family of languages derived from Apple's Hypertalk, where you do assignment with: put somevalue into name (Doesn't COBOL do something similar?) Yup. move banana to pineapple. move accountnum in inrec to accountnum in outrec. move corresponding inrec to outrec. It should all be upper case of course... I cannot quite recall, but I have the feeling that in the second form, of was also allowed instead of in, but it has been a while now so I am probably wrong. The move was powerful - it would do conversions for you based on the types of the operands - it all just worked. - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
Douglas Alan wrote: [snip] C++ also allows for reading from stdin like so: cin myVar; I think the direction of the arrows probably derives from languages like APL, which had notation something like so: myVar - 3 [] - myVar - was really a little arrow symbol (APL didn't use ascii), and the first line above would assign the value 3 to myVar. In the second line, the [] was really a little box symbol and represented the terminal. Assigning to the box would cause the output to be printed on the terminal, so the above would output 3. If you did this: [] - myVar It would read a value into myVar from the terminal. APL predates Unix by quite a few years. No, APL is strictly right-to-left. - x means goto x. Writing to the console is: [] - myVar Reading from the console is: myVar - [] -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
On Aug 16, 8:45 am, MRAB pyt...@mrabarnett.plus.com wrote: No, APL is strictly right-to-left. - x means goto x. Writing to the console is: [] - myVar Reading from the console is: myVar - [] Ah, thanks for the correction. It's been 5,000 years since I used APL! |ouglas -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
On Aug 16, 6:18 am, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: On Sun, 16 Aug 2009 01:41:41 -0700, Douglas Alan wrote: I would definitely not like a language that obscures assignment by moving it over to the right side of lines. One could argue that left-assigned-from-right assignment obscures the most important part of the assignment, namely *what* you're assigning, in favour of what you're assigning *to*. The most important things are always the side-effects and the name- bindings. In a large program, it can be difficult to figure out where a name is defined, or which version of a name a particular line of code is seeing. Consequently languages should always go out of their way to make tracking this as easy as possible. Side effects are also a huge issue, and a source of many bugs. This is one of the reasons that that are many functional languages that prohibit or discourage side-effects. Side effects should be made as obvious as is feasible. This is why, for instance, in Scheme, variable assignment as an exclamation mark in it. E.g., (set! x (+ x 1)) The exclamation mark is to make the fact that a side effect is happening there stand out and be immediately apparent. And C++ provides the const declaration for similar reasons. In any case, after half a century of left-from-right assignment, I think it's worth the experiment in a teaching language or three to try it the other way. The closest to this I know of is the family of languages derived from Apple's Hypertalk, where you do assignment with: put somevalue into name That's okay with me, but only because the statement begins with put, which lets you know at the very beginning of the line that something very important is happening. You don't have to scan all the way to the right before you notice. Still, I would prefer let name = somevalue as the let gives me the heads up right away, and then immediately after the let is the name that I might want to be able to scan for quickly. |ouglas -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
On Sun, 16 Aug 2009 05:05:01 +, Steven D'Aprano wrote: Now that I understand what the semantics of cout Hello world are, I don't have any problem with it either. It is a bit weird, Hello world cout would probably be better, Placing the stream on the LHS allows the main forms of to be implemented as methods of the ostream class. C++ only considers the LHS operand when attempting to resolve an infix operator as a method. Also, and are left-associative, and that cannot be changed by overloading. Having the ostream on the LHS allows the operators to be chained: cout Hello , world endl equivalent to: (((cout Hello) , ) world) endl [operator returns the ostream as its result.] Even if you could make right-associative, the values would have to be written right-to-left: endl world , Hello cout i.e.: endl (world (, (Hello cout))) -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
On Friday 14 August 2009 18:11:52 Steven D'Aprano wrote: On Fri, 14 Aug 2009 07:07:31 -0700, Aahz wrote: I saw `cout' being shifted Hello world times to the left and stopped right there. --Steve Gonedes Assuming that's something real, and not invented for humour, I presume that's describing something possible in C++. Am I correct? What the hell would it actually do??? It would shift cout left Hello World times. It is unclear if the shift wraps around or not. It is similar to a banana *holding his hands apart about a foot* this colour. - Hendrik -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
On Sat, Aug 15, 2009 at 4:47 AM, Hendrik van Rooyenhend...@microcorp.co.za wrote: On Friday 14 August 2009 18:11:52 Steven D'Aprano wrote: On Fri, 14 Aug 2009 07:07:31 -0700, Aahz wrote: I saw `cout' being shifted Hello world times to the left and stopped right there. --Steve Gonedes Assuming that's something real, and not invented for humour, I presume that's describing something possible in C++. Am I correct? What the hell would it actually do??? It would shift cout left Hello World times. It is unclear if the shift wraps around or not. It is similar to a banana *holding his hands apart about a foot* this colour. - Hendrik I think you managed to successfully dereference the null pointer there... Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
On Aug 14, 10:25 pm, Dave Angel da...@ieee.org wrote: Benjamin Kaplan wrote: On Fri, Aug 14, 2009 at 12:42 PM, Douglas Alan darkwate...@gmail.comwrote: P.S. Overloading left shift to mean output does indeed seem a bit sketchy, but in 15 years of C++ programming, I've never seen it cause any confusion or bugs. The only reason it hasn't is because people use it in Hello World. I bet some newbie C++ programmers get confused the first time they see used to shift. People typically get confused by a *lot* of things when they learn a new language. I think the better metric is how people fare with a language feature once they've grown accustomed to the language, and how long it takes them to acquire this familiarity. Actually, I've seen it cause confusion, because of operator precedence. The logical shift operators have a fairly high level priority, so sometimes you need parentheses that aren't obvious. Fortunately, most of those cases make compile errors. I've been programming in C++ so long that for me, if there's any confusion, it's the other way around. I see or and I think I/ O. I don't immediately think shifting. Fortunately, shifting is a pretty rare operation to actually use, which is perhaps why C++ reclaimed it for I/O. On the other hand, you are right that the precedence of is messed up for I/O. I've never seen a real-world case where this causes a bug in C++ code, because the static type-checker always seems to catch the error. In a dynamically typed language, this would be a much more serious problem. |ouglas P.S. I find it strange, however, that anyone who is not okay with abusing operator overloading in this manner, wouldn't also take umbrage at Python's overloading of + to work with strings and lists, etc. Numerical addition and sequence concatenation have entirely different semantics. -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
I guess the problem is---does it actually matter? On Fri, Aug 14, 2009 at 10:11 AM, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Fri, 14 Aug 2009 07:07:31 -0700, Aahz wrote: I saw `cout' being shifted Hello world times to the left and stopped right there. --Steve Gonedes Assuming that's something real, and not invented for humour, I presume that's describing something possible in C++. Am I correct? What the hell would it actually do??? -- Steven -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
On Sat, 15 Aug 2009 20:00:23 -0700, Douglas Alan wrote: So, as far as I can tell, Python has no real authority to throw stones at C++ on this little tiny particular issue. I think you're being a tad over-defensive. I asked a genuine question about a quote in somebody's signature. That's a quote which can be found all over the Internet, and the poster using it has (as far as I know) no official capacity to speak for Python -- while Aahz is a high-profile, well-respected Pythonista, he's not Guido. Now that I understand what the semantics of cout Hello world are, I don't have any problem with it either. It is a bit weird, Hello world cout would probably be better, but it's hardly the strangest design in any programming language, and it's probably influenced by input redirection using in various shells. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
On Aug 16, 1:05 am, Steven D'Aprano st...@remove-this- cybersource.com.au wrote: On Sat, 15 Aug 2009 20:00:23 -0700, Douglas Alan wrote: So, as far as I can tell, Python has no real authority to throw stones at C++ on this little tiny particular issue. I think you're being a tad over-defensive. Defensive? Personally, I prefer Python over C++ by about a factor of 100X. I just find it a bit amusing when someone claims that some programming language has a particular fatal flaw, when their own apparently favorite language has the very same issue in an only slightly different form. the poster using it has (as far as I know) no official capacity to speak for Python I never thought he did. I wasn't speaking literally, as I'm not under the opinion that any programming language has any literal authority or any literal ability to throw stones. Now that I understand what the semantics of cout Hello world are, I don't have any problem with it either. It is a bit weird, Hello world cout would probably be better, but it's hardly the strangest design in any programming language, and it's probably influenced by input redirection using in various shells. C++ also allows for reading from stdin like so: cin myVar; I think the direction of the arrows probably derives from languages like APL, which had notation something like so: myVar - 3 [] - myVar - was really a little arrow symbol (APL didn't use ascii), and the first line above would assign the value 3 to myVar. In the second line, the [] was really a little box symbol and represented the terminal. Assigning to the box would cause the output to be printed on the terminal, so the above would output 3. If you did this: [] - myVar It would read a value into myVar from the terminal. APL predates Unix by quite a few years. |ouglas -- http://mail.python.org/mailman/listinfo/python-list
OT Signature quote [was Re: Unrecognized escape sequences in string literals]
On Fri, 14 Aug 2009 07:07:31 -0700, Aahz wrote: I saw `cout' being shifted Hello world times to the left and stopped right there. --Steve Gonedes Assuming that's something real, and not invented for humour, I presume that's describing something possible in C++. Am I correct? What the hell would it actually do??? -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
On 2009-08-14, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Fri, 14 Aug 2009 07:07:31 -0700, Aahz wrote: I saw `cout' being shifted Hello world times to the left and stopped right there. --Steve Gonedes Assuming that's something real, and not invented for humour, I presume that's describing something possible in C++. Am I correct? Yes. In C++, the operator is overloaded. Judging by the context in which I've seen it used, it does something like write strings to a stream. What the hell would it actually do??? IIRC in C++, cout Hello world; is equivalent to this in C: printf(Hellow world); or this in Python: print hellow world -- Grant Edwards grante Yow! Bo Derek ruined at my life! visi.com -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
Grant Edwards wrote: On 2009-08-14, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Fri, 14 Aug 2009 07:07:31 -0700, Aahz wrote: I saw `cout' being shifted Hello world times to the left and stopped right there. --Steve Gonedes Assuming that's something real, and not invented for humour, I presume that's describing something possible in C++. Am I correct? Yes. In C++, the operator is overloaded. Judging by the context in which I've seen it used, it does something like write strings to a stream. What the hell would it actually do??? IIRC in C++, cout Hello world; It also returns cout, so you can chain them: cout Hello, name '\n'; is equivalent to this in C: printf(Hellow world); or this in Python: print hellow world -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
On Aug 14, 12:17 pm, Grant Edwards inva...@invalid wrote: On 2009-08-14, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: On Fri, 14 Aug 2009 07:07:31 -0700, Aahz wrote: I saw `cout' being shifted Hello world times to the left and stopped right there. --Steve Gonedes Assuming that's something real, and not invented for humour, I presume that's describing something possible in C++. Am I correct? Yes. In C++, the operator is overloaded. Judging by the context in which I've seen it used, it does something like write strings to a stream. There's a persistent rumor that it is *this* very abuse of overloading that caused Java to avoid operator overloading all together. But then then Java went and used + as the string concatenation operator. Go figure! |ouglas P.S. Overloading left shift to mean output does indeed seem a bit sketchy, but in 15 years of C++ programming, I've never seen it cause any confusion or bugs. -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
Grant Edwards wrote: On 2009-08-14, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: What the hell would it actually do??? IIRC in C++, cout Hello world; is equivalent to this in C: printf(Hellow world); or this in Python: print hellow world Well, plus or minus newlines. -- Erik Max Francis m...@alcyone.com http://www.alcyone.com/max/ San Jose, CA, USA 37 18 N 121 57 W AIM/Y!M/Skype erikmaxfrancis It's hard to say what I want my legacy to be when I'm long gone. -- Aaliyah -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
On 2009-08-14, Erik Max Francis m...@alcyone.com wrote: Grant Edwards wrote: On 2009-08-14, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: What the hell would it actually do??? IIRC in C++, cout Hello world; is equivalent to this in C: printf(Hellow world); or this in Python: print hellow world Well, plus or minus newlines. And a few miscellaneous typos... -- Grant Edwards grante Yow! I don't understand at the HUMOUR of the THREE visi.comSTOOGES!! -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
Grant Edwards wrote: On 2009-08-14, Erik Max Francis m...@alcyone.com wrote: Grant Edwards wrote: On 2009-08-14, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: What the hell would it actually do??? IIRC in C++, cout Hello world; is equivalent to this in C: printf(Hellow world); or this in Python: print hellow world Well, plus or minus newlines. And a few miscellaneous typos... ... and includes and namespaces :-). -- Erik Max Francis m...@alcyone.com http://www.alcyone.com/max/ San Jose, CA, USA 37 18 N 121 57 W AIM/Y!M/Skype erikmaxfrancis It's hard to say what I want my legacy to be when I'm long gone. -- Aaliyah -- http://mail.python.org/mailman/listinfo/python-list
Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
On Fri, Aug 14, 2009 at 12:42 PM, Douglas Alan darkwate...@gmail.comwrote: P.S. Overloading left shift to mean output does indeed seem a bit sketchy, but in 15 years of C++ programming, I've never seen it cause any confusion or bugs. The only reason it hasn't is because people use it in Hello World. I bet some newbie C++ programmers get confused the first time they see used to shift. -- http://mail.python.org/mailman/listinfo/python-list
Re: Re: OT Signature quote [was Re: Unrecognized escape sequences in string literals]
Benjamin Kaplan wrote: On Fri, Aug 14, 2009 at 12:42 PM, Douglas Alan darkwate...@gmail.comwrote: P.S. Overloading left shift to mean output does indeed seem a bit sketchy, but in 15 years of C++ programming, I've never seen it cause any confusion or bugs. The only reason it hasn't is because people use it in Hello World. I bet some newbie C++ programmers get confused the first time they see used to shift. Actually, I've seen it cause confusion, because of operator precedence. The logical shift operators have a fairly high level priority, so sometimes you need parentheses that aren't obvious. Fortunately, most of those cases make compile errors. C++ has about 17 levels of precedence, plus some confusing associative rules. And operator overloading does *NOT* change precedence. DaveA -- http://mail.python.org/mailman/listinfo/python-list