Re: Symbol lookup rules and imports

2014-12-08 Thread Walter Bright via Digitalmars-d
On 12/2/2014 2:00 PM, H. S. Teoh via Digitalmars-d wrote: 4) This isn't the end of the story. There's also this lovely bug: https://issues.dlang.org/show_bug.cgi?id=1238 which, as its number should tell you, has been around for a LONG time. Executive summary: // mymod.d

Re: Symbol lookup rules and imports

2014-12-08 Thread Walter Bright via Digitalmars-d
On 12/2/2014 2:00 PM, H. S. Teoh via Digitalmars-d wrote: However, there are major issues with scoped imports currently, that make this otherwise ideal solution less-than-ideal, which stem from the way 'import' is implemented in D. When the compiler encounters an 'import' statement, what it

Re: Symbol lookup rules and imports

2014-12-08 Thread H. S. Teoh via Digitalmars-d
On Mon, Dec 08, 2014 at 12:34:07AM -0800, Walter Bright via Digitalmars-d wrote: On 12/2/2014 2:00 PM, H. S. Teoh via Digitalmars-d wrote: However, there are major issues with scoped imports currently, that make this otherwise ideal solution less-than-ideal, which stem from the way 'import' is

Re: Symbol lookup rules and imports

2014-12-08 Thread Walter Bright via Digitalmars-d
On 12/8/2014 7:52 AM, H. S. Teoh via Digitalmars-d wrote: I realize that my understanding on the workings of dmd may not be quite accurate, and I apologize for any inadvertent misrepresentations, but the fact remains that the current behaviour of import is very counterintuitive, and users will

Re: Symbol lookup rules and imports

2014-12-08 Thread ketmar via Digitalmars-d
On Mon, 08 Dec 2014 14:30:08 -0800 Walter Bright via Digitalmars-d digitalmars-d@puremagic.com wrote: The two-step lookup method, of current scope then imports in current scope, is misunderstood by nearly everyone. this is the clear sign of the existing problem. signature.asc Description:

Re: Symbol lookup rules and imports

2014-12-08 Thread Walter Bright via Digitalmars-d
On 12/8/2014 7:34 PM, ketmar via Digitalmars-d wrote: On Mon, 08 Dec 2014 14:30:08 -0800 Walter Bright via Digitalmars-d digitalmars-d@puremagic.com wrote: The two-step lookup method, of current scope then imports in current scope, is misunderstood by nearly everyone. this is the clear sign

Re: Symbol lookup rules and imports

2014-12-08 Thread ketmar via Digitalmars-d
On Mon, 08 Dec 2014 19:40:38 -0800 Walter Bright via Digitalmars-d digitalmars-d@puremagic.com wrote: On 12/8/2014 7:34 PM, ketmar via Digitalmars-d wrote: On Mon, 08 Dec 2014 14:30:08 -0800 Walter Bright via Digitalmars-d digitalmars-d@puremagic.com wrote: The two-step lookup method, of

Re: Symbol lookup rules and imports

2014-12-07 Thread Andrei Alexandrescu via Digitalmars-d
On 12/3/14 8:00 AM, H. S. Teoh via Digitalmars-d wrote: I'm finding it harder and harder to accept Walter's stance that symbol lookups should be kept simple and free from complications and convoluted corner cases, etc.. Except that it is*already* full of convoluted pitfalls and corner cases you

Re: Symbol lookup rules and imports

2014-12-05 Thread Bruno Medeiros via Digitalmars-d
On 02/12/2014 22:00, H. S. Teoh via Digitalmars-d wrote: Recently, in a bid to reduce the messy tangle that is the web of interdependencies among Phobos modules, many module-scope imports have been replaced with scoped imports. In addition to reducing gratuitous dependencies (the scoped import

Re: Symbol lookup rules and imports

2014-12-04 Thread Dicebot via Digitalmars-d
On Tuesday, 2 December 2014 at 22:02:23 UTC, H. S. Teoh via Digitalmars-d wrote: However, there are major issues with scoped imports currently, that make this otherwise ideal solution less-than-ideal, which stem from the way 'import' is implemented in D. When the compiler encounters an

Re: Symbol lookup rules and imports

2014-12-04 Thread Dicebot via Digitalmars-d
On Wednesday, 3 December 2014 at 13:34:42 UTC, Jacob Carlborg wrote: On 2014-12-02 23:00, H. S. Teoh via Digitalmars-d wrote: I'm finding it harder and harder to accept Walter's stance that symbol lookups should be kept simple and free from complications and convoluted corner cases, etc..

Re: Symbol lookup rules and imports

2014-12-04 Thread H. S. Teoh via Digitalmars-d
On Wed, Dec 03, 2014 at 02:10:52AM +0200, ketmar via Digitalmars-d wrote: On Tue, 2 Dec 2014 15:55:34 -0800 H. S. Teoh via Digitalmars-d digitalmars-d@puremagic.com wrote: Hmm... actually, this gives me an idea. What if we implement a little syntactic sugar for this in the compiler? Say:

Re: Symbol lookup rules and imports

2014-12-04 Thread Rainer Schuetze via Digitalmars-d
On 02.12.2014 23:00, H. S. Teoh via Digitalmars-d wrote: 4) This isn't the end of the story. There's also this lovely bug: https://issues.dlang.org/show_bug.cgi?id=1238 which, as its number should tell you, has been around for a LONG time. Executive summary: // mymod.d

Re: Symbol lookup rules and imports

2014-12-04 Thread H. S. Teoh via Digitalmars-d
On Fri, Dec 05, 2014 at 12:25:49AM +0100, Rainer Schuetze via Digitalmars-d wrote: On 02.12.2014 23:00, H. S. Teoh via Digitalmars-d wrote: 4) This isn't the end of the story. There's also this lovely bug: https://issues.dlang.org/show_bug.cgi?id=1238 which, as its number should

Re: Symbol lookup rules and imports

2014-12-04 Thread ketmar via Digitalmars-d
On Thu, 4 Dec 2014 14:15:22 -0800 H. S. Teoh via Digitalmars-d digitalmars-d@puremagic.com wrote: On Wed, Dec 03, 2014 at 02:10:52AM +0200, ketmar via Digitalmars-d wrote: On Tue, 2 Dec 2014 15:55:34 -0800 H. S. Teoh via Digitalmars-d digitalmars-d@puremagic.com wrote: Hmm... actually,

Re: Symbol lookup rules and imports

2014-12-04 Thread ketmar via Digitalmars-d
On Thu, 4 Dec 2014 14:15:22 -0800 H. S. Teoh via Digitalmars-d digitalmars-d@puremagic.com wrote: On Wed, Dec 03, 2014 at 02:10:52AM +0200, ketmar via Digitalmars-d wrote: On Tue, 2 Dec 2014 15:55:34 -0800 H. S. Teoh via Digitalmars-d digitalmars-d@puremagic.com wrote: Hmm... actually,

Re: Symbol lookup rules and imports

2014-12-04 Thread Meta via Digitalmars-d
module base; class Base { import std.conv; } module derived; import base; import std.stdio; string text = 123; class Derived : Base { static void foo() { writeln(text); } } void main() { Derived.foo(); } This prints an empty line! My

Re: Symbol lookup rules and imports

2014-12-04 Thread Mike Parker via Digitalmars-d
On 12/5/2014 10:04 AM, ketmar via Digitalmars-d wrote: On Thu, 4 Dec 2014 14:15:22 -0800 H. S. Teoh via Digitalmars-d digitalmars-d@puremagic.com wrote: OTOH, Kenji has a different solution already in PR form: https://github.com/D-Programming-Language/dmd/pull/3407 Static, renamed,

Re: Symbol lookup rules and imports

2014-12-03 Thread Paolo Invernizzi via Digitalmars-d
On Tuesday, 2 December 2014 at 22:02:23 UTC, H. S. Teoh via Digitalmars-d wrote: I wish we would just acknowledge that the current symbol lookup / import rules (or at least the implementation thereof) are inadequate, and find a clean solution to this long-standing issue, instead of hoping

Re: Symbol lookup rules and imports

2014-12-03 Thread via Digitalmars-d
On Tuesday, 2 December 2014 at 22:02:23 UTC, H. S. Teoh via Digitalmars-d wrote: 2) OK, so the conclusion is that unqualified scoped imports are dangerous, right? Alright, let's see what happens when we use qualified imports: // mod.d module mod; struct S {

Re: Symbol lookup rules and imports

2014-12-03 Thread Jacob Carlborg via Digitalmars-d
On 2014-12-02 23:00, H. S. Teoh via Digitalmars-d wrote: I'm finding it harder and harder to accept Walter's stance that symbol lookups should be kept simple and free from complications and convoluted corner cases, etc.. Except that it is *already* full of convoluted pitfalls and corner cases

Re: Symbol lookup rules and imports

2014-12-03 Thread Martin Nowak via Digitalmars-d
On 12/03/2014 12:55 AM, H. S. Teoh via Digitalmars-d wrote: struct S { static import std.format; alias format = std.format.format; // ^^^ the above line is what makes s.format() break. } It's equivalent to private alias

Symbol lookup rules and imports

2014-12-02 Thread H. S. Teoh via Digitalmars-d
Recently, in a bid to reduce the messy tangle that is the web of interdependencies among Phobos modules, many module-scope imports have been replaced with scoped imports. In addition to reducing gratuitous dependencies (the scoped import is not processed in a template body until the template is

Re: Symbol lookup rules and imports

2014-12-02 Thread Meta via Digitalmars-d
This whole thing is a huge hole in D that needs to be fixed (it may even be necessary to consider it higher priority than the current C++ and GC). As it works currently, I'd go as far as to say that almost every addition to Phobos must be considered a breaking change for these reasons. Given

Re: Symbol lookup rules and imports

2014-12-02 Thread ketmar via Digitalmars-d
On Tue, 2 Dec 2014 14:00:09 -0800 H. S. Teoh via Digitalmars-d digitalmars-d@puremagic.com wrote: // mymod.d module mymod; struct S { // Now everyone is happy, right...? import std.range : isInputRange; void method(R)(R range)

Re: Symbol lookup rules and imports

2014-12-02 Thread H. S. Teoh via Digitalmars-d
On Wed, Dec 03, 2014 at 01:20:59AM +0200, ketmar via Digitalmars-d wrote: On Tue, 2 Dec 2014 14:00:09 -0800 H. S. Teoh via Digitalmars-d digitalmars-d@puremagic.com wrote: // mymod.d module mymod; struct S { // Now everyone is happy, right...?

Re: Symbol lookup rules and imports

2014-12-02 Thread H. S. Teoh via Digitalmars-d
On Tue, Dec 02, 2014 at 11:02:18PM +, Meta via Digitalmars-d wrote: This whole thing is a huge hole in D that needs to be fixed (it may even be necessary to consider it higher priority than the current C++ and GC). Well, that's up to Walter Andrei to decide. :-P As it works currently,

Re: Symbol lookup rules and imports

2014-12-02 Thread Martin Nowak via Digitalmars-d
http://wiki.dlang.org/DIP22

Re: Symbol lookup rules and imports

2014-12-02 Thread ketmar via Digitalmars-d
On Tue, 2 Dec 2014 15:55:34 -0800 H. S. Teoh via Digitalmars-d digitalmars-d@puremagic.com wrote: Hmm... actually, this gives me an idea. What if we implement a little syntactic sugar for this in the compiler? Say: scope import std.conv ... ; scope import std.format ... ;

Re: Symbol lookup rules and imports

2014-12-02 Thread Steven Schveighoffer via Digitalmars-d
On 12/2/14 6:28 PM, H. S. Teoh via Digitalmars-d wrote: Technically, you *can* do that, but it's a lot more verbose (plus, ddoc doesn't know how to generate docs for eponymous templates properly and it looks ugly): template method(R) { import std.range :

Re: Symbol lookup rules and imports

2014-12-02 Thread H. S. Teoh via Digitalmars-d
On Tue, Dec 02, 2014 at 08:11:52PM -0500, Steven Schveighoffer via Digitalmars-d wrote: On 12/2/14 6:28 PM, H. S. Teoh via Digitalmars-d wrote: Technically, you *can* do that, but it's a lot more verbose (plus, ddoc doesn't know how to generate docs for eponymous templates properly and it

Re: Symbol lookup rules and imports

2014-12-02 Thread ketmar via Digitalmars-d
On Tue, 2 Dec 2014 17:33:09 -0800 H. S. Teoh via Digitalmars-d digitalmars-d@puremagic.com wrote: On Tue, Dec 02, 2014 at 08:11:52PM -0500, Steven Schveighoffer via Digitalmars-d wrote: On 12/2/14 6:28 PM, H. S. Teoh via Digitalmars-d wrote: Technically, you *can* do that, but it's a