On Monday, 8 September 2014 at 05:04:21 UTC, Jakob Ovrum wrote:
Function pointers can be converted to delegates through a
simple wrapper function (which is how std.functional.toDelegate
achieves it), but delegates cannot be wrapped by a function
pointer without introducing additional
On Monday, 8 September 2014 at 06:23:40 UTC, deadalnix wrote:
On Monday, 8 September 2014 at 05:04:21 UTC, Jakob Ovrum wrote:
Function pointers can be converted to delegates through a
simple wrapper function (which is how
std.functional.toDelegate achieves it), but delegates cannot
be wrapped
I'm trying to use a bit of function programming.
In a function like this:
int f(in int[] arr, bool delegate(int) func);
call using:
bool g(int n) { ... }
f(arr, g);
instead of:
f(arr, x = x == 0);
it is possible?
On Sunday, 7 September 2014 at 20:47:47 UTC, AsmMan wrote:
I'm trying to use a bit of function programming.
In a function like this:
int f(in int[] arr, bool delegate(int) func);
call using:
bool g(int n) { ... }
f(arr, g);
instead of:
f(arr, x = x == 0);
it is possible?
bool g(int n) {
On Sunday, 7 September 2014 at 21:02:16 UTC, John Colvin wrote:
bool g(int n) { ... }
f(arr, g);
This will fail if `g` is a function pointer, such as when `g` is
declared at module-level scope. In that case, it has to be
explicitly converted to a delegate:
---
import std.functional :
On Sunday, 7 September 2014 at 21:02:16 UTC, John Colvin wrote:
On Sunday, 7 September 2014 at 20:47:47 UTC, AsmMan wrote:
I'm trying to use a bit of function programming.
In a function like this:
int f(in int[] arr, bool delegate(int) func);
call using:
bool g(int n) { ... }
f(arr, g);
On Sunday, 7 September 2014 at 21:23:26 UTC, Jakob Ovrum wrote:
On Sunday, 7 September 2014 at 21:02:16 UTC, John Colvin wrote:
bool g(int n) { ... }
f(arr, g);
This will fail if `g` is a function pointer, such as when `g`
is declared at module-level scope. In that case, it has to be
On Sunday, 7 September 2014 at 21:31:11 UTC, AsmMan wrote:
Thank you too. Btw, why the operator in this syntax? I used
to think ref keyword sort of C's T** and operator is
neeeded.. or is it because f can be a function called without
pass any parameter?
In D, the address-of operator has to
On Sunday, 7 September 2014 at 21:42:31 UTC, Jakob Ovrum wrote:
void bar(void function() a) {}
s/void function() a/int function() a/
On Sunday, 7 September 2014 at 21:42:31 UTC, Jakob Ovrum wrote:
On Sunday, 7 September 2014 at 21:31:11 UTC, AsmMan wrote:
Thank you too. Btw, why the operator in this syntax? I used
to think ref keyword sort of C's T** and operator is
neeeded.. or is it because f can be a function called
On Sunday, 7 September 2014 at 21:42:31 UTC, Jakob Ovrum wrote:
On Sunday, 7 September 2014 at 21:31:11 UTC, AsmMan wrote:
Thank you too. Btw, why the operator in this syntax? I used
to think ref keyword sort of C's T** and operator is
neeeded.. or is it because f can be a function called
On Sunday, 7 September 2014 at 20:47:47 UTC, AsmMan wrote:
I'm trying to use a bit of function programming.
In a function like this:
int f(in int[] arr, bool delegate(int) func);
call using:
bool g(int n) { ... }
f(arr, g);
instead of:
f(arr, x = x == 0);
it is possible?
In D there is a
On Monday, 8 September 2014 at 03:37:45 UTC, deadalnix wrote:
In fact the distinction is done by C and C++ only.
And by D.
On Monday, 8 September 2014 at 03:01:40 UTC, AsmMan wrote:
I got it. Why it doesn't works if foo is a method?
Taking the address of a method/member function yields a delegate,
not a function pointer. Delegates are fat pointers; they contain
a pointer to the function as well as a pointer to
14 matches
Mail list logo