Live data from Hacker News

Vim's 400 line function to wait for keyboard input

geoff.greer.fm

61–70 of 239 posts

Re: Vim's 400 line function to wait for keyboard input

#61
Speaking of legacy platforms, anyone know of a vi/tinyvi/etc work-alike for CP/M?

I'm going to be doing some hacking on z80 assembly via Yaze, and it would be great if I could have the editor I'm used to, natively on the platform (rather than having to edit in OSX or whatever).

Re: Vim's 400 line function to wait for keyboard input

#62
post #20

Earlier quoted context omitted.

How do you know it works? Did you test it on every platform? What you would have to gain is maintainability. Maybe it's not worth it; maybe it is. But saying that there is nothing to be gained is just an opinion.

I bet that it contains fewer bugs than a rewrite of the code will have! That code represents years of tweaks, fixes and obscure workarounds. There are countless problems that you will re-introduce with a code rewrite, because the subtleties in aged, thoroughly-used code are not immediately obvious.

I agree, I just think your initial statement was a bit extreme.

Re: Vim's 400 line function to wait for keyboard input

#64
post #62

Earlier quoted context omitted.

I bet that it contains fewer bugs than a rewrite of the code will have! That code represents years of tweaks, fixes and obscure workarounds. There are countless problems that you will re-introduce with a code rewrite, because the subtleties in aged, thoroughly-used code are not immediately obvious.

I agree, I just think your initial statement was a bit extreme.

Yeah, on a re-read, my comment is too sure of itself. Never say never! But while there are always edge cases, IMO code rewriting is something that is almost never worth it. Especially a maintainability rewrite just for the sake of maintainability.

Re: Vim's 400 line function to wait for keyboard input

#65
I assume portability is why the function declaration is old K&R style and not ANSI prototype style. I'm always surprised when I see K&R style in modern(ish) code. I do miss the ability to declare multiple parameters of the same type without repeating the type name, though. Oddly, several modern languages (like D) seem to think that's a feature.

Re: Vim's 400 line function to wait for keyboard input

#66

But the code works. It supports lots of platforms through choice. Yes, you could make the code prettier if you dropped some platforms. Yes, you could refactor it to use some abstracting libraries that now exist. But the code works . If you rewrote the code, the best result you could end up with is the same functionality that still works. All other possible results are bad. There is nothing to be gained.

[deleted]

Re: Vim's 400 line function to wait for keyboard input

#67
post #48

But the code works. It supports lots of platforms through choice. Yes, you could make the code prettier if you dropped some platforms. Yes, you could refactor it to use some abstracting libraries that now exist. But the code works . If you rewrote the code, the best result you could end up with is the same functionality that still works. All other possible results are bad. There is nothing to be gained.

I made the page as a companion piece to a blog post[1]. The code works, but it's quite buggy. Also, it is almost certainly broken on outdated OSes. It's just that nobody uses the latest Vim on IRIX or VMS, so no bug reports get filed. A quick glance shows some obvious errors in RealWaitForChar(). For example: with typical preprocessor defines, it uses gettimeofday() in a select() loop. This will break if the system c…

> The code works, but it's quite buggy

Could you elaborate a bit? I've never experienced a bug related to keyboard input while using Vim, at least that I know of.

Re: Vim's 400 line function to wait for keyboard input

#70

If you are all such experts, why don't you "fix it" and then pull request it in.

Please, you can critique something even if you lack the skills to fix it, or the desire to fix it, or the time to fix it. Also, you can point out that something is broken even if you have no suggestions on how to fix it.

You can do whatever you like, but if you were raised right than you'd understand his point. Criticizing something that is broken with no desire/ability/whatever to fix just makes you look like a douche. If you can't do anything about it keep it to yourself; you're just wasting time otherwise.
Post reply on HN