Live data from Hacker News

If-then-else had to be invented

github.com

51–60 of 255 posts

Re: If-then-else had to be invented

#52
Just one of those things that no one really questions the existence of. It, like the semicolon, always has been and will be.

Good work digging through these historic esoteric languages. Wikipedia states McCarthy of Lisp fame invented it so many of the evangelists here likely know the conclusion here.

Re: If-then-else had to be invented

#53
post #5

Ah, interesting, I wish the title had been prefixed with "What if ". There's a language where THEN basically means ENDIF... Forth, if memory serves me right?

Yes, and the inventor of the language eventually removed ELSE from his dialects, amusingly. These days he says that his code has very few conditional statements.

I think the tactic strategy to achieve this is to confine conditional branches in a few well chosen words.

For instance if you have a word SORT that sorts the top pair on the stack, which has to have a branch:

    : SORT 2DUP 
then you can build "if-less" MIN, MAX and ABS:

    : MIN SORT NIP ;

    : MAX SORT DROP ;

    : ABS 0 SORT SWAP - ;

Re: If-then-else had to be invented

#54
post #41
post #36

"Else" is not archaic. Every kid growing up in the sixties knew that the way to start a fight was to say "Or else!" It was used a lot in cowboy movies before a gunfight.

I think for these purposes, “else” is different from the “or else” construction. As in: “Read thee the article, else thou shall suffer great ridicule in the comments.”

"thee" is the dative (and later accusative) inflected form of "thou", the second person singular pronoun.

In your sentence above "Read" is the imperative form of the verb. The subject is elided since it's implicitly second person (singular or plural) (as imperative is used to give orders to people you're talking to) and if it wasn't elided it would have been in nominative case. Middle english had an ending -(e)th to form a plural second person imperative.

"Learn the grammar of past and present languages, else you'll attract pedants from the intertubes"

Re: If-then-else had to be invented

#55
post #33

I guess the unknown German word mentioned in the post is probably "sonst". It can be translated to "otherwise" or "else". And "wenn...dann...sonst" sounds perfectly natural in German.

Willing to bet it's either "sonst" or "andernfalls"... I'd suspect the latter, the former is a little bit too informal for mathematicians. Both of these are commonly used for case enumerations in math.

Maybe. On the other hand, "andernfalls" is a bit long as a keyword.

Re: If-then-else had to be invented

#56
post #50

Earlier quoted context omitted.

> But the "or" makes the meaning ambiguous I disagree that or is ambiguous. In English we use or to mean xor, that is one item or the other item but not both. If we want to clarify that choosing both items is an option we use the term and/or.

> I disagree that or is ambiguous There are examples of inclusive “or” in natural language. When the waiter asks: “Would you like cream or sugar?”, it’s not meant to imply that you should pick only one; it’s fine to answer “both” (example from: https://divisbyzero.com/2009/09/27/is-or-an-inclusive-or-or-... ).

And if you put a comma in, then it reverts it to exclusive or: “Would you like cream, or sugar?” This may depend on locale, however; I’m speaking of Australian English, and it’s possible that in some locales there may be a verbal cue to indicate the exclusive or but that it wouldn’t be spelled in any way. (As it stands, you could still have a pause before the “or” permitting inclusive or with two inqusitive portions: “Would you like cream? Or sugar?”)

This is a large part of why I dislike prescribed Oxford comma, because it undermines this legitimate use of a comma to alter the semantics.

Re: If-then-else had to be invented

#57
post #41
post #36

"Else" is not archaic. Every kid growing up in the sixties knew that the way to start a fight was to say "Or else!" It was used a lot in cowboy movies before a gunfight.

I think for these purposes, “else” is different from the “or else” construction. As in: “Read thee the article, else thou shall suffer great ridicule in the comments.”

(At least a couple of wrong words there: “thee” should be “thou”, and “shall” should be “shalt”. Also I reckon “thou shalt” reads much better as “shalt thou” in this style, though either is acceptable. Final proposed form: “Read thou the article, else shalt thou suffer great ridicule in the comments.” The overall style of the sentence is still rather off for the era, but it’ll do.)

Re: If-then-else had to be invented

#58

I remember there was a paper that tried to compare natural language usage of common programming language keywords to see if they may come up with other constructs to create a programming language that is easier to learn as your first one. There were a few interesting observations. The one that stuck with me the most is that 'and' is most commonly used with almost the opposite sense in natural language vs programming:…

The word “and” in English is simply there to join multiple clauses together. Whether it is a set union or set intersection, (or some other relations) depends on the sentence. Set union: they can read and write’ Set intersection: my jeans were creased and dirty Sequential: he turned round and walked out Causal: there was a flash flood and by the next morning the town was under water’ And, there are many more usages.

How is your set union example not another intersection (your quantification could go in one of two places though, they = (set of readers) cap (set of writers) versus they = { p in people such that (p writes) cap (p reads) }.

Re: If-then-else had to be invented

#59
post #37
post #8

Earlier quoted context omitted.

Wiktionary has a usage example from 1903, clearly before modern computers but not too ancient. > 1903, Jack London, The Call of the Wild, Grosset & Dunlap, page 44: > […] and his first experience taught him an unforgetable lesson. It is true, it was a vicarious experience, else he would not have lived to profit by it. As an aside there is at least one common word which does seem to have been invented by the software…

I believe that sentence should read “or else he would have...” to be grammatically correct.

Based on what, though?

Re: If-then-else had to be invented

#60
post #41
post #36

"Else" is not archaic. Every kid growing up in the sixties knew that the way to start a fight was to say "Or else!" It was used a lot in cowboy movies before a gunfight.

I think for these purposes, “else” is different from the “or else” construction. As in: “Read thee the article, else thou shall suffer great ridicule in the comments.”

If you are calling me archaic, I'm going to have to ask you to step outside, you young whippersnapper.
Post reply on HN