4 ms·
I'm talking more about shortening words where they don't need to be shortened. For instance one of my beefs with Ruby (My main language) is: elsif. Would it re
by ThinkWriteMute 17y ago
I'm talking more about shortening words where they don't need to be shortened.
For instance one of my beefs with Ruby (My main language) is: elsif. Would it really have been so difficult to have "elseif"? No.
- mncaudill 17y agoYour Ruby example is to help the developer. Let's say you are skimming your code. Are you going to quickly and easily see the difference between "elseif" and "else if"? Creating a new word, while superficially unwieldly, keeps you from wasting valuable time debugging one of those "d'oh!" bugs.
- ThinkWriteMute 17y agoAnd the developer who writes "elseif" instead of "elsif" because "else" is a word and "els" isn't? Sorry that argument works both ways.
- mncaudill 17y agoWhat I'm saying is that if "else" and "elseif" were both in the grammar (and "elsif" didn't exist), you could have typed "else if" when you meant to type "elseif" and vice-versa and the mistake could easily be overlooked as your code would be syntactically correct, parsing and running and doing the wrong thing. Now, in Ruby, if you type "elseif" your code will not run. Problem avoided. The point of Ruby's "elsif" and Python's "elif" is to have visually disparate representations of the two kinds of code blocks (that have different control flows!) that a developer could easily overlook. The difference is there to help out you and every other developer that use languages that don't use a visible token to separate code blocks, I promise.
- aaronblohowiak 17y ago"you could have typed "else if" when you meant to type "elseif" and vice-versa and the mistake could easily be overlooked as your code would be syntactically correct, parsing and running and doing the wrong thing." can you give an example where this would make a difference?