5 ms·
Well, it certainly looks ambitious. But... It's not very pretty? Looks a bit like an unholy union of TeX and C? https://github.com/zig-lang/zig/blob/master/exa
by e12e 9y ago
Well, it certainly looks ambitious. But... It's not very pretty? Looks a bit like an unholy union of TeX and C?
https://github.com/zig-lang/zig/blob/master/example/cat/main.zig https://github.com/zig-lang/zig/blob/master/example/cat/main...
- AndyKelley 9y agoHandling every possible error in a clear way isn't pretty, but somebody's gotta do it.
- e12e 9y agoBut do you have to use so many percentage signs to handle all the errors? :)
- AndyKelley 9y agoThis is the ugliest thing about zig. Can you come up with a better proposal to capture the semantics? I'd love to see it. I've tried and this is the best I can do.
- hawski 9y agoA keyword maybe? For unary case: // original: %%io.stdout.printf("Hello, world!\n"); // my favorite ideas: try io.stdout.printf("Hello, world!\n"); dare io.stdout.printf("Hello, world!\n"); // others: err io.stdout.printf("Hello, world!\n"); ex io.stdout.printf("Hello, world!\n"); bet io.stdout.printf("Hello, world!\n"); bid io.stdout.printf("Hello, world!\n"); For the binary operator: // my favorite ideas: a yet b a odd b a but b a ex b // extra or except a err b a bail b // others: a else b // Would overloading the meaning have sense? a esc b // escape a alt b // alternate a aux b // auxiliary a sub b // substitute a prox b // proxy a then b a eor b // error or a repl b // replacement a supp b // supplemental a %or b
- oblio 9y agoAgreed. A short keyword is generally better than a symbol. Yes, you do get used to symbols, but words come naturally. "a and b" is easy to read, easy to explain and read by newbies and overall much, much nicer in my opinion than the 1-letter-shorter "a && b". Keywords can also benefit from the fact that 99% of programmers know at least the basic English words, while special characters are not necessarily international. They might not be used, they might not have the same meaning. I'm speaking more about "&" here, but it applies to other characters as well.
- AndyKelley 9y agoThese are good ideas. we also need alternatives for these : %defer %return
- hawski 9y agoSome may fit previous propositions. For %defer: error defer deallocateFoo(foo); but defer deallocateFoo(foo); ex defer deallocateFoo(foo); failsafe deallocateFoo(foo); bail defer deallocateFoo(foo); For %return: fn doAThing(str: []u8) -> %void { const number = try parseU64(str, 10); // ... } "try" could mean "return an error in case of an error" aka "%return". Then "dare" could mean "panic in case of an error" aka "%%foo();". Or use "ex" or "but" everywhere: ex foo(); const num = foo() ex 42; const num = ex foo(); ex defer bar(baz); but foo(); const num = foo() but 42; const num = but foo(); but defer bar(baz);
- ant6n 9y agoEx sounds a lot like example, rather than exception. I really like the use of keywords, leveraging our extensive understanding and intuition of language to make a language more clear and intuitive. Symbolic operators work well if they are borrowed from math (e.g. third grade), making up new ones often results in a painful learning phase.
- iainmerrick 9y agoHow about "catch"? Zig doesn't have the usual try/catch blocks but the meaning is similar. catch defer dealloc(foo);
- explainplease 9y ago"must" might be a good alternative for "%%", as in, "this call must return without an error." or "this call must work." For "%return", perhaps "should" or "handle", as in, "This function should return without an error, but if it does, handle it."
- iainmerrick 9y agoI specifically like the similarity between ?? and %% -- they do do similar things! -- so please keep that in some way if you can.
- CyberDildonics 9y agoAre you asking a question or making a statement?