4 ms·
Strange syntax choices, Pascal/Ruby style statements with C-like type notation order?
by eterps 3y ago
Strange syntax choices, Pascal/Ruby style statements with C-like type notation order?
- flohofwoe 3y agoThis isn't C-like type notation order though? let variable: type = value Or do you mean pointer and array notation? let pointer: type* = address let array: type[n] = [elem1, elem2, ..., elemn] ...at least the array type looks better to me then putting the size in front. Putting the '*' after the type is debatable though.
- eterps 3y agoYes, I meant pointer (and array) notation. To give a view examples of notation in other languages: Modula-2, p: POINTER TO INTEGER Nim, p: ref int Odin: p: ^int Go: p: *int
- Joker_vD 3y agoAnd as for arrays, VAR array: ARRAY n OF type = [elem1, elem2, ..., elemn]; also doesn't look questionable to me, with or without square brackets around "n".
- deleted 3y ago[deleted]
- trealira 3y agoThe modifiers (pointer, "function taking _ returning _", "array N of", etc.) are prefixed, but they could just as well be postfixed. I think people don't do it because it's more similar to English to make the modifiers prefixed. C: int *p; Prefix: p: pointer to int; Postfix: p: int pointer; Another example. C: int (*fp_arr[5])(int, int); Prefix: fp_arr: array 5 of pointer to function(int, int) to int; Postfix: fp_arr: int (int, int) pointer array 5; This is something I was thinking about because some non-English languages use post positions instead of prepositions, and say the verb last instead of in the middle. For example, in English, you could say "He looks at me," and in some other languages, you'd say the equivalent of "He me-at looks". Instead of "I went to the bathroom" it would be the equivalent of "I bathroom-to went." And instead of "the fifth day of the month" it might be something like "month of fifth day", except "of" has the opposite meaning. I'm speaking vaguely because I've only read about such languages from a linguistics perspective, and I don't know them. Specifically, head-initial vs head-final languages: https://en.wikipedia.org/wiki/Branching_(linguistics) https://en.wikipedia.org/wiki/Branching_(linguistics)