3 ms·
I consider forward references an anti-feature. I want any language I use to have the following property: if I append to the source file, I can't break previousl
by norir 2y ago
I consider forward references an anti-feature. I want any language I use to have the following property: if I append to the source file, I can't break previously correct code above the insertion point. Forward references both break this property _and_ requires multiple compiler passes.
More generally though, it's time to stick a fork in c. To me the only sane ways to use c are as a compilation target or for quick and dirty prototypes.
We can't make c better by adding to it. We need to let it die peacefully so its grandchildren may live.
- the-grump 2y agoC will always live. I’m not onboard with significant changes to C but the language will always be around at the interface between hardware and software and probably as the lingua franca for FFI.
- me-vs-cat 2y agoWhat do you mean by "break previously correct code"? Can you give an example of what you're thinking with original code and appended code, where concatenating the two (1) does not change the behavior of the original code when forward references are not allowed, and (2) changes the behavior of the original code when forward references are allowed?
- norir 2y agoin d: import std.stdio; alias string = immutable(char)[] void main() { bar(foo()); } void bar(string s) { writeln(s); } string foo() { return "foo"; } now change the definition of foo: import std.stdio; alias string = immutable(char)[]; void main() { bar(foo()); } void bar(string s) { writeln(s); } int foo() { return 1; } This now fails to compile at line 3 even though the breaking change was made at line 5.
- me-vs-cat 2y agoI am unable to fit that example in this prior description: "if I append to the source file, I can't break previously correct code above the insertion point". Can you help me by providing the "previously correct code" and the "appended code" which causes the break after being appended?
- me-vs-cat 2y agoI am unable to fit that example in this prior description: "if I append to the source file, I can't break previously correct code above the insertion point". Your foo() example above has code which has been changed, rather than "if I append to the source file". (I re-read my prior comment and realized this may not have been clear.) That a change to code can introduce a bug is something we've all seen. But your prior description is not any kind of change, it was specifically an append. In the context of forward references, I am curious to see something that matched your prior description.