D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 13771 - any language support capture acquire type?
Summary: any language support capture acquire type?
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-11-24 15:17 UTC by galaxylang
Modified: 2022-12-16 14:23 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description galaxylang 2014-11-24 15:17:05 UTC
auto add(T)(T a,T b)
{
    return to!RetureType(a+b);
}

void fun(T)(T x)
{

}
fun!double(add(1,2));
fun!int(add(1,2));

just add a implicit RetureType,not need visible,background syntax tree like this

auto add(RetureType,T)(T a,T b)

but we can see ,the type reduce logical changed from down-up to up-down
template SelectFrom(T)
{
 alias SelectFrom=T;
}
auto add(T=SelectFrom!(ReturnType))(T a,T b)

these will change the language' template more magic when mix use with opCast,opDispacth...act
Comment 1 RazvanN 2022-12-16 14:23:27 UTC
No, D does not support such features because the return type is always deduced from the function body, not from the surrounding context (there are some exceptions with regards to lambda functions). This is a major change that does really bring too much benefit.