C is Brittle D is Plastic

Timon Gehr timon.gehr at gmx.ch
Tue Mar 24 19:50:26 UTC 2026


On 3/24/26 15:36, H. S. Teoh wrote:
> However, that led to counterintuitive behaviours like:
> 
> 	void main() {
> 		myFunc("abc");
> 	}
> 	void myFunc(string text) {
> 		writeln(text);	// prints "abc"
> 		import std.conv;
> 		writeln(text);	// prints ""
> 	}
> 
> Walter was very resistant to changing this behaviour, as all proposed
> solutions involved "inelegant" complications in the semantics and
> implementation of "import".  Eventually, however, the crowd prevailed
> and Walter relented.

Not really, the problem is not fixed:

```d
import std.stdio;

string readAndLog(string filename){
     import std.file;
     auto text=readText(filename);
     write(filename," read successfully!\n");
     return text;
}

void main(){
     writeln(readAndLog("important_data.txt"));
}
```

https://github.com/dlang/dmd/issues/19272

So what we have now is a compromise: It's both broken and not entirely 
straightforward.


More information about the Digitalmars-d mailing list