Earlier quoted context omitted.
Hmmm, thinking about my dialect of English (Lancastrian) I can certainly say else without an or and it doesn't sound unnatural to my ears. Something like "if you're hungry now then I can make you a sandwich, else we'll eat when we get to the pub" doesn't sound more awkward than using otherwise. I can't say whether that's just because the Lancastrian dialect preserves quite a few old fashioned usages that have fallen…
The consensus amongst the three English teachers I asked was that it should be "or else" or "otherwise" and that it's probably ungrammatical, although none of them could explain why. The one who is also an actor said "it works as a line" and she wouldn't think twice about it in a script or as written dialog. Interesting one though!
If-then-else had to be invented
251–255 of 255 posts
Re: If-then-else had to be invented
#252You don't need "else". if (x) then: doSomething(); if (!x) then: doOtherThing(); "Else" is a redundant construct, but it's nice to have for sure. I would prefer not writing the above code.
This doesn't work like "else" if doSomething() can change the value of x.
Re: If-then-else had to be invented
#253Earlier quoted context omitted.
The historical truth is that Lisp had COND first; IF was added later. Also, LAMBDA before LET. MacCarthy writes, in History of Lisp : I invented conditional expressions in connection with a set of chess legal move routines I wrotein FORTRAN for the IBM704 at M.I.T. during1957-58. This program did not use list processing. The IF statement provided in FORTRAN1 and FORTRAN2 was very awkward to use, and it was natural to…
An interesting historical note, but it says nothing about the relative 'primitiveness' of COND vs IF. It's not uncommon at all in mathematics to build a system with certain axioms, and then improve them later, when it's realized that simpler axioms can be used to build more complex constructs.
Re: If-then-else had to be invented
#254Earlier quoted context omitted.
You’ve framed it in the article and here again as a correctness issue, but it’s not a correctness issue. It’s fair to say you haven’t heard it, or that it’s uncommon today, but if you use it, it’s not wrong. And people will understand you, even if you do get a sideways glance from some people. You can use “else” without “or”, if you like. The article was fascinating, especially the historical examples from different…
I was a linguistics major in college and therefore am a descriptivist, not a prescriptivist about language. When I say I cannot say this, I mean that this construct does not exist in the ordinary dialect that I speak, in the same way that I can say "that doesn't need washed" even though speakers of many other dialects have to say "washing" instead. If it is in someone else's dialect, they can feel free to say it, but…
Re: If-then-else had to be invented
#255Earlier quoted context omitted.
> Also, "if / else" only supports 2 cases, with pattern matching you can have an arbitrary amount of cases. Coming from a non-pattern marching language (python) I’ve yet to see what the big deal is, maybe you can help. I can have as many elif’s as I need cases and other than maybe not needing to repeat `x==...` I’m not sure what I’m missing out on. With that being said, I do often wish for more elegant solutions to l…
To get an intuition for the expressive power you can look up examples of quicksort and factorial in languages that support pattern matching. Haskell is a good example. It is true that you can always just use if statements, it's more about the convenience and cleaner syntax. You can also do destructuring with pattern matching. Pattern matching is almost a requirement if you are going to use algebraic data types. As Pa…
It made me rethink the premise of my question.