Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think it would be better to either find a legitimate use for the feature, or conclude that it might be a mis-feature.

For example, I can see the value of allowing a default function argument to be a Proc/lambda. I can even imagine how it might make sense to allow it to be a named function declaration -- if def actually returned a function object, rather than nil as the article notes. But what the author demonstrates seems to me nothing more than a broken consequence of Ruby's syntax.

Finding weird corner cases may indeed be very hacker-ish, but blindly labeling them as good is not, in my opinion.

I could be wrong about the value of this construct; someone might come up with something useful you can do with it. But, until then, I'm not going to view it as anything other than a curiosity, not as an example of "ZOMG look how cool Ruby is!!11!".

Regarding Symbol#to_proc, I would say that it is only syntactically weird. But if you have any background with functional languages, it's an incredibly natural semantic construct.



Finding weird corner cases may indeed be very hacker-ish, but blindly labeling them as good is not, in my opinion.

Did Thomas do that? I don't see anywhere where he "blindly label(s) them as good". Right there in the title he calls them Quirks, and he says you have to love them. Then, in the text he explains, quite clearly, that you should almost never use these in actual code.

I think you've missed the point that the examples presented (especially the function definition in a default argument) merely show how Ruby works; specifically that all code is executed as expressions during runtime. To me these "quirks" are similar to showing somebody that dereferencing an offset to an array pointer in C is the same as using an array index. You're not going to do it in production code, but knowing that it's possible helps in better understanding what's going on with all that code you write.


Troll




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: