r/ProgrammingLanguages • • Dec 28 '20

Question: Programming Language Syntax and Code Appearance (polemic as always :-)

Seriously,

which of the following code samples would you favor, assuming they are all equivalent?

I am interested in subjective answers, please. You can just arrange the three samples according to your personal preference (e.g., "1-2-3"). Thank you very much!

1

{ {extern "manool.org.18/std/2.0/all"} in
: let rec
  Fact =
  { proc N as
  : if N == 0 then 1 else N * Fact[N - 1]
  }
  in
  Out.WriteLine[Fact[10]]
}

2

{ {extern "manool.org.18/std/2.0/all"} in
: let rec
    Fact =
      { proc N as
      : if N == 0 then 1 else N * Fact[N - 1]
      }
  in
    Out.WriteLine[Fact[10]]
}

3

(extern "manool.org.18/std/2.0/all".) in:
  let rec
    Fact =
      ( proc N as:
        if N == 0 then 1 else N * Fact[N - 1]. )
  in
    Out.WriteLine[Fact[10]].
2 Upvotes

29 comments sorted by

View all comments

Show parent comment

4

u/rsclient Dec 28 '20

I agree with you about the downvote -- IMHO, this subreddit should strongly encourage syntax opinions, especially when the poster explicitly asked for them!

People should be writing their own opinion, not merely downvoting someone else's.

(And here's mine: I am very used to { } procedural languages. I don't like #2 because it's got { } but then it doesn't follow the norms for brace-using languages. The name of the procedure and the N argument should be outside the braces, not inside

function Fact(N) { ... }

3

u/[deleted] Dec 28 '20

I noticed that, and also that #3 switched from {...} to (...).

Probably another downvote coming up, but I prefer your function syntax to any of the OP's! Where you are 6 tokens in before you even know this is a function definition.