Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
lerno
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
11 ms
·
121.
▲
by
lerno
1y ago
Hasn't this been done already? C with classes I mean. eC and others.
122.
▲
by
lerno
1y ago
It's very simple, the latter describes an `if-else` chain. No more complicated than that. Can you explain what your concern is?
123.
▲
by
lerno
1y ago
C3 has case ranges, like case 'a'..'z': It's from the GCC C extension (except GCC uses ...)
124.
▲
by
lerno
1y ago
It was the minimal change from C. It's fairly easy regex out the types, so while not as nice as Odin, it should be straightforward. Named parameters are already in the language. Regarding concurrency, I don't want to pick a single
125.
▲
by
lerno
1y ago
No, it's not a problem. If you think it's a problem, write a C compiler in C and come back to me and show me your code that doesn't have that. :)
126.
▲
by
lerno
1y ago
This could make sense for a from-scratch language, but C3 is trying to be an evolution of C, and such constraints would make it so much of a different language that it would be way out of scope. I think Rust and similar languages fill that
127.
▲
by
lerno
1y ago
I was talking about function overloading. Sorry for being unclear.
128.
▲
by
lerno
1y ago
I based the LLVM-IR output on what Clang outputs for C. And so they should be identical. C3 has a single module option for maximum interfunctional optimizations, but Clang can give you LTO for the same thing. So they should be the same, oth
129.
▲
by
lerno
1y ago
Yes, just a sponsorship. No other relationship with the project.
130.
▲
by
lerno
1y ago
You have both in C3: switch (x) { case 0: ... case 1 + 1: ... } This will behave in the normal way. But you can also have: switch { case foo() > 0: ... case bar
131.
▲
by
lerno
1y ago
"case X, Y" works for 3-4 values, but for something longer problems accumulate: case SOME_BAD_THING, SOME_OTHER_CONDITION, HERE_IS_NUMBER_THREE: foo(); int y = baz(); Placing them on the next row is fairly
132.
▲
by
lerno
1y ago
I can only speak for myself: 1. It is so big. 2. It still largely depends on GC (less important actually) It keeps adding features, but adding features isn't what makes a language worth using. In fact, that's one of the least attr
133.
▲
by
lerno
1y ago
C3 error handling is fairly novel though. It tries to find a sweet spot between composability, explicitness and C compatibility. The try-catch has nice composability: try { int x = foo_may_fail(); int y = bar_may_fail(
134.
▲
by
lerno
1y ago
It might be interesting to note that none of the C alternatives: C3, Zig, Odin, Hare, Jai use ownership nor RAII. Overloading is also generally missing from today's breed of C alternatives. There has certainly been many attempts at C a
135.
▲
by
lerno
1y ago
Yeah, you will need to pry `for` from my dead cold hands.
136.
▲
by
lerno
1y ago
All macros are hygienic. However, you can pass in a lazy expression which then is evaluated in its original context. The macro cannot insert variables into the caller scope, nor cause the function to return. Mostly it's similar to a st
137.
▲
by
lerno
1y ago
Rust is a C++ competitor with all the semantic complexity that comes with it. And similar compile times. C3 is more complex than C (because of a net increase of features), but it's miles from C++ and Rust in complexity and it compiles
138.
▲
by
lerno
1y ago
The downside of QBE is that it then requires an assembler and a linker. And QBE's only input and output is still text. Plus the "frontend -> QBE -> assembler -> binary" process is slower than "frontend -> LLV
139.
▲
by
lerno
1y ago
Every time
140.
▲
by
lerno
1y ago
Yes, C3 started as a variant of C2.
141.
▲
by
lerno
1y ago
Yes, and I was too slow to getting back and trying to edit it. Sorry about that.
142.
▲
by
lerno
1y ago
I don't quite see what you mean. As an example, let's say you use ZII and allocate 100 objects in a single allocation. These are now zero initialized and so either invalid (which should not happen) or do not hold non-null types. C
143.
▲
by
lerno
1y ago
I'm unable to edit this now... that should teach me not to comment and then go to kendo practice... It should say '*' and '&' and 'int&' and 'int*'
144.
▲
by
lerno
1y ago
It isn't possible. Use `for` instead. `foreach` isn't trying to be a one-stop-shop, but rather help the common case of looping over an array or list. Because it handles caching the length and such it's more efficient than a c
145.
▲
by
lerno
1y ago
Some other links links on C3 that might be interesting: Interviews: - https://www.youtube.com/watch?v=UC8VDRJqXfc - https://www.youtube.com/watch?v=9rS8MVZH-vA Here is a series doing various tasks in C3: -
146.
▲
by
lerno
1y ago
It uses operator overloading of [] &[] and "len" to create a straight for loop. Normal C for loops are there of course.
147.
▲
by
lerno
1y ago
It's an interesting problem. Originally I experimented with both having ` ` and `&` syntax, so `int&` being a ref (non null) and `int ` being a pointer. The thing you notice then are two things: 1. You want almost all pointer p
148.
▲
Learning C3
(alloc.dev)
261 points
by
lerno
1y ago
|
155 comments
149.
▲
by
lerno
1y ago
Amusingly enough, I found that the compiler also accepted MyEnum.len (completely undocumented!). That was an easter egg! But I'm trying to update the docs for types now. It's reasonable to just have all the compile time type prope
150.
▲
by
lerno
1y ago
I saw what you wrote about the enums, anything else? And feel free to add issues for things that feel off.
More ›