From: matz@... (Yukihiro Matsumoto) Date: 2002-09-27T08:25:20+09:00 Subject: Re: Ruby - common pitfalls? Hi, In message "Ruby - common pitfalls?" on 02/09/27, Rudolf Polzer writes: |- the if syntax. Pascal-style if is supported (and one is tempted to use | it instead of the also supported C-style if since parantheses aren't | easy to enter on most keyboards), but comparisons have to be written | in C style. Therefore this happened to me more than once: | | if foo = nil then | # ... | end | | It's getting even worse because nil is named 'nil', like it is in | Pascal. Hmm, if you are Pascal addicted, you have to write if foo = nil then begin # ... end and should get syntax error. ;-) It might be dangerous for Modula-2 users. |- accessing one character in a string. | | s[3] does not do what most programmers would expect: May change in the future, due to M17N support. |- a %= b versus %=...=. A syntax highlighter gets into big trouble when | seeing this construct. Nothing really seriuos, but I already had to | insert "useless" comments to fix vim's highlighting - which is unable | to correctly highlight if-then-end expressions. Perhaps it would help | to deprecate %=...= as string separator (any other character could be | used with less problems). I admit Ruby syntax highlighter must be very smart. | *a = *b + *c | |would be possible? No way, I like the following |Or perhaps instead: | | a.zipWith! (b) do |x, y| x + y end # slightly resembling Haskell | a = b.zipWith (c) do |x, y| x + y end | |which is a bit more verbose, but can be done with the current syntax. iff it has a better name than zipWith. matz.