www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2971] New: map no longer works with to

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

           Summary: map no longer works with to
           Product: D
           Version: 2.030
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: k-foley onu.edu


auto strings = ["1", "2", "3", "4", "5"][];

auto integers = to!(int[])(strings); // fine
auto integers1 = map!("to!(int)(a)")(strings); // fine
auto integers2 = map!(to!(int))(strings); // Error: template instance to!(int)
does not match any template declaration

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 13 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2971


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei metalanguage.com




--- Comment #1 from Andrei Alexandrescu <andrei metalanguage.com>  2009-05-13
08:43:30 PDT ---
This is related to the growing concern that I have that Walter is over-relying
on unittests to define D. Essentially right now a feature is defined by the
maze of related unittests that were defined for it.

I think this approach is good for verifying that the compiler does the right
thing, but is by no means a substitute of sound language and compiler design.
This has been long forgotten. Many of the recent bugs show how, as soon as you
step outside a narrow path defined by the testsuite, everything bursts in
flames. 

To wit, try these replacements. The error messages show how the compiler has no
idea what it's doing. It also gives the user no indication of what might be
going wrong.

/*A*/ auto integers2 = map!((a) {return to!int(a);})(strings);

/home/andrei/code/dmd/phobos/std/algorithm.d(120): Error: forward reference to
type __T2
/home/andrei/code/dmd/phobos/std/algorithm.d(120): Error: cannot implicitly
convert expression (null) of type immutable(char)[] to __T2
/home/andrei/code/dmd/phobos/std/algorithm.d(120): Error: forward reference to
inferred return type of function call __dgliteral1(cast(__T2)null)
./test.d(111): Error: template instance
test.main.Map!(__dgliteral1,immutable(char)[][]) error instantiating

/*B*/ auto integers2 = map!(function int(string a) {return
to!int(a);})(strings);

/home/andrei/code/dmd/phobos/std/algorithm.d(94): Error: template
std.algorithm.map(fun...) is not a function template
./test.d(9): Error: template std.algorithm.map(fun...) cannot deduce template
function from argument types !(int function(immutable(char)[] a)
{
return (immutable(char)[] value = value = a;
) , parseString(cast(const(char)[])value);
}
)(immutable(char)[][])
/home/andrei/code/dmd/phobos/std/algorithm.d(9): Error: template instance
std.algorithm.map!(int function(immutable(char)[] a)
{
return (immutable(char)[] value = value = a;
) , parseString(cast(const(char)[])value);
}
) errors instantiating template

We need to change the way the language design is (not) approached, pronto.


Andrei

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 13 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2971


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|nobody puremagic.com        |andrei metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 11 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2971


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


--- Comment #2 from Andrei Alexandrescu <andrei metalanguage.com> 2010-07-11
18:29:07 PDT ---
Changeset 1747.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 11 2010