Hacker News new | past | comments | ask | show | jobs | submit login

In my previous life I was maintaining some backend services. One of the most common reasons for a service dying was a typo in a name in some rarely visited code path. I was tempted to write a similar module that would be a little bit smarter: when some identifier (variable, method, etc.) was not found, instead of raising an exception, try to find a similarly named thing and use that instead. I never did find a good way of implementing that.



I think you might like something like TheFuck? EDIT: This bash commandline completion has been updated to by default wait for the user to verify the replacement command is what they wanted; this pretty much turns this from a terminal Russian Roulette into a kinda handy autosuggestion!

https://github.com/nvbn/thefuck

(Previous discussion: https://news.ycombinator.com/item?id=9396116 )


That's probably for the best.


Seriously, that's asking for unpredictable behavior. Maybe if it printed the suggestion to the logs and then failed it would be ok.


Yes, it's crazy. I saw a Python library a while ago that when would pip install any missing module, even if it's because of a typo. Crazy.


I spilled tea because of laughter induced by your comment. well done.


How about better testing and path coverage of your code? I hope that was also explored as a way to stabilize your codebase? Otherwise your suggestion does come offa bit as 'cowboy-ish' to say the least ...


Ruby has a language feature for this and it's pure 100% poison.

http://rubylearning.com/satishtalim/ruby_method_missing.html


That came from Smalltalk, where it was named doesNotUnderstand. It's always difficult to choose between crippling the language and encouraging stupidity.


that is neither what OP mentioned (automatic matching of a typo) nor poison.

Also, it's from Smalltalk, and found in some ways also in python, objective-c and many others.




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

Search: