Re: runtime loading D shared library as a standalone (with it's own GC etc)

2014-02-26 Thread Timothee Cour
On Wed, Feb 26, 2014 at 1:20 PM, Adam D. Ruppe wrote: > Try compiling your library with -defaultlib= (leaving it blank after the > equal sign). Then it might work by not loading the symbols for phobos etc > twice - they will only be linked into the main program. > Thanks, but I don't see how that

undefined symbol: rt_finalize

2014-02-26 Thread Tolga Cakiroglu
I am trying to compile a shared library on Linux and use it. lib.d --- import core.runtime; class A{} extern(C) void foo(){ Object obj = new Object(); A objA = new A(); char[] c = new char[ 1024 ]; destroy( objA ); destroy( c );

Re: Static library including other static library

2014-02-26 Thread Mike Parker
On 2/27/2014 6:28 AM, Andre wrote: Hi, I created a static library "webbrowser.lib" which depends on the dsource project WindowsAPI. I compile my static library by this statement: dmd main ... C:\D\WindowsAPI\dmd_win32_x32.lib -lib -of"webbrowser.lib" I get a static library with my webbrowser c

Static library including other static library

2014-02-26 Thread Andre
Hi, I created a static library "webbrowser.lib" which depends on the dsource project WindowsAPI. I compile my static library by this statement: dmd main ... C:\D\WindowsAPI\dmd_win32_x32.lib -lib -of"webbrowser.lib" I get a static library with my webbrowser coding and it seems it als embedds th

Re: runtime loading D shared library as a standalone (with it's own GC etc)

2014-02-26 Thread Adam D. Ruppe
Try compiling your library with -defaultlib= (leaving it blank after the equal sign). Then it might work by not loading the symbols for phobos etc twice - they will only be linked into the main program.

runtime loading D shared library as a standalone (with it's own GC etc)

2014-02-26 Thread Timothee Cour
Currently (on OSX) I can runtime load a D dll from a C program, but not from a D program, which seems silly. Is it possible to runtime load a D shared library as a standalone (ie without sharing GC, runtime or any other data), treating it as if we were loading from a C program (making no attempt a

Re: Dynamically calling external libraries.

2014-02-26 Thread John Colvin
On Wednesday, 26 February 2014 at 17:58:46 UTC, Mike James wrote: On Wednesday, 26 February 2014 at 14:41:02 UTC, Adam D. Ruppe wrote: You'd do it the same way you do in C. On Windows, call LoadLibrary, FreeLibrary, and GetProcAddress or the COM functions. On Linux, the family of functions is d

Re: Dynamically calling external libraries.

2014-02-26 Thread Mike James
On Wednesday, 26 February 2014 at 14:41:02 UTC, Adam D. Ruppe wrote: You'd do it the same way you do in C. On Windows, call LoadLibrary, FreeLibrary, and GetProcAddress or the COM functions. On Linux, the family of functions is dlopen, dlsym, and dlclose. Knowing the types to pass the functio

Re: DUB Error

2014-02-26 Thread Sönke Ludwig
Am 26.02.2014 08:00, schrieb Steve Teale: On Wednesday, 26 February 2014 at 03:33:38 UTC, Jesse Phillips wrote: On Tuesday, 25 February 2014 at 14:32:42 UTC, Steve Teale wrote: What does the somewhat cryptic DUB error Trying to append absolute path. mean. By a process of elimination, the off

Re: A little of coordination for Rosettacode

2014-02-26 Thread Stanislav Blinov
Thank you for posting the code. However, I think there might be a subtle bug with my synchronization on bools, but I need to comtemplate on it some more to be sure :) On Wednesday, 26 February 2014 at 15:52:24 UTC, bearophile wrote: Stanislav Blinov: Oh, there is still much to discuss on th

Re: A little of coordination for Rosettacode

2014-02-26 Thread bearophile
Stanislav Blinov: The whole 'shared' concept being incomplete in the language is a shame. Hopefully things will get better in the near future. As for slicing syntax for shared arrays, personally I think it should be disallowed, just like operators for shared scalars. But that would mean that

Re: A little of coordination for Rosettacode

2014-02-26 Thread Stanislav Blinov
On Wednesday, 26 February 2014 at 14:54:05 UTC, Ali Çehreli wrote: On 02/26/2014 03:24 AM, bearophile wrote: > Ali Çehreli: > >> Improve at will! :p > > I will mostly just uniform its formatting to all the other Rosettacode > entries, shorten the lines to 72 chars, etc. > > >> sy

Re: A little of coordination for Rosettacode

2014-02-26 Thread Ali Çehreli
On 02/26/2014 06:58 AM, bearophile wrote: > Updated the site > http://rosettacode.org/wiki/Rendezvous#D Thanks for posting the problem to begin with. I've learned a lot. Ali

Re: A little of coordination for Rosettacode

2014-02-26 Thread Ali Çehreli
On 02/26/2014 04:46 AM, Stanislav Blinov wrote: > I forgot to note that both synchronized {} blocks should also be > synchronizing on the same mutex. Oh, that's a good one! :) > Run the code several times and you'll no doubt stumble upon it. But I had inserted that Sleep() in there. Isn't that

Re: A little of coordination for Rosettacode

2014-02-26 Thread bearophile
Ali Çehreli: And I am not sure why the slicing syntax works because the 'printers' member is still shared then. Probably it's a known D implementation fault meant to be eventually fixed. - Stanislav Blinov: Here are some improvements: http://dpaste.dzfl.pl/6430488f3d07 Upda

Re: A little of coordination for Rosettacode

2014-02-26 Thread Ali Çehreli
On 02/26/2014 03:24 AM, bearophile wrote: > Ali Çehreli: > >> Improve at will! :p > > I will mostly just uniform its formatting to all the other Rosettacode > entries, shorten the lines to 72 chars, etc. > > >> synchronized { >> // Switch to the next printer >>

Re: Dynamically calling external libraries.

2014-02-26 Thread Adam D. Ruppe
You'd do it the same way you do in C. On Windows, call LoadLibrary, FreeLibrary, and GetProcAddress or the COM functions. On Linux, the family of functions is dlopen, dlsym, and dlclose. Knowing the types to pass the functions is gonna be tricky and this needs to be right to avoid crashes. On

Re: A little of coordination for Rosettacode

2014-02-26 Thread Stanislav Blinov
On Wednesday, 26 February 2014 at 12:58:26 UTC, bearophile wrote: If you have bug fixes, or improvements, it's better to do them right there. Of if you don't want to register on that site, you can put the modified version in dpaste, and I'll upload it on Rosettacode. Here are some improvemen

Re: getopt example please

2014-02-26 Thread Andrew Edwards
On 2/26/14, 5:37 AM, Vladimir Panteleev wrote: On Wednesday, 26 February 2014 at 09:57:19 UTC, Andrew Edwards wrote: Request a small example of how to use getopt to accomplish the following: [1] program subcommand //process subcommand with default arguments if any [2] program -h subcommand //ou

Dynamically calling external libraries.

2014-02-26 Thread Setra
Hello all! I am in the process of creating a programming language, and I have completed parsing for most of the actual language (it is interpreted). I do not however have a way to print to the screen yet. This is because I want to use external libraries. My question is how in D can I call a extern

Re: alias declaration spec

2014-02-26 Thread John Colvin
On Wednesday, 26 February 2014 at 11:45:54 UTC, Jonathan M Davis wrote: On Tuesday, February 25, 2014 23:14:08 cal wrote: On Tuesday, 25 February 2014 at 23:09:43 UTC, Jonathan M Davis wrote: > On Tuesday, February 25, 2014 22:32:44 cal wrote: >> Grammar spec >> (http://dlang.org/grammar.html#

Re: A little of coordination for Rosettacode

2014-02-26 Thread bearophile
Stanislav Blinov: You'd also have to synchronize access to id member, I forgot to note that both synchronized {} blocks should also be synchronizing on the same mutex. The mutex could be emulated with a shared bool and std.atomic.cas(). That would get rid of synchronized{} blocks and woul

Re: A little of coordination for Rosettacode

2014-02-26 Thread Stanislav Blinov
I forgot to note that both synchronized {} blocks should also be synchronizing on the same mutex. Right now it's two different critical sections, so a race is still possible, i.e. while one thread is printing the other may be removing the first printer. Run the code several times and you'll no

Re: A little of coordination for Rosettacode

2014-02-26 Thread Stanislav Blinov
On Wednesday, 26 February 2014 at 11:24:58 UTC, bearophile wrote: Ali Çehreli: synchronized { // Switch to the next printer printers = printers[1..$]; } This doesn't work: printers.popFront(); Yes, because typeof(printers

Re: Array of struct pointers error

2014-02-26 Thread Szymon Gatner
On Wednesday, 26 February 2014 at 11:21:37 UTC, bearophile wrote: Szymon Gatner: That would be just it: import dchip.all; void main() { cpBody* bodies[]; auto b = cpBodyNew(0, 0); bodies ~= b; } where dchip is pulled using dub. As described earlier, wrapping cpBody* in another struct or

Re: Array of struct pointers error

2014-02-26 Thread Szymon Gatner
On Wednesday, 26 February 2014 at 11:22:00 UTC, Tobias Pankrath wrote: On Wednesday, 26 February 2014 at 11:07:44 UTC, Szymon Gatner wrote: On Wednesday, 26 February 2014 at 10:59:39 UTC, bearophile wrote: Szymon Gatner: I want to keep a list of pointers-to-C-struct but this line: Please re

Re: alias declaration spec

2014-02-26 Thread Jonathan M Davis
On Tuesday, February 25, 2014 23:14:08 cal wrote: > On Tuesday, 25 February 2014 at 23:09:43 UTC, Jonathan M Davis > > wrote: > > On Tuesday, February 25, 2014 22:32:44 cal wrote: > >> Grammar spec (http://dlang.org/grammar.html#AliasDeclaration) > >> allows: > >> > >> AliasDeclaration: > >>

Re: Array of struct pointers error

2014-02-26 Thread bearophile
Szymon Gatner: That would be just it: import dchip.all; void main() { cpBody* bodies[]; auto b = cpBodyNew(0, 0); bodies ~= b; } where dchip is pulled using dub. As described earlier, wrapping cpBody* in another struct or Tuple works. Now you have to remove all imports from the code

Re: Array of struct pointers error

2014-02-26 Thread Tobias Pankrath
On Wednesday, 26 February 2014 at 11:07:44 UTC, Szymon Gatner wrote: On Wednesday, 26 February 2014 at 10:59:39 UTC, bearophile wrote: Szymon Gatner: I want to keep a list of pointers-to-C-struct but this line: Please reduce your code as much as possible, and show the whole compilable reduc

Re: A little of coordination for Rosettacode

2014-02-26 Thread bearophile
Ali Çehreli: Improve at will! :p I will mostly just uniform its formatting to all the other Rosettacode entries, shorten the lines to 72 chars, etc. synchronized { // Switch to the next printer printers = printers[1..$];

Re: Array of struct pointers error

2014-02-26 Thread Szymon Gatner
On Wednesday, 26 February 2014 at 10:59:39 UTC, bearophile wrote: Szymon Gatner: I want to keep a list of pointers-to-C-struct but this line: Please reduce your code as much as possible, and show the whole compilable reduced buggy program here. Bye, bearophile That would be just it: imp

Re: Array of struct pointers error

2014-02-26 Thread bearophile
Szymon Gatner: Is there a different array declaration syntax for pointers? There is not. But the D-style syntax is preferred for arrays. Bye, bearophile

Re: Array of struct pointers error

2014-02-26 Thread bearophile
Szymon Gatner: I want to keep a list of pointers-to-C-struct but this line: Please reduce your code as much as possible, and show the whole compilable reduced buggy program here. Bye, bearophile

Re: getopt example please

2014-02-26 Thread Vladimir Panteleev
On Wednesday, 26 February 2014 at 09:57:19 UTC, Andrew Edwards wrote: Request a small example of how to use getopt to accomplish the following: [1] program subcommand //process subcommand with default arguments if any [2] program -h subcommand //output help information about subcommand [3] pr

Re: getopt example please

2014-02-26 Thread simendsjo
On 02/26/2014 11:06 AM, Tobias Pankrath wrote: On Wednesday, 26 February 2014 at 09:57:19 UTC, Andrew Edwards wrote: Request a small example of how to use getopt to accomplish the following: [1] program subcommand //process subcommand with default arguments if any [2] program -h subcommand //ou

Re: Array of struct pointers error

2014-02-26 Thread Szymon Gatner
On Wednesday, 26 February 2014 at 10:01:53 UTC, Tobias Pankrath wrote: On Wednesday, 26 February 2014 at 09:56:39 UTC, Szymon Gatner wrote: I want to keep a list of pointers-to-C-struct but this line: cpBody* cpBodies_[]; which I use as a workaround. I am using DMD 2.065. cpBody*[] cpBodies;

Re: getopt example please

2014-02-26 Thread Tobias Pankrath
On Wednesday, 26 February 2014 at 09:57:19 UTC, Andrew Edwards wrote: Request a small example of how to use getopt to accomplish the following: [1] program subcommand //process subcommand with default arguments if any [2] program -h subcommand //output help information about subcommand [3] pr

Re: Array of struct pointers error

2014-02-26 Thread Tobias Pankrath
On Wednesday, 26 February 2014 at 09:56:39 UTC, Szymon Gatner wrote: I want to keep a list of pointers-to-C-struct but this line: cpBody* cpBodies_[]; which I use as a workaround. I am using DMD 2.065. cpBody*[] cpBodies;

Array of struct pointers error

2014-02-26 Thread Szymon Gatner
I want to keep a list of pointers-to-C-struct but this line: cpBody* cpBodies_[]; cpBodies_ ~= cpBodyNew(0, 0); gives: Error 1 Error 42: Symbol Undefined _D5dchip6cpBody6cpBody11__xopEqualsFKxS5dchip6cpBody6cpBodyKxS5dchip6cpBody6cpBodyZb (bool dchip.cpBody.cpBody.__xopEquals(ref const(d

getopt example please

2014-02-26 Thread Andrew Edwards
Request a small example of how to use getopt to accomplish the following: [1] program subcommand //process subcommand with default arguments if any [2] program -h subcommand //output help information about subcommand [3] program subcommand --option1 --option2 true option3=log.txt // process subc

Re: Allocating and freeing memory like this?

2014-02-26 Thread Mike
On Wednesday, 26 February 2014 at 09:14:42 UTC, Bienlein wrote: Hello, ich found this article on the Internet that explains how to do malloc and free in D: http://fgda.pl/post/8/a-look-at-the-d-programming-language See the functions named _new and _delete. My question is whether this is real

Re: Allocating and freeing memory like this?

2014-02-26 Thread Stanislav Blinov
On Wednesday, 26 February 2014 at 09:14:42 UTC, Bienlein wrote: A similar approach is already employed in phobos, see http://dlang.org/phobos/std_typecons.html#.scoped The article confused me. Is the contents outdated or am I messing something up? Regarding keywords new and delete: http://

Re: Allocating and freeing memory like this?

2014-02-26 Thread Tolga Cakiroglu
I noticed that the `delete` function is not in that link. Anyway, there are some discussions about the `delete` function already. http://forum.dlang.org/thread/bmipphidczppnllpi...@forum.dlang.org#post-mailman.1327.1351300092.5162.digitalmars-d-learn:40puremagic.com On Wednesday, 26 February 20

Re: Allocating and freeing memory like this?

2014-02-26 Thread Tolga Cakiroglu
I can't remember where I read it though, in documentation probably, the `free` function calls the `delete` function as well, and it can be used to remove object from memory. Since there is garbage collector in the background already, you don't have to do it in this way (and I am not doing as w

Allocating and freeing memory like this?

2014-02-26 Thread Bienlein
Hello, ich found this article on the Internet that explains how to do malloc and free in D: http://fgda.pl/post/8/a-look-at-the-d-programming-language See the functions named _new and _delete. My question is whether this is really the way to allocate and free some memory for a class manually