3 ms·
Not a native English speaker, but I learnt that if and when have different meaning and also to translate them to different, non-interchangable words in my mothe
by weinzierl 5y ago
Not a native English speaker, but I learnt that if and when have different meaning and also to translate them to different, non-interchangable words in my mother tongue. The Cambridge dictionary seems to support that view:
"We use if to introduce a possible or unreal situation or condition. We use when to refer to the time of a future situation or condition that we are certain of."[1]
Could you really replace the if as used in a programming language context with when?
To me, when doesn't make sense in that context at all, but again, English is not my first language.
[1] https://dictionary.cambridge.org/grammar/british-grammar/if-or-when https://dictionary.cambridge.org/grammar/british-grammar/if-...
- bena 5y agoIt's kind of interchangeable if you consider not a single execution of your program/method, but every execution of your program/method. When you run it with "this" value, it'll do "this". When you run it with "that" value, it'll do "that". Because, eventually, all code paths will be run. It would also be semantically valid to say: When you execute this program/method, if the value is "this", do "this". At the end of the day, English rules are more what we like to call guidelines.
- weinzierl 5y agoThat makes sense indeed. I think what you described is the declarative viewpoint whereas I was thinking strictly imperative, where we are talking about a decision in one particular moment. > At the end of the day, English rules are more what we like to call guidelines. Tell that to my English teacher;-)
- dcminter 5y agoAs a native English speaker I'd say that's spot on. In particular, at least in British English, 'when' is never paired with 'else' - you might instead pair 'until' and 'when' and I suppose one could contort oneself into making a case for those keywords to create havoc!
- noneeeed 5y agoAlso a native english speaker. I was about to disagree with you, that we use "when" when several things might be true, but then I realised that in those cases each of the possibilities will happen, but at different times, like "when the light is read you stop, when it is green you go". It's fascinating how many quite subtle rules you internalise about your native language without realising it.
- jrmg 5y ago‘If’ is never really paired with ‘else’ in natural language either.