I wish Zig had lovely vector, quaternion, matrix etx syntax. The team's refusal to add operator overloading will prevent this.
Agreed, their reason for not allowing it is weird. No hidden overloading? OK make it explicit then: #+, #/ would be fine.
Zig's Lovely Syntax
171–180 of 246 posts
Re: Zig's Lovely Syntax
#172> as name of the type, I think I like void more than () It's the wrong name though. In type theory, (), the type with one member, is traditionally called "Unit", while "Void" is the uninhabited type. Void is the return type of e.g. abort.
Cool trick: some languages (e.g. TypeScript) allow `void` generics making parameters of that type optional.
Re: Zig's Lovely Syntax
#173Re: Zig's Lovely Syntax
#174> Raw or multiline strings are spelled like this: const still_raw = \\const raw = \\ \\Roses are red \\ \\ Violets are blue, \\ \\Sugar is sweet \\ \\ And so are you. \\ \\ \\; \\ ; This syntax seems fairly insane to me.
Usually, representing multiline strings within another multiline string requires lots of non-trivial escaping. This is what this example is about: no escaping and no indent nursery needed in Zig.
Re: Zig's Lovely Syntax
#175> as name of the type, I think I like void more than () It's the wrong name though. In type theory, (), the type with one member, is traditionally called "Unit", while "Void" is the uninhabited type. Void is the return type of e.g. abort.
Re: Zig's Lovely Syntax
#176> as name of the type, I think I like void more than () It's the wrong name though. In type theory, (), the type with one member, is traditionally called "Unit", while "Void" is the uninhabited type. Void is the return type of e.g. abort.
A ton of people coming to Zig are going to be coming from C and C++. void is fine.
Re: Zig's Lovely Syntax
#177Earlier quoted context omitted.
Maybe if you've never tried formatting a traditional multiline string (e.g. in Python, C++ or Rust) before. If it isn't obvious, the problem is that you can't indent them properly because the indentation becomes part of the string itself. Some languages have magical "removed the indent" modes for strings (e.g. YAML) but they generally suck and just add confusion. This syntax is quite clear (at least with respect to i…
I may be missing something but come Go has a simple: `A simple formatted string ` ?
fn main() {
if something {
print(`A
simple
formatted
string`)
}
}
which looks ugly and confusing.Re: Zig's Lovely Syntax
#178> Raw or multiline strings are spelled like this: const still_raw = \\const raw = \\ \\Roses are red \\ \\ Violets are blue, \\ \\Sugar is sweet \\ \\ And so are you. \\ \\ \\; \\ ; This syntax seems fairly insane to me.
When I first read it I thought it was line comments.
People are having trouble distinguishing between '//' and '\\'.
Re: Zig's Lovely Syntax
#179Earlier quoted context omitted.
I may be missing something but come Go has a simple: `A simple formatted string ` ?
Yours is rendered as: A\n\tsimple\n\t\tformatted\n\t\t\tstring\n\t If you wanted it without the additional indentation, you’d need to use a function to strip that out. Typescript has dedent which goes in front of the template string, for example. I guess in Zig that’s not necessary which is nice.
Re: Zig's Lovely Syntax
#180Earlier quoted context omitted.
> it's even worse that they landed on // for the syntax .. it is using \\
I worked with browsers since before most people knew what a browser was and it will never cease to amaze me how often people confuse slash and backslash, / and \ It’s some sort of mental glitch that a number of people fall into and I have absolutely no idea why.