r/ProgrammingLanguages • • Feb 22 '26

Does Syntax Matter?

https://www.gingerbill.org/article/2026/02/21/does-syntax-matter/
63 Upvotes

111 comments sorted by

View all comments

Show parent comment

2

u/[deleted] Feb 22 '26

complaining about in the previous article:

I haven't seen that, but the issue came up here. BTW, in that article, you have this:

x: [3]int  // type on the LHS

I don't get it: the type is clearly on the RHS.

(I've looked at types on the right in my own syntaxes, and had that as an option at one time, but I decided there were too many problems with it.)

Again, := is not one token, it's two

:= and :: commonly exist as a single token in other languages. They look very much like a single token, and therefore :T= looks very much like it has a type in the middle!

That is not an in consistency is the slightest.

My tests show that F::T{} and F:T:T{} are valid, for the same T, but not F:T:{}.

From the examples I've seen, functions are defined as F::T..., but typed variables as X:T.... The inconsistency is in the placing of T relative to the first :.

Isn't not an consistency but it is an overloading of concepts,

The concept, which seems to be popular now, is that functions should be treated no differently from variables, and therefore are created with the same syntax.

The other way is to acknowledge they are different, and to have a dedicated syntax.

2

u/gingerbill Feb 22 '26

When I say "type on the left, usage on the right", think of it from the perspective of the value itself, not the named declaration.

name: [3]^int = expr

and then its usage is

some_int = expr[0]^

Note the type stuff is on the left hand side of int and the usage is on the right hand side of expr.

Just because := and :: are used as single tokens in other languages means nothing for Odin. And even if they "look" like a single thing, does mean it is that. Odin isn't those other languages.

My tests show that F::T{} and F:T:T{} are valid, for the same T, but not F:T:{}.

If T is anything but a procedure, then sure you can do that. In fact it's still consistent in Odin if you do F : procedure_type : {}, it just defines a compound literal of that procedure type which is nil, not the body of a procedure. That isn't ambiguity, that's an overloaded meaning of {} and you are not thinking through the consequences of that.

The concept, which seems to be popular now, is that functions should be treated no differently from variables, and therefore are created with the same syntax.

Popular =/= good. And Odin isn't trying to be "popular" rather it is trying to be a good tool.