4 ms·
Is it just me or does the closure version read more clearly?
by dnaquin 17y ago
Is it just me or does the closure version read more clearly?
- pvg 17y agoIt seems the purpose was to show three module definitions and then and then talk about them - in which case both the eval and meta versions are complete gibberish since they have absolutely nothing to do with his expository goals. Both basically amount to 'let me show you some cute Ruby code that would generate the code that I could have just shown you on three slides. Instead of showing you three slides, though, I'd like you to become a Ruby interpreter for a few moments'. This seems almost purposefully obtuse. As to eval itself, it's obviously not 'evil'. But nontrivial use can make code unreadable: doSomeStuff() eval(someVar) doOtherStuff() this can be read as doSomeStuff() doPrettyMuchAnythingConceivable() doOtherStuff() This neatly removes any ability to effectively reason about the code.
- mr_dbr 17y agoThe first bit of code seemed perfectly readable.. Seems like decreasing the font size a few points would have clearer a better solution than clouding the could with loops and `eval()`/closures.. Depending on the context, perhaps showing the first class "full size", and abbreviating the other two would work.. or, show the code for one, then explain "we define another class named C, which prints C, and final one named D, which prints D" - it is a "talk", after all.. That's why I consider `eval` to be "evil" - there's almost always a better way..