Re:Donald Knuth used an Erlang-like notation
by old_sound on Wednesday October 19, 2016 @02:19AM
(#12741528)
For me what's striking about Erlang syntax is the meaning of the semi-colon and the period, as function clause separator. Most of the rest is just vanilla FP lang syntax.
Re:Donald Knuth used an Erlang-like notation
by DanielMcLaury on Wednesday October 19, 2016 @02:49AM
(#12741628)
To be fair that's just vanilla English orthography.
Re:Donald Knuth used an Erlang-like notation
by old_sound on Wednesday October 19, 2016 @02:54AM
(#12741651)
Yup, and still people get confused at Erlang's use of semi-colons and periods.
Do you think it is because other programming languages don't uses the semi-colon that way? Or that periods are usually used to access class members, but not to finish function declarations?
Re:Donald Knuth used an Erlang-like notation
by klibertp on Wednesday October 19, 2016 @05:16AM
(#12742304)
I think it's because most people have no idea how to use semicolons in natural languages too.
Re:Donald Knuth used an Erlang-like notation
by kbenson on Wednesday October 19, 2016 @01:10PM
(#12745595)
I think this is true. Anecdotally, I've looked up the usage of semicolons a few times now, and I think I know how to use them, but every time I'm about to I just rephrase what I'm saying so I don't have to. They are used so rarely in English it's hard to feel confident through exposure.
Re:Donald Knuth used an Erlang-like notation
by adrianratnapala on Wednesday October 19, 2016 @02:50PM
(#12746573)
I use semicolons all the time; they are easy and useful.
The two clauses separated by a semicolon are sentences; thus the semicolon is logically and grammatically equivalent to a full stop. (As long as you normalise the capitalisation). The difference is in nuance, flow, and other soft things.
So when do you use a semicolon instead of a full stop? Whenever you want to!
The really difficult punctuation mark in English is the full colon.
Re:Donald Knuth used an Erlang-like notation
by kbenson on Wednesday October 19, 2016 @03:25PM
(#12746903)
Sure, which is what the rules always say, and is fairly straightforward. The hard part is actually using it because it usually looks so out of place to me. It's a chicken and egg problem, where semicolons are hard to comfortably use because they are so rare they look out of place when I try, and I assume part of the reason for their rarity is other people feel the same way.
Re:Donald Knuth used an Erlang-like notation
by petertodd on Wednesday October 19, 2016 @06:04PM
(#12748113)
What's a full colon? Hard/NSFW to google for that...
Re:Donald Knuth used an Erlang-like notation
by dragonwriter on Wednesday October 19, 2016 @06:09PM
(#12748145)
Just a plain colon, as an emphatic distinction from a semicolon.
Re:Donald Knuth used an Erlang-like notation
by tombert on Wednesday October 19, 2016 @10:01AM
(#12743799)
I feel like the semicolon-period thing of Erlang is only really frustrating for the first day you're using it. After that, I actually found it to be a fairly natural syntax, and had little trouble switching between it and JS.
Re:Donald Knuth used an Erlang-like notation
by qohen on Thursday October 20, 2016 @02:21AM
(#12750089)
Erlang's usage of commas, semi-colons and periods is based on Prolog's use of these punctuation-marks. (Erlang was developed in Prolog and retains many similarities to it).
f [n] = [n]
f [m, n] = [m, n, 0, 1]
f [m, n, r, 1] = [m, n, mod m n, 2]
f [m, n, r, 2] = if r == 0 then [n] else [m, n, r, 3]
f [m, n, p, 3] = [n, p, p, 1]
It needs to be implemented with variable-length lists instead of fixed-length tuples, in order to satisfy the type system.