Live data from Hacker News

Learning C3

alloc.dev

131–140 of 163 posts

Re: Learning C3

#131

Earlier quoted context omitted.

the hacker news markdown parser seems to have swallowed your asterisks, which are essential to understanding your comment.

Yeah, if you want to use asterisks without italicizing your text, you need to escape them with backslashes, and then you can write things like 5 * 2 * 1 = 10. That is, you'd write it like this: 5 \* 2 \* 1 = 10

Is there a place this is all written down? It's not in the FAQ...

Re: Learning C3

#132
post #73

Earlier quoted context omitted.

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 -> LLVM -> binary". And LLVM is known for being a fairly slow compiler.

The downside of QBE is that it doesn't have a way to generate debug symbols. But I still love and use it.

The most recent release has the ability to generate basic debugging information (see "new experimental dbgfile and dbgloc directives. " from the release notes) as Hare needed that (and IIRC a Hare contributor added it). Unfortunately, there's no documentation on it, and last I checked to see how to use it I had to go spelunking in the Hare source code.

Re: Learning C3

#133
I love this.

But this was distracting:

> Macros are a bag of worms. Sure, they can be a great source of protein, but will you really see me eating them? I might use worms when I'm fishing, but I don't see much use for them around the home. To express my opinion outside of a metaphor: macros have niche use cases, are good at what they do, but shouldn't be abused. One example of this abuse would be making a turing-complete domain-specific language inside of some macro-supporting programming language.

Re: Learning C3

#134
post #32

Earlier quoted context omitted.

> Approaches to avoid constructors/destructors such as ZII play very poorly with ref values as well. What you end up with is some period of time where a value is quasi valid - since non-null types need to be assigned and it's in a broken state before it's initially assigned. I don't see that as a problem; don't separate declaration from assignment and it will never be unassigned. Then a ZII non-null pointer is always…

> don't separate declaration from assignment and it will never be unassigned That's tricky when you want to write algorithms where you can start with an uninitialized object and are guaranteed to have initialized the object by the time the algorithm completes. (Simplest example - create an array B which contains the elements of array A in reverse order.) You can either allow declaring B uninitialized (which can be a…

I don't think that's much of an issue. If you need deferred initialization then stick to a pointer and then once the pointer is initialized shadow it with a reference.

    int* pre_foo = null;
    ... initialize pre_foo ...
    int& foo = *pre_foo;

Re: Learning C3

#135
post #125
post #108

Earlier quoted context omitted.

The new allocators, some corner cases of the destroy and destructors, not everything on Phobos is @nogc friendly, BetterC still chockes on many common C extensions, DIP 1000, the whole set of @live semantics. Now there is a new GC being redesigned, and there are discussions about a possible Phobos V3.

You mean ImportC and not BetterC, right?

Right, got that one wrong.

Although, on the context of BetterC, there is the debate about having more regular features available in that mode as well.

Re: Learning C3

#136
post #108

Earlier quoted context omitted.

>while not finishing the previous attempts I agree, and that applies to many software projects, and not just programming languages only. >so there are quite a few half baked features by now what are some of those half baked features?

The new allocators, some corner cases of the destroy and destructors, not everything on Phobos is @nogc friendly, BetterC still chockes on many common C extensions, DIP 1000, the whole set of @live semantics. Now there is a new GC being redesigned, and there are discussions about a possible Phobos V3.

> still chockes on many common C extensions

I play with ImportC occasionally, a lot of those can actually be opt out by undef'ing __GNUC__ on the preprocessor invocation, idk why they don't do that. Oh, now it chokes on C23 features as well because system cpp defines __STDC_VERSION__=202311L now. Edit: that was solved: dlang/dmd/pull/21372

Re: Learning C3

#137

Earlier quoted context omitted.

Yeah, if you want to use asterisks without italicizing your text, you need to escape them with backslashes, and then you can write things like 5 * 2 * 1 = 10. That is, you'd write it like this: 5 \* 2 \* 1 = 10

Is there a place this is all written down? It's not in the FAQ...

https://news.ycombinator.com/formatdoc

Re: Learning C3

#138
I wish there was a way to transpile this to C. That way it can be both an escape hatch, and a way to target unusual platforms not directly supported by C3 lang.
Post reply on HN