tag:blogger.com,1999:blog-27488238.post115272288565148428..comments2024-03-22T11:34:45.165+01:00Comments on taw's blog: List of things that suck in Rubytawhttp://www.blogger.com/profile/16972845140253292628noreply@blogger.comBlogger18125tag:blogger.com,1999:blog-27488238.post-75668378917693144182011-03-20T23:19:07.627+01:002011-03-20T23:19:07.627+01:00Significant whitespace would cripple Ruby. There a...Significant whitespace would cripple Ruby. There are several drawbacks, the biggest in Python is that it doesn't allow for multiline lambdas.<br /><br />It is the biggest reason why Python is so rigid.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-27488238.post-69852867169342593332007-06-05T09:37:00.000+02:002007-06-05T09:37:00.000+02:00"It's not possible to change class of an existing ..."It's not possible to change class of an existing object." I think you would love to use a prototype-oriented language, like http://iolanguage.com<BR/><BR/>For history between sessions in ALL languages, see rlwrap.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-27488238.post-52577179244079010182007-06-05T07:38:00.000+02:002007-06-05T07:38:00.000+02:00Check Wirble for irb related stuff like history be...Check <A HREF="http://pablotron.org/software/wirble/" REL="nofollow">Wirble</A> for irb related stuff like history between session and syntax coloring.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-27488238.post-41537367649286162932007-06-05T05:47:00.000+02:002007-06-05T05:47:00.000+02:00黄毅: Ruby can do that with non-standard evil-ruby l...黄毅: Ruby can do that with non-standard <A HREF="http://code.google.com/p/evil-ruby/" REL="nofollow">evil-ruby</A> library. I'd much rather have it as an official supported feature, like in Python and Perl.tawhttps://www.blogger.com/profile/16972845140253292628noreply@blogger.comtag:blogger.com,1999:blog-27488238.post-84114316663494945792007-06-05T05:32:00.000+02:002007-06-05T05:32:00.000+02:00The first one "change class of an existing object"...The first one "change class of an existing object", python can do that too.<BR/><BR/><B>obj.__class__ = Klass </B>黄毅https://www.blogger.com/profile/01060629900676151700noreply@blogger.comtag:blogger.com,1999:blog-27488238.post-78290601447914643152007-03-10T10:13:00.000+01:002007-03-10T10:13:00.000+01:00re: It's not possible to change class of an existi...re: It's not possible to change class of an existing object...<BR/><BR/>Technically no, but you can just use singleton classes for most things.<BR/><BR/>widj = Factory.new($some_xml_in)<BR/>...<BR/>Later we discover we want widj to be (for instance) a modal dialog:<BR/><BR/>class << widj<BR/> include ModalDialogBehavior<BR/>end<BR/><BR/>Or at least it seem to me that something like that would be a workable scheme.<BR/><BR/>Cullencjhttps://www.blogger.com/profile/07095119449400438181noreply@blogger.comtag:blogger.com,1999:blog-27488238.post-79147628043033367272007-03-10T09:58:00.000+01:002007-03-10T09:58:00.000+01:00To get IRB to remember state across sessions, see ...To get IRB to remember state across sessions, see here:<BR/><BR/>http://blog.nicksieger.com/articles/2006/04/23/tweaking-irbcjhttps://www.blogger.com/profile/07095119449400438181noreply@blogger.comtag:blogger.com,1999:blog-27488238.post-11703820880772401852007-01-03T20:15:00.000+01:002007-01-03T20:15:00.000+01:00Local variable scoping in Ruby sucks, but not a si...Local variable scoping in Ruby sucks, but not a single language got it right yet.<br /><br />Ruby scoping is quite decent, with a single exception that block arguments are not automatically locally scoped, and it's very easy to make a silly mistake. They plan to fix it in Ruby 2.<br /><br />(0..1).times{|i|<br /> (2..3).times{|i|}<br /> # Will output 3 3, not 0 1<br /> puts i<br />}<br /><br />Ruby still beats all other languages I know, as far as local scopes are concerned. Python has no real nested scopes, and most other languages require explicit declaration for each local variable, what is absolutely abhorrent.<br /><br />And seriously, in your example, how could you expect v not to be shared ? It is obviously the same v, it's very hard to imagine making such a mistake unintentionally.tawhttps://www.blogger.com/profile/16972845140253292628noreply@blogger.comtag:blogger.com,1999:blog-27488238.post-48322286484391939112007-01-03T12:02:00.000+01:002007-01-03T12:02:00.000+01:00Taw, are you also missing a feature for enforcing ...Taw, are you also missing a feature for enforcing a local variable scope (like done by keyword "my" in Perl or "local" in Lua)?<br /><br />f = lambda do<br /> v = 1<br /> g = lambda do<br /> v = 2 # Oops!<br /> 3 * v<br /> end<br /> [v + g[], g[] + v]<br />end<br />puts f[]<br /><br />In the line commented by "Oops!" variable v is unintentionally shared with the one of the outer lambda.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-27488238.post-1157361138596656342006-09-04T11:12:00.000+02:002006-09-04T11:12:00.000+02:00I see your point, which makes sense indeed. Thank ...I see your point, which makes sense indeed. Thank you very much for the clarification.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-27488238.post-1157339021330303402006-09-04T05:03:00.000+02:002006-09-04T05:03:00.000+02:00Well, end-less syntax was just a wishlist item, I'...Well, end-less syntax was just a wishlist item, I'm fully aware that it would probably require severe backwards compatibility breakage.<BR/><BR/>Now as for keyword arguments, I might have expressed myself a bit vaguely, but the point is not enforcing a particular order (most functions do not care, nor should they), but being able to get the order information if the function wants to. It is occasionally useful in DSLs.<BR/><BR/>Example - defining a lexer using a set of regular expressions:<BR/>str.lex /foo/ => proc{blah1},<BR/> /bar/ => proc{blah2},<BR/> /./ => proc{warn "Funny character, ignoring"}<BR/><BR/>It looks very pretty this way, unfortunately the function has no way of knowing that /./ should be tried last :-). On the other hand this is much uglier:<BR/>str.lex /foo/, proc{blah1},<BR/> /bar/, proc{blah2},<BR/> /./ , proc{warn "Funny character, ignoring"}<BR/><BR/>There was some talk on Ruby-talk on hashes remembering order of insertions, and they would make syntax like that possible. It is not a big deal, it's just that Perl has it, and losing features when moving to a new language sucks, even if the features aren't that big :-)tawhttps://www.blogger.com/profile/16972845140253292628noreply@blogger.comtag:blogger.com,1999:blog-27488238.post-1157328484957564022006-09-04T02:08:00.000+02:002006-09-04T02:08:00.000+02:00hmm, as for the ugly 'end', Matz once said he did ...hmm, as for the ugly 'end', Matz once said he did some experiment to eliminate 'end' in early version of Ruby, but the syntax turned out to be too hard to parse. Maybe Ruby's syntax is way too flexible. :^)<BR/><BR/>I don't agree with you on keyword arguments, since I would have to remember the sequence of arguments without such feature, and therefore would require an IDE providing intelligent argument hint.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-27488238.post-1153992378717297052006-07-27T11:26:00.000+02:002006-07-27T11:26:00.000+02:00I submitted one that seems easiest to fix:RCR 342:...I submitted one that seems easiest to fix:<BR/><A HREF="http://www.rcrchive.net/rcr/show/342" REL="nofollow">RCR 342: Symbol should be Comparable</A><BR/><BR/>The one about massive symbolification would require a proof of concept code that it doesn't break backward compatibility in reasonable use cases. I think I'll RCR it later.tawhttps://www.blogger.com/profile/16972845140253292628noreply@blogger.comtag:blogger.com,1999:blog-27488238.post-1153715787588613892006-07-24T06:36:00.000+02:002006-07-24T06:36:00.000+02:00So what are the RCR numbers?http://www.rcrchive.ne...So what are the RCR numbers?<BR/><BR/>http://www.rcrchive.net/Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-27488238.post-1152811418577257842006-07-13T19:23:00.000+02:002006-07-13T19:23:00.000+02:00This is object-oriented expectation - if we (on co...This is object-oriented expectation - if we (on conceptual level) treat comparing as a method, then the thing I want is perfectly natural.<BR/><BR/>On the other hand if we (again, on conceptual level) consider comparing a function then it doesn't make that much sense.<BR/><BR/>So I think it just depends whether you're into object-oriented programming, or <A HREF="http://www.paulgraham.com/noop.html" REL="nofollow">not really</A>.tawhttps://www.blogger.com/profile/16972845140253292628noreply@blogger.comtag:blogger.com,1999:blog-27488238.post-1152801846298043002006-07-13T16:44:00.000+02:002006-07-13T16:44:00.000+02:00Lisp doesn't cater to that expectation (I don't th...Lisp doesn't cater to that expectation (I don't think it's particularly natural).Xachhttps://www.blogger.com/profile/04498567730331742642noreply@blogger.comtag:blogger.com,1999:blog-27488238.post-1152735703337942562006-07-12T22:21:00.000+02:002006-07-12T22:21:00.000+02:00This is technically true, but the thing that I'm e...This is technically true, but the thing that I'm expecting from a language is for every object to know how to compare itself with other objects of the same kind, and for this comparison to naturally extend itself to composite data structures. In Ruby I can do [[1,"foo"], [2,"bar"]].sort() and so on. In Python I can do sorted([(1,"foo"), (2,"foo"), (1,"bar")]).<BR/><BR/>In languages without it (or in which implementation of it is broken), like Perl, C++ or OCaml, I have to mindlessly code those comparison functions and explicitly use them. Now if you're not much into object-orientation you may think it's a very small issue, but I consider it a rather serious conceptual problem.<BR/><BR/>Extending comparability to Symbols in Ruby is just a few lines and I think it's just an oversight that it's not in the standard library:<BR/><BR/>class Symbol<BR/> include Comparable<BR/> def <=>(x)<BR/> to_s <=> x.to_s<BR/> end<BR/>end<BR/><BR/>As far as I know neither Common Lisp nor Scheme have any generic<= function (<= is only for numbers). Would it be possible to code it ? I really don't know much about CLOS and Lisp generic functions, so maybe I'm simply missing it.tawhttps://www.blogger.com/profile/16972845140253292628noreply@blogger.comtag:blogger.com,1999:blog-27488238.post-1152733762839807992006-07-12T21:49:00.000+02:002006-07-12T21:49:00.000+02:00(string tSymbols are string designators, so string...(string<= 'BAR 'FOO) => t<BR/><BR/>Symbols are string designators, so string sorting works fine for symbols.Xachhttps://www.blogger.com/profile/04498567730331742642noreply@blogger.com