5 ms·
What 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
by me-vs-cat 2y ago
What 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.