Re: Calling D from C++

2011-07-18 Thread Johann MacDonagh
On 7/18/2011 11:52 PM, Andrej Mitrovic wrote: See I tried using dumpbin, but apparently I wiped it from my PATH so I had to rely on DLL Export viewer (because I'm lazy and it had an icon on my desktop!) which doesn't even show this. I had a hunch that was happening behind the scenes. Thanks for t

Re: Calling D from C++

2011-07-18 Thread Andrej Mitrovic
Uhh, I tried using ASM to simulate the thiscall calling convention, it didn't go all to well. :) A wrapper C++ DLL that exposes a C interface was my workaround. Here's a page that talks about some problems with passing objects via DLLs: http://www.prowiki.org/wiki4d/wiki.cgi?BestPractices/DLL

Re: Calling D from C++

2011-07-18 Thread Andrej Mitrovic
On 7/19/11, Johann MacDonagh wrote: > If you export it like this, it will be exported as the C++ mangled name. > If you have extern(C) it will be cdecl "_SetInt" and extern(Windows) > will be stdcall "_SetInt@4". Right, that's all pretty standard stuff. :) > >> I don't know why, but if you use a

Re: Calling D from C++

2011-07-18 Thread Johann MacDonagh
On 7/18/2011 11:27 PM, Loopback wrote: On 2011-07-19 04:40, Andrej Mitrovic wrote: You have several problems. extern(C++) only specifies the calling convention, not the visibility of the symbol. To export the symbol, list it in a .def file or mark the function with export in the module itself,

Re: Calling D from C++

2011-07-18 Thread Loopback
On 2011-07-19 04:40, Andrej Mitrovic wrote: You have several problems. extern(C++) only specifies the calling convention, not the visibility of the symbol. To export the symbol, list it in a .def file or mark the function with export in the module itself, ala: export extern(C++) void SetInt(int

Re: Calling D from C++

2011-07-18 Thread Johann MacDonagh
On 7/18/2011 10:40 PM, Andrej Mitrovic wrote: You have several problems. extern(C++) only specifies the calling convention, not the visibility of the symbol. To export the symbol, list it in a .def file or mark the function with export in the module itself, ala: export extern(C++) void SetInt(i

Re: Calling D from C++

2011-07-18 Thread Andrej Mitrovic
You have several problems. extern(C++) only specifies the calling convention, not the visibility of the symbol. To export the symbol, list it in a .def file or mark the function with export in the module itself, ala: export extern(C++) void SetInt(int * foo) {} I don't know why, but if you use a

Re: Calling D from C++

2011-07-18 Thread Loopback
On 2011-07-19 00:56, Johann MacDonagh wrote: On 7/18/2011 5:04 PM, Andrej Mitrovic wrote: On 7/18/11, Loopback wrote: On 2011-07-18 21:59, Andrej Mitrovic wrote: import core.dll_helper; is outdated, use import core.sys.windows.dll; And also import core.runtime; Are there any examples coverin

Re: Infer purity of functions too?

2011-07-18 Thread Johann MacDonagh
On 7/18/2011 7:43 PM, Jonathan M Davis wrote: On 2011-07-18 16:02, Johann MacDonagh wrote: On 7/18/2011 7:00 PM, bearophile wrote: Jonathan M Davis: And if pure were inferred for a function and then it became impure, that could break a _lot_ of code. OK. The restricted idea then is to infer

Re: Passing null array to template

2011-07-18 Thread Jonathan M Davis
On Tuesday 19 July 2011 01:19:11 Jesse Phillips wrote: > On Mon, 18 Jul 2011 19:44:38 +0200, David Nadlinger wrote: > > On 7/18/11 7:43 PM, Jesse Phillips wrote: > >> I'm wondering if this should be filed in Bugzilla. I'm guessing it > >> should. The blow should compile? > >> > >> void main() { >

Re: Passing null array to template

2011-07-18 Thread Jesse Phillips
On Mon, 18 Jul 2011 19:44:38 +0200, David Nadlinger wrote: > On 7/18/11 7:43 PM, Jesse Phillips wrote: >> I'm wondering if this should be filed in Bugzilla. I'm guessing it >> should. The blow should compile? >> >> void main() { >> example(null); >> } >> >> void example()(string[] foo) { >> }

Re: Infer purity of functions too?

2011-07-18 Thread Jonathan M Davis
On 2011-07-18 16:02, Johann MacDonagh wrote: > On 7/18/2011 7:00 PM, bearophile wrote: > > Jonathan M Davis: > >> And if pure were inferred for a function and then it became > >> impure, that could break a _lot_ of code. > > > > OK. The restricted idea then is to infer only the purity of functions

Re: Infer purity of functions too?

2011-07-18 Thread Jonathan M Davis
On 2011-07-18 16:07, bearophile wrote: > > Example: if a not pure function sqr is called by both a not pure template > > bar and by a pure function foo, the compiler raises an error in foo, > > because sqr is not pure, but compiles the pure main because sqr called > > by bar is seen as pure :-) >

Re: Calling D from C++

2011-07-18 Thread Johann MacDonagh
On 7/18/2011 7:08 PM, Andrej Mitrovic wrote: On 7/19/11, Johann MacDonagh wrote: FWIW I was able to compile and link a D DLL with the code I copy pasted in the other message. Maybe you're running 2.052. I think in 2.053 dll_helper disappeared, and so in 2.054: D:\dev\code\d_code\DLLTest>dmd

Re: Calling D from C++

2011-07-18 Thread Andrej Mitrovic
On 7/19/11, Johann MacDonagh wrote: > FWIW I was able to compile and link a D DLL with the code I copy pasted > in the other message. Maybe you're running 2.052. I think in 2.053 dll_helper disappeared, and so in 2.054: D:\dev\code\d_code\DLLTest>dmd mydll.d mydll.d(9): Error: module dll_helper

Re: Infer purity of functions too?

2011-07-18 Thread Johann MacDonagh
On 7/18/2011 7:00 PM, bearophile wrote: Jonathan M Davis: And if pure were inferred for a function and then it became impure, that could break a _lot_ of code. OK. The restricted idea then is to infer only the purity of functions called by templates, to allow more templates to be pure, and s

Re: Infer purity of functions too?

2011-07-18 Thread bearophile
> Example: if a not pure function sqr is called by both a not pure template bar > and by a pure function foo, the compiler raises an error in foo, because sqr > is not pure, but compiles the pure main because sqr called by bar is seen as > pure :-) This seems quite useful for delegates given to

Re: Calling D from C++

2011-07-18 Thread Johann MacDonagh
On 7/18/2011 5:04 PM, Andrej Mitrovic wrote: On 7/18/11, Loopback wrote: On 2011-07-18 21:59, Andrej Mitrovic wrote: import core.dll_helper; is outdated, use import core.sys.windows.dll; And also import core.runtime; Are there any examples covering these new modules, or are the procedure the

Re: Infer purity of functions too?

2011-07-18 Thread bearophile
Jonathan M Davis: > And if pure were inferred for a function and then it became > impure, that could break a _lot_ of code. OK. The restricted idea then is to infer only the purity of functions called by templates, to allow more templates to be pure, and such inferred purity is seen by functio

Re: std.concurrency.spawn does not accept delegates

2011-07-18 Thread Jonathan M Davis
On 2011-07-18 15:15, teo wrote: > On Mon, 18 Jul 2011 18:14:45 +, Jonathan M Davis wrote: > > On 2011-07-18 10:54, Simen Kjaeraas wrote: > >> On Mon, 18 Jul 2011 18:06:46 +0200, Jonathan M Davis > >> > >> > >> wrote: > >> > On Monday 18 July 2011 15:55:52 teo wrote: > >> >> On Mon, 18 Jul 201

Re: std.concurrency.spawn does not accept delegates

2011-07-18 Thread teo
On Mon, 18 Jul 2011 18:14:45 +, Jonathan M Davis wrote: > On 2011-07-18 10:54, Simen Kjaeraas wrote: >> On Mon, 18 Jul 2011 18:06:46 +0200, Jonathan M Davis >> >> >> wrote: >> > On Monday 18 July 2011 15:55:52 teo wrote: >> >> On Mon, 18 Jul 2011 10:26:27 -0400, Steven Schveighoffer wrote: >

Re: Infer purity of functions too?

2011-07-18 Thread Jonathan M Davis
On 2011-07-18 14:01, Steven Schveighoffer wrote: > On Mon, 18 Jul 2011 16:52:41 -0400, Jonathan M Davis > > wrote: > > On 2011-07-18 13:32, Steven Schveighoffer wrote: > >> On Mon, 18 Jul 2011 16:01:08 -0400, bearophile > >> > >> > >> wrote: > >> > Maybe someone has already answered this questi

Re: Calling D from C++

2011-07-18 Thread Andrej Mitrovic
On 7/18/11, Loopback wrote: > On 2011-07-18 21:59, Andrej Mitrovic wrote: >> import core.dll_helper; is outdated, use import core.sys.windows.dll; >> And also import core.runtime; > > Are there any examples covering these new modules, or are the procedure > the same? > It's all pretty much the sa

Re: Infer purity of functions too?

2011-07-18 Thread Steven Schveighoffer
On Mon, 18 Jul 2011 16:52:41 -0400, Jonathan M Davis wrote: On 2011-07-18 13:32, Steven Schveighoffer wrote: On Mon, 18 Jul 2011 16:01:08 -0400, bearophile wrote: > Maybe someone has already answered this question, but I don't remember > it. > > DMD 2.054 is able to infer if a template f

Re: Infer purity of functions too?

2011-07-18 Thread Jonathan M Davis
On 2011-07-18 13:32, Steven Schveighoffer wrote: > On Mon, 18 Jul 2011 16:01:08 -0400, bearophile > > wrote: > > Maybe someone has already answered this question, but I don't remember > > it. > > > > DMD 2.054 is able to infer if a template function is pure. Isn't it a > > good idea to use the s

Re: Infer purity of functions too?

2011-07-18 Thread Steven Schveighoffer
On Mon, 18 Jul 2011 16:01:08 -0400, bearophile wrote: Maybe someone has already answered this question, but I don't remember it. DMD 2.054 is able to infer if a template function is pure. Isn't it a good idea to use the same machinery to infer the unmarked functions too? A template may

Re: Calling D from C++

2011-07-18 Thread Loopback
On 2011-07-18 21:59, Andrej Mitrovic wrote: import core.dll_helper; is outdated, use import core.sys.windows.dll; And also import core.runtime; Are there any examples covering these new modules, or are the procedure the same?

Purity tree trace error?

2011-07-18 Thread bearophile
In DMD 2.054 if I have a wrong program like this, a function that's not pure called from a pure function: import std.conv; void main() pure { to!int("12"); } DMD 2.054 prints: test.d(3): Error: pure function 'main' cannot call impure function 'to' Instead of that error message, do you lik

Infer purity of functions too?

2011-07-18 Thread bearophile
Maybe someone has already answered this question, but I don't remember it. DMD 2.054 is able to infer if a template function is pure. Isn't it a good idea to use the same machinery to infer the unmarked functions too? A template may call a second function that's not annotated with 'pure' despite

Re: Calling D from C++

2011-07-18 Thread Andrej Mitrovic
import core.dll_helper; is outdated, use import core.sys.windows.dll; And also import core.runtime;

Re: Calling D from C++

2011-07-18 Thread Loopback
On 2011-07-17 22:51, Johann MacDonagh wrote: On 7/17/2011 3:53 PM, Loopback wrote: On 2011-07-17 21:45, Loopback wrote: Hello! As of my understanding you can write usable c libraries in D by using extern(C). The problem is that I haven't found any other threads asking the same question about C

Re: std.concurrency.spawn does not accept delegates

2011-07-18 Thread Jonathan M Davis
On 2011-07-18 10:54, Simen Kjaeraas wrote: > On Mon, 18 Jul 2011 18:06:46 +0200, Jonathan M Davis > > wrote: > > On Monday 18 July 2011 15:55:52 teo wrote: > >> On Mon, 18 Jul 2011 10:26:27 -0400, Steven Schveighoffer wrote: > >> > On Sun, 17 Jul 2011 15:29:02 -0400, teo wrote: > >> >> It looks

Re: Passing null array to template

2011-07-18 Thread Jonathan M Davis
On 2011-07-18 10:44, David Nadlinger wrote: > On 7/18/11 7:43 PM, Jesse Phillips wrote: > > I'm wondering if this should be filed in Bugzilla. I'm guessing it > > should. The blow should compile? > > > > void main() { > > > > example(null); > > > > } > > > > void example()(string[] foo) { > > }

Re: std.concurrency.spawn does not accept delegates

2011-07-18 Thread Simen Kjaeraas
On Mon, 18 Jul 2011 18:06:46 +0200, Jonathan M Davis wrote: On Monday 18 July 2011 15:55:52 teo wrote: On Mon, 18 Jul 2011 10:26:27 -0400, Steven Schveighoffer wrote: > On Sun, 17 Jul 2011 15:29:02 -0400, teo wrote: >> It looks like std.concurrency.spawn does not accept delegates. Is >> the

Re: A different vector op

2011-07-18 Thread Andrej Mitrovic
float[] buffers = malloc..; float*[] CBuffers = buffers[].ptr; Pure win.

Re: Passing null array to template

2011-07-18 Thread David Nadlinger
On 7/18/11 7:43 PM, Jesse Phillips wrote: I'm wondering if this should be filed in Bugzilla. I'm guessing it should. The blow should compile? void main() { example(null); } void example()(string[] foo) { } test.d(3): Error: template test.example() does not match any function template

Passing null array to template

2011-07-18 Thread Jesse Phillips
I'm wondering if this should be filed in Bugzilla. I'm guessing it should. The blow should compile? void main() { example(null); } void example()(string[] foo) { } test.d(3): Error: template test.example() does not match any function template declaration test.d(3): Error: template test

Re: workaround to sort BigInt[]?

2011-07-18 Thread David Nadlinger
On 7/18/11 6:28 PM, McAnany, Charles E wrote: Hi, all. I'm trying to sort an array of BigInts, and I get an overlapping array copy error. Short of writing my own sorting algorithm, is there a workaround for this? Didn't you ask the same question here a few days ago? In any case, here is the

workaround to sort BigInt[]?

2011-07-18 Thread McAnany, Charles E
Hi, all. I'm trying to sort an array of BigInts, and I get an overlapping array copy error. Short of writing my own sorting algorithm, is there a workaround for this? Thanks, Charles.

Re: std.datetime for month integer

2011-07-18 Thread dsmith
Thank you, it works as planned, now as: int mo = Now.month; // --> 7 == Repost the article of Jonathan M Davis (jmdavisp...@gmx.com) == Posted at 2011/07/18 12:14 to digitalmars.D.learn On�Monday�18�July�2011�16:01:06�dsmith�wrote: >�Recall�that�std.date�used�the�following�to�retrieve�a�month�in

Re: std.datetime for month integer

2011-07-18 Thread Jonathan M Davis
On Monday 18 July 2011 16:01:06 dsmith wrote: > Recall that std.date used the following to retrieve a month in integer form > (0 .. 11): > > auto Now = std.date.getUTCtime(); > writeln(std.date.monthFromTime(Now)); > > Using std.datetime, the following yields the abbreviated month name: > >

Re: Polymorphism problem w/local functions?

2011-07-18 Thread Jonathan M Davis
On Monday 18 July 2011 14:11:29 Magnus Lie Hetland wrote: > Is it intended that local functions can't be polymorphic? > > Example: > > void foo(int x) {} > void foo(string x) {} > > void bar() { > void foo(int x) {} > void foo(string x) {} > } > > void main() { > } > > The error (at li

Re: std.concurrency.spawn does not accept delegates

2011-07-18 Thread Jonathan M Davis
On Monday 18 July 2011 15:55:52 teo wrote: > On Mon, 18 Jul 2011 10:26:27 -0400, Steven Schveighoffer wrote: > > On Sun, 17 Jul 2011 15:29:02 -0400, teo wrote: > >> It looks like std.concurrency.spawn does not accept delegates. Is > >> there > >> any reason for that? > > > > There is no type atta

std.datetime for month integer

2011-07-18 Thread dsmith
Recall that std.date used the following to retrieve a month in integer form (0 .. 11): auto Now = std.date.getUTCtime(); writeln(std.date.monthFromTime(Now)); Using std.datetime, the following yields the abbreviated month name: auto Now = Clock.currTime(); writefln("%s", Now.month);

Re: std.concurrency.spawn does not accept delegates

2011-07-18 Thread teo
On Mon, 18 Jul 2011 10:26:27 -0400, Steven Schveighoffer wrote: > On Sun, 17 Jul 2011 15:29:02 -0400, teo wrote: > >> It looks like std.concurrency.spawn does not accept delegates. Is there >> any reason for that? > > There is no type attached to the hidden 'this' pointer. So spawn cannot > gu

Re: std.concurrency.spawn does not accept delegates

2011-07-18 Thread Steven Schveighoffer
On Sun, 17 Jul 2011 15:29:02 -0400, teo wrote: It looks like std.concurrency.spawn does not accept delegates. Is there any reason for that? There is no type attached to the hidden 'this' pointer. So spawn cannot guarantee it doesn't point to unshared data. -Steve

Polymorphism problem w/local functions?

2011-07-18 Thread Magnus Lie Hetland
Is it intended that local functions can't be polymorphic? Example: void foo(int x) {} void foo(string x) {} void bar() { void foo(int x) {} void foo(string x) {} } void main() { } The error (at line 6) is "declaration foo is already defined". The code compiles if you comment out at lea

Re: A different vector op

2011-07-18 Thread bearophile
Wilfried Kirschenmann: > In fact, I would be more interested in the opposite : If you allow that syntax on the left you probably allow it on the right too. Bye, bearophile