Re: import strangeness with std.stdio.write

2018-02-13 Thread Seb via Digitalmars-d-learn
On Tuesday, 13 February 2018 at 16:55:10 UTC, ixid wrote: On Tuesday, 13 February 2018 at 13:52:37 UTC, rikki cattermole wrote: write exists in both, writeln exists only in std.stdio. Use named imports to pick which write you want. It does seem a little silly to have a name clash with such a

Re: import strangeness with std.stdio.write

2018-02-13 Thread ixid via Digitalmars-d-learn
On Tuesday, 13 February 2018 at 13:52:37 UTC, rikki cattermole wrote: write exists in both, writeln exists only in std.stdio. Use named imports to pick which write you want. It does seem a little silly to have a name clash with such a commonly used function. Would it not be better to rename

Re: import strangeness with std.stdio.write

2018-02-13 Thread psychoticRabbit via Digitalmars-d-learn
On Tuesday, 13 February 2018 at 14:21:31 UTC, bauss wrote: What you can do is use aliases to use both functions. import io = std.stdio; void main() { import file = std.file; file.write("hello"); io.writeln("hello again"); } that's a nice simple solution. thanks.

Re: import strangeness with std.stdio.write

2018-02-13 Thread bauss via Digitalmars-d-learn
On Tuesday, 13 February 2018 at 13:56:17 UTC, psychoticRabbit wrote: On Tuesday, 13 February 2018 at 13:52:37 UTC, rikki cattermole wrote: On 13/02/2018 1:46 PM, psychoticRabbit wrote: So, strange problem below. The commented-out line will not compile (if I un-comment it), unless I either

Re: import strangeness with std.stdio.write

2018-02-13 Thread psychoticRabbit via Digitalmars-d-learn
On Tuesday, 13 February 2018 at 14:18:05 UTC, ketmar wrote: psychoticRabbit wrote: Also, if I do this below, how does the compiler choose the correct write function? import std.stdio; import std.file; void main() { write("hello"); writeln("hello again"); } it's easy: just take a

Re: import strangeness with std.stdio.write

2018-02-13 Thread ketmar via Digitalmars-d-learn
psychoticRabbit wrote: Also, if I do this below, how does the compiler choose the correct write function? import std.stdio; import std.file; void main() { write("hello"); writeln("hello again"); } it's easy: just take a look at `std.file.write()`. first, it require two

Re: import strangeness with std.stdio.write

2018-02-13 Thread psychoticRabbit via Digitalmars-d-learn
On Tuesday, 13 February 2018 at 13:57:38 UTC, ketmar wrote: `std.file` has function named `write()` too. and local import completely shadows global imports (i.e. it removes global imports from overload set for the given scope), hence `std.stdio.write()` is not available there. "..local

Re: import strangeness with std.stdio.write

2018-02-13 Thread psychoticRabbit via Digitalmars-d-learn
On Tuesday, 13 February 2018 at 13:52:37 UTC, rikki cattermole wrote: On 13/02/2018 1:46 PM, psychoticRabbit wrote: So, strange problem below. The commented-out line will not compile (if I un-comment it), unless I either move std.stdio into main, or, move std.file out of main. Whereas

Re: import strangeness with std.stdio.write

2018-02-13 Thread ketmar via Digitalmars-d-learn
psychoticRabbit wrote: So, strange problem below. The commented-out line will not compile (if I un-comment it), unless I either move std.stdio into main, or, move std.file out of main. Whereas writeln works just fine as is. - module test; import std.stdio; void main()

Re: import strangeness with std.stdio.write

2018-02-13 Thread rikki cattermole via Digitalmars-d-learn
On 13/02/2018 1:46 PM, psychoticRabbit wrote: So, strange problem below. The commented-out line will not compile (if I un-comment it), unless I either move std.stdio into main, or, move std.file out of main. Whereas writeln works just fine as is. - module test; import

Re: import strangeness with std.stdio.write

2018-02-13 Thread psychoticRabbit via Digitalmars-d-learn
On Tuesday, 13 February 2018 at 13:46:11 UTC, psychoticRabbit wrote: So, strange problem below. The commented-out line will not compile (if I un-comment it), unless I either move std.stdio into main, or, move std.file out of main. Whereas writeln works just fine as is.

import strangeness with std.stdio.write

2018-02-13 Thread psychoticRabbit via Digitalmars-d-learn
So, strange problem below. The commented-out line will not compile (if I un-comment it), unless I either move std.stdio into main, or, move std.file out of main. Whereas writeln works just fine as is. - module test; import std.stdio; void main() { import std.file;