On 10/13/13 16:43, Benjamin Thaut wrote:
> Am 10.10.2013 17:45, schrieb Namespace:
>> On Thursday, 10 October 2013 at 15:15:45 UTC, bearophile wrote:
>>> Namespace:
>>>
You mean like this?
void foo(T)(extern(C) void function(T*) func) {
}
That print
Am 10.10.2013 17:45, schrieb Namespace:
On Thursday, 10 October 2013 at 15:15:45 UTC, bearophile wrote:
Namespace:
You mean like this?
void foo(T)(extern(C) void function(T*) func) {
}
That prints: Error: basic type expected, not extern
In theory that's correct, in practice the c
On Friday, 11 October 2013 at 15:55:17 UTC, Artur Skawina wrote:
It's probably not just "incompetence" (the compiler is able to
figure this
out in other contexts), but a deliberate choice. Having
function types
depend on their bodies would not be a good idea. Eg
int c;
auto f() {
On 10/10/13 20:54, Dicebot wrote:
> On Thursday, 10 October 2013 at 17:47:54 UTC, Namespace wrote:
>>
>> import std.stdio;
>>
>> void foo1(void function(void*) fp) { }
>> void foo2(void function(int) fp) { }
>> void foo3(void*) { }
>>
>> void main()
>> {
>> foo1((void* ptr) => ( assert(ptr
Andrej Mitrovic:
I'm pretty sure I saw it filed somewhere. Can't find it though..
I have just added the new test case :-)
http://d.puremagic.com/issues/show_bug.cgi?id=6754
Bye,
bearophile
On 10/10/13, bearophile wrote:
> Perhaps this bug is not yet in Bugzilla.
I'm pretty sure I saw it filed somewhere. Can't find it though..
On Thursday, 10 October 2013 at 17:47:54 UTC, Namespace wrote:
import std.stdio;
void foo1(void function(void*) fp) { }
void foo2(void function(int) fp) { }
void foo3(void*) { }
void main()
{
foo1((void* ptr) => ( assert(ptr is null) ));
foo2((int a) => ( a + 1 )); /// Fails: Erro
import std.stdio;
void foo1(void function(void*) fp) { }
void foo2(void function(int) fp) { }
void foo3(void*) { }
void main()
{
foo1((void* ptr) => ( assert(ptr is null) ));
foo2((int a) => ( a + 1 )); /// Fails: Error: function foo2
(void function(int) fp) is not callable using
Namespace:
/d917/f732.d(8): Error: basic type expected, not extern
/d917/f732.d(8): Error: semicolon expected to close alias
declaration
/d917/f732.d(8): Error: no identifier for declarator void
function(T*)
It seems that even the new alias syntax doesn't support the
extern :-) Perhaps this
On Thursday, 10 October 2013 at 15:15:45 UTC, bearophile wrote:
Namespace:
You mean like this?
void foo(T)(extern(C) void function(T*) func) {
}
That prints: Error: basic type expected, not extern
In theory that's correct, in practice the compiler refuses
tha
On Thursday, 10 October 2013 at 15:15:45 UTC, bearophile wrote:
Namespace:
You mean like this?
void foo(T)(extern(C) void function(T*) func) {
}
That prints: Error: basic type expected, not extern
In theory that's correct, in practice the compiler refuses
tha
On Thursday, 10 October 2013 at 14:44:00 UTC, Dicebot wrote:
On Thursday, 10 October 2013 at 14:40:09 UTC, Namespace wrote:
Example? I do not use lambdas often.
void foo(T)(void function(T*) test)
{
}
extern(C) void bar(int*) { }
void main()
{
foo( (int* a) => bar(a) );
}
I don't kn
Namespace:
You mean like this?
void foo(T)(extern(C) void function(T*) func) {
}
That prints: Error: basic type expected, not extern
In theory that's correct, in practice the compiler refuses that,
it's in Bugzilla, so try to define the type outside the signat
On Thursday, 10 October 2013 at 14:28:20 UTC, Dicebot wrote:
On Thursday, 10 October 2013 at 14:13:47 UTC, Namespace wrote:
I have this function:
void foo(T)(void function(T*) test) { }
And want to call it with a C function:
foo!(SDL_Surface)(SDL_FreeSurface);
but I get:
Fe
On Thursday, 10 October 2013 at 14:40:09 UTC, Namespace wrote:
Example? I do not use lambdas often.
void foo(T)(void function(T*) test)
{
}
extern(C) void bar(int*) { }
void main()
{
foo( (int* a) => bar(a) );
}
I don't know to what extent IFTI can work here though.
Error: foo (void function(SDL_Surface*) test)
is not
callable using argument types (extern (C) void
function(SDL_Surface*)
nothrow)
What would be the smartest solution?
If you can change the signature of foo just add a extern(c) to
the function pointer declaration.
Otherwise just wrap the
argument types (extern (C) void function(SDL_Surface*)
nothrow)
What would be the smartest solution?
If you can change the signature of foo just add a extern(c) to the
function pointer declaration.
Otherwise just wrap the SDL_FreeSurface call into a delegate on the
caller side.
--
Kind Regards
On Thursday, 10 October 2013 at 14:13:47 UTC, Namespace wrote:
I have this function:
void foo(T)(void function(T*) test) { }
And want to call it with a C function:
foo!(SDL_Surface)(SDL_FreeSurface);
but I get:
Fehler 1 Error: foo (void function(SDL_Surface*) test) is not
c
I have this function:
void foo(T)(void function(T*) test) { }
And want to call it with a C function:
foo!(SDL_Surface)(SDL_FreeSurface);
but I get:
Fehler 1 Error: foo (void function(SDL_Surface*) test) is not
callable using argument types (extern (C) void
function(SDL_Surf
On Sunday, 28 July 2013 at 22:13:13 UTC, H. S. Teoh wrote:
On Mon, Jul 29, 2013 at 12:04:55AM +0200, Gabi wrote:
I tried:
struct X
{
..
function double(Individual) someFun;
[...]
The correct syntax is:
double function(Individual) someFun;
T
Yes thanks. Beginner's mistake :)
On Sunday, 28 July 2013 at 22:04:57 UTC, Gabi wrote:
I tried:
struct X
{
..
function double(Individual) someFun;
..
}
But get:
Error: Declaration expected, not 'function'
Thanks,
Gabi
Sorry I found the answer.
Should have declared double function(...) someFun;
On Mon, Jul 29, 2013 at 12:04:55AM +0200, Gabi wrote:
> I tried:
>
> struct X
> {
> ..
> function double(Individual) someFun;
[...]
The correct syntax is:
double function(Individual) someFun;
T
--
Music critic: "That's an imitation fugue!"
I tried:
struct X
{
..
function double(Individual) someFun;
..
}
But get:
Error: Declaration expected, not 'function'
Thanks,
Gabi
On Sunday, October 07, 2012 10:42:49 Timon Gehr wrote:
> On 10/07/2012 10:35 AM, Jonathan M Davis wrote:
> > On Sunday, October 07, 2012 10:25:41 Tommi wrote:
> >> The following compiles, which I'm pretty sure must be a bug,
> >> right? Just checking to be sure I won't be polluting the bug
> >> tra
On 10/07/2012 10:35 AM, Jonathan M Davis wrote:
On Sunday, October 07, 2012 10:25:41 Tommi wrote:
The following compiles, which I'm pretty sure must be a bug,
right? Just checking to be sure I won't be polluting the bug
tracker.
void main()
{
auto f = (int i) {};
static assert (!is(
On Sunday, October 07, 2012 10:25:41 Tommi wrote:
> The following compiles, which I'm pretty sure must be a bug,
> right? Just checking to be sure I won't be polluting the bug
> tracker.
>
> void main()
> {
> auto f = (int i) {};
> static assert (!is(f == function)); // should fail
>
The following compiles, which I'm pretty sure must be a bug,
right? Just checking to be sure I won't be polluting the bug
tracker.
void main()
{
auto f = (int i) {};
static assert (!is(f == function)); // should fail
static assert (!is(f == delegate));
}
//dmd: ok
> fn(1); // dmd: not ok
> }
The type of the function pointer does not include the values of the
default parameters.
typeof lies.
pragma(msg, typeof(fn));
> void function(int i, double j = 1)
Opened:
http://d.puremagic.com/issues/show_bug.cgi?id=8579
Ali
On Wednesday, August 22, 2012 11:51:45 Ellery Newcomer wrote:
> hey.
>
> is this valid code?
>
> void func1(int i, double j = 1.0) {
> }
>
> void main() {
> auto fn = &func1;
> func1(1); //dmd: ok
> fn(1); // dmd: not ok
> }
Default arguments are not part of the type. This behavior is very much
On 08/22/2012 12:03 PM, Ali Çehreli wrote:
On 08/22/2012 11:51 AM, Ellery Newcomer wrote:
> hey.
>
> is this valid code?
>
> void func1(int i, double j = 1.0) {
> }
>
> void main() {
> auto fn = &func1;
> func1(1); //dmd: ok
> fn(1); // dmd:
On 08/22/2012 11:51 AM, Ellery Newcomer wrote:
> hey.
>
> is this valid code?
>
> void func1(int i, double j = 1.0) {
> }
>
> void main() {
> auto fn = &func1;
> func1(1); //dmd: ok
> fn(1); // dmd: not ok
> }
The type of the function pointer doe
hey.
is this valid code?
void func1(int i, double j = 1.0) {
}
void main() {
auto fn = &func1;
func1(1); //dmd: ok
fn(1); // dmd: not ok
}
time:
auto func = &object.func;
This will create a delegate with the this pointer and the function
pointer. If you want to build it manually you can do that also:
alias void delegate() func_t;
func_t func;
func.funcptr = GetFunctionPointer();
func.ptr = object;
Kind Regards
Benjamin Thaut
On 07/08/2012 09:57 PM, Alex Rønne Petersen wrote:
Hi,
Is there a portable way to obtain a pointer to a member function and
invoke it with the this reference? I seem to recall some discussion
about this on the NG in the past, but can't find the thread now.
auto mptr = function(Base o,Args arg
Hi,
Is there a portable way to obtain a pointer to a member function and
invoke it with the this reference? I seem to recall some discussion
about this on the NG in the past, but can't find the thread now.
--
Alex Rønne Petersen
a...@lycus.org
http://lycus.org
Le 01/07/2012 01:59, dnewbie a écrit :
import std.stdio;
alias void function(int) fooInt;
alias void function(long) fooLong;
int main(string[] args)
{
fooInt f1 = &foo;
fooLong f2 = &foo;
f1(1L);
f2(1L);
return 0;
}
void foo(int i)
{
writeln("foo(int i)");
}
void foo(long i)
{
writeln("foo(lo
import std.stdio;
alias void function(int) fooInt;
alias void function(long) fooLong;
int main(string[] args)
{
fooInt f1 = &foo;
fooLong f2 = &foo;
f1(1L);
f2(1L);
return 0;
}
void foo(int i)
{
writeln("foo(int i)");
}
void foo(long i)
{
writeln("foo(long i)");
}
Simple question. How to I get a function pointer to one of the foo
functions in this case :
void foo(int i);
void foo(long i);
Your problem was that you didn't cast the function pointer to an
extern(C) function. Unfortunately you can't do this inline (I can't
tell if this will be fixed or not), so you have to use an alias as a
workaround:
alias extern (C) int function(void*,int,int,int) SciFnDirect;
fn = c
On Sat, Jan 14, 2012, at 06:04 AM, Andrej Mitrovic wrote:
> On 1/14/12, Andrej Mitrovic wrote:
> > You can clone this: g...@github.com:AndrejMitrovic/DSciteWin.git
> >
> > Then just run build.bat.
> >
>
> Sorry, I've assumed you run git, the http link is:
> https://github.com/AndrejMitrovic/DSci
On 1/14/12, Andrej Mitrovic wrote:
> You can clone this: g...@github.com:AndrejMitrovic/DSciteWin.git
>
> Then just run build.bat.
>
Sorry, I've assumed you run git, the http link is:
https://github.com/AndrejMitrovic/DSciteWin
You can clone this: g...@github.com:AndrejMitrovic/DSciteWin.git
Then just run build.bat.
I've been trying to translate the following from
http://www.scintilla.org/Steps.html
int (*fn)(void*,int,int,int);
void * ptr;
int canundo;
fn = (int (__cdecl *)(void *,int,int,int))SendMessage(
hwndScintilla,SCI_GETDIRECTFUNCTION,0,0);
ptr = (void *)SendMessage(hwndScintilla,SCI_GETDIRE
"Peter Federighi" wrote in message
news:ial8hq$213...@digitalmars.com...
> Is there a way to do it without removing handler() from the class? When I
> try
> compiling, I get: Error: cannot implicitly convert expression
> (&this.handler)
> of type void delegate(int signal) to void C function(in
he class? When
I try
compiling, I get: Error: cannot implicitly convert expression
(&this.handler)
of type void delegate(int signal) to void C function(int).
Thank you,
- Peter
No, unfortunately not. A delegate is a function pointer PLUS 'this'. The C
API you are using allows pro
Hello. I'm new to D. It's been a long time since I've coded anything with
classes. Please excuse my ignorance.
Here's a very simplified version of what I'm trying to do:
import std.c.linux.linux;
import std.stdio;
class FOO
{
this()
{
sa.sa_handler = &handler;
si
On Friday, September 17, 2010 17:07:15 Simen kjaeraas wrote:
> Jonathan M Davis wrote:
> >> I've always been confused by C in this regard. It seems to logical to me
> >> that T[3] works the same whether T is U[4] or U.
> >
> > You're going to have to elaborate on that. I'm not quite sure what you
Jonathan M Davis wrote:
I've always been confused by C in this regard. It seems to logical to me
that T[3] works the same whether T is U[4] or U.
You're going to have to elaborate on that. I'm not quite sure what you're
talking about. And the syntax int[4][3] isn't legal C anyway. It just
d
Jonathan M Davis Wrote:
> On Friday, September 17, 2010 10:43:12 Ali Ãehreli wrote:
> >
> > int[4] is an array of 4 ints; like Simen, let's call it U.
> > Now U[3] is an array of 3 Us; i.e. 3 int[4]s
> >
> > I read that from left to right, not inside out.
>
> No, no. You read it outwards from t
On Friday, September 17, 2010 10:43:12 Ali Çehreli wrote:
> Jonathan M Davis wrote:
> > On Thursday 16 September 2010 23:50:16 Kagamin wrote:
> >> BCS Wrote:
> >>> The trick is that function pointers are best read from the inside out.
> >>
> >> All C declarations are read from inside out, pos
On Friday, September 17, 2010 05:00:55 Simen kjaeraas wrote:
> On Fri, 17 Sep 2010 10:12:34 +0200, Jonathan M Davis
>
> wrote:
> > On Thursday 16 September 2010 23:50:16 Kagamin wrote:
> >> BCS Wrote:
> >> > The trick is that function pointers are best read from the inside out.
> >>
> >> All C d
Jonathan M Davis wrote:
> On Thursday 16 September 2010 23:50:16 Kagamin wrote:
>> BCS Wrote:
>>> The trick is that function pointers are best read from the inside out.
>> All C declarations are read from inside out, postfixes take precedence,
>> that's why you have to use braces to give pointer h
On Fri, 17 Sep 2010 10:12:34 +0200, Jonathan M Davis
wrote:
On Thursday 16 September 2010 23:50:16 Kagamin wrote:
BCS Wrote:
> The trick is that function pointers are best read from the inside out.
All C declarations are read from inside out, postfixes take precedence,
that's why you have t
On Thursday 16 September 2010 23:50:16 Kagamin wrote:
> BCS Wrote:
> > The trick is that function pointers are best read from the inside out.
>
> All C declarations are read from inside out, postfixes take precedence,
> that's why you have to use braces to give pointer higher precedence. One
> of
BCS Wrote:
> The trick is that function pointers are best read from the inside out.
> --
All C declarations are read from inside out, postfixes take precedence, that's
why you have to use braces to give pointer higher precedence. One of the
earlier books by Stroustroup gives a nice monster of a
outermost level, you end up with (note (void) becomes ())
void function() (*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol);
instead of Name, you've got this funny thing. You're left with a
function pointer declaration where void function() is the ReturnType, so
transformi
Hello Steven,
On Thu, 16 Sep 2010 10:06:24 -0400, BCS wrote:
Hello Steven,
// note you can't use void as a parameter type in D
void (*(*xDlSym)(sqlite3_vfs*,void*, const char
*zSymbol))(/*void*/);
pragma(msg, typeof(xDlSym).stringof);
outputs:
void function() function(sqlite3_vfs*, void*, c
)
D, now with C type un-garbleing!
Perhaps the only excuse for keeping C-style function pointer
declarations in D.
But since we have htod, we could just as well use it and leave D free to
get rid of this fossil that leads to a syntactic ambiguity. Except that
I've just found htod
On Thu, 16 Sep 2010 10:06:24 -0400, BCS wrote:
Hello Steven,
// note you can't use void as a parameter type in D
void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(/*void*/);
pragma(msg, typeof(xDlSym).stringof);
outputs:
void function() function(sqlite3_vfs*, void*, const const(char
Hello Steven,
// note you can't use void as a parameter type in D
void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(/*void*/);
pragma(msg, typeof(xDlSym).stringof);
outputs:
void function() function(sqlite3_vfs*, void*, const const(char*)
zSymbol)
D, now with C type un-garbleing!
--
DlSym).stringof);
outputs:
void function() function(sqlite3_vfs*, void*, const const(char*) zSymbol)
so I think it's a function pointer that takes those parameters and
returns a function pointer that takes no parameters and returns nothing.
-Steve
Thanks Steve!
--
Yao G.
On Wed, 15 Sep 2010 17:05:24 -0400, Yao G.
wrote:
Hello gentlemen:
I'm trying to translate the newest SQLite C header to D, and I stumbled
unto this gem:
void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);
What's that? A function pointer that takes anothe
(void);
What's that? A function pointer that takes another function pointer as
its name? I'm stuck at this and I don't know how to convert it to a D
function pointer. Certainly, the inner pointer is easy:
void (* function(sqlite3_vfs*,void*, const(char) *zSymbol) xDlSym)();
Hello gentlemen:
I'm trying to translate the newest SQLite C header to D, and I stumbled
unto this gem:
void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void);
What's that? A function pointer that takes another function pointer as its
name? I'm stuck at this and I
Simen kjaeraas:
> Add it to Bugzilla. Another case is that this works:
>
> alias pure int function( int ) FN;
> pure foo4( FN fn, int x ) {
> return fn( x );
> }
>
> It seems the problem is that type specification in function signatures
> does not support the full range of type signature in
On Sun, 25 Jul 2010 01:10:54 +0200, bearophile
wrote:
In the following D2 the D type system is strong enough to allow foo1()
to be pure because sqr() is a pointer to a pure function. In foo2() I
have tried to do the same thing avoiding templates, and it works. In
foo3() I have tried to w
In the following D2 the D type system is strong enough to allow foo1() to be
pure because sqr() is a pointer to a pure function. In foo2() I have tried to
do the same thing avoiding templates, and it works. In foo3() I have tried to
write the type literal, but I was not able to:
pure int sqr(i
101 - 167 of 167 matches
Mail list logo