News for hackers. Stuff that matters.
Re:Why Zig when there is already C++, D, and Rust? by agytvfr on Friday January 15, 2021 @06:29PM (#25798045)
In Zig? It would allocate stack space for a new variable a, and add b and the d field of c together and insert that value into the memory location that a reserved. In D or Python or anything that allows for properties, it would be allocating a where-ever the language allocates stuff, then calling an infix function '+' which could be anything depending on the language including starting up a JVM in the background for god knows what reason, and calls it with the arguments b and the result of calling the property function d of the object c.
Re:Why Zig when there is already C++, D, and Rust? by zabzonk on Friday January 15, 2021 @06:35PM (#25798112)
But what are the types of those fields it is "adding"? What are the semantics of "adding" for those types? These things are not obvious from reading that statement.
Re:Why Zig when there is already C++, D, and Rust? by qayxc on Friday January 15, 2021 @07:08PM (#25798394)
They are obvious to the programmer who knows the types of b and d and thus the semantics of adding them.

The operation itself implies that both b and c.d must be primitive types and so the semantics of the operation are defined by Zig's language rules.

edit: To clarify - this in contrast to, say C++, where nothing can be inferred about the types of the variables involved and the semantics of the operation, since '+' can be overloaded.