On Thursday, 3 October 2013 at 02:57:50 UTC, Andrej Mitrovic wrote:
On 10/3/13, Craig Dillabaugh <[email protected]> wrote:void main( string[] args ) { string str = "Hello"; write( "file.txt", str );string hello_file = readText("file.txt"); writeln( hello_file ); }You can also disambiguate by preferring one symbol over another with an alias:alias write = std.file.write; void main( string[] args ) { string str = "Hello"; write( "file.txt", str ); } You can also put the alias inside the function.
Thanks. It seems that std.file should include a writeText() function for the sake of consistency that is the above alias. When you come across readText() in the documentation you sort of expect that such a function would exist, and then you spot write() below it, and think hey that does what I need. Then you hit upon the syntax error if you are also using std.stdio (which is a very commonly used module). Adding writeText() doesn't really add much to the library, but having to jump through hoops (as minor as they may be) to perform such a simple op is a bit of a pain for people new to the language. Craig
