D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6392 - function pointers should be convertible to delegates
Summary: function pointers should be convertible to delegates
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86_64 Windows
: P2 enhancement
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-28 07:43 UTC by Gor Gyolchanyan
Modified: 2011-07-28 07:53 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 Gor Gyolchanyan 2011-07-28 07:43:45 UTC
if a delegate is a fat pointer, containing the context pointer and the function pointer, why isn't it legal to have a context pointer of null, allowing any function to be viewed as a delegate? It will save lots of effort, making duplicates of code for function pointers and delegates. To resolve the problem of the hidden context parameter of the delegate function, for example, a simple test for null may be used to determine whether the context pointer should be passed or not.
Comment 1 Steven Schveighoffer 2011-07-28 07:53:59 UTC
There is already a library solution:  http://www.d-programming-language.org/phobos/std_functional.html#toDelegate