www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5411] New: import wtf1

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5411

           Summary: import wtf1
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: ellery-newcomer utulsa.edu



17:20:43 PST ---
quick! where does the following code fail?


import std.stdio, std.algorithm: writeln, indexOf;
void main(){
    writefln("abc");                               //1
    writeln(map!("a+1")([1,2,3]));                 //2
    std.stdio.writefln("abc");                     //3
    writeln(std.algorithm.map!("a+1")([1,2,3]));   //5
    writeln(indexOf("abc","b"));                   //6
}

answer: 
not 1, but it should
2, as it should
not 3, erm ?????
not 5, which may well be due to bug 314, or vice versa with 1
not 6, which maybe it shouldn't

summary: selective imports can select from multiple modules, but some of the
multiple modules get in to this module's symbol table anyways

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 04 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5411


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |INVALID



00:15:42 PST ---
The selective imports only apply to std.algorithm, not std.stdio.

std.algorithm publicly imports std.stdio, and so the selective import of
writeln from std.algorithm works.

The behavior is as expected.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 05 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5411


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |andrei metalanguage.com
         Resolution|INVALID                     |



00:18:55 PST ---
std.algorithm imports std.stdio privately.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 05 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5411




08:50:22 PST ---

 The selective imports only apply to std.algorithm, not std.stdio.
 
 std.algorithm publicly imports std.stdio, and so the selective import of
 writeln from std.algorithm works.
 
 The behavior is as expected.
then why is std.algorithm.map in the local module symbol table? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 05 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5411


Peter Alexander <peter.alexander.au gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |peter.alexander.au gmail.co
                   |                            |m



14:09:40 PST ---
Another test:

import std.stdio;
void main() {  
    writeln(std.algorithm.map!("a+1")([1,2,3])); // compiles
}

That succeeds (note lack of std.algorithm import)

import std.stdio;
void main() {  
    writeln(map!("a+1")([1,2,3])); // error: map not defined
}

That doesn't.

Where is map coming from? std.stdio doesn't use a public import for
std.algorithm.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 05 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5411


Jacob Carlborg <doob me.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |doob me.com



I think the last test compiles due to
http://d.puremagic.com/issues/show_bug.cgi?id=314

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 06 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5411




17:43:42 PST ---

 I think the last test compiles due to
 http://d.puremagic.com/issues/show_bug.cgi?id=314
yeah, looking back on this, I think all of them are instances of 314 and the rest is confusion about selective imports since the spec does not indicate how to interpret import mod1, mod2, ... modN: identifier; if it were up to me, I'd just disallow multiple module names in this case -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 06 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5411


dawg dawgfoto.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
                 CC|                            |dawg dawgfoto.de
         Resolution|                            |DUPLICATE



*** This issue has been marked as a duplicate of issue 313 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 16 2012