Re: getTid wrapper

2014-03-03 Thread Bienlein
On Tuesday, 4 March 2014 at 06:31:24 UTC, Timothee Cour wrote: that gives tid of spawned thread, not 'self'. The link you mentioned says it is stored in the special variable thisTid.

Re: Reading a string in binary mode

2014-03-03 Thread Christof Schardt
"bearophile" schrieb im Newsbeitrag news:qqcdemwimcylaizjy...@forum.dlang.org... > Christof Schardt: > >> By "trickery" I meant having to know about things like >> "import std.exception : assumeUnique" for this basic kind of task. > > Your function has signature (you use "ref" instead of "in" or

Re: How to build DMD on windows ?

2014-03-03 Thread Benjamin Thaut
Am 03.03.2014 21:49, schrieb Remo: On Monday, 3 March 2014 at 19:51:45 UTC, Benjamin Thaut wrote: Am 28.02.2014 21:14, schrieb Remo: How to build DMD on windows ? And then run all the test for it? README.md is pretty empty at the moment. Of course it is possible to wait for some Fixes in DMD c

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

2014-03-03 Thread Timothee Cour
On Fri, Feb 28, 2014 at 10:27 AM, Martin Nowak wrote: > On 02/26/2014 10:16 PM, Timothee Cour wrote: > >> 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 >>

Re: Final class and interface

2014-03-03 Thread Steven Schveighoffer
On Mon, 03 Mar 2014 21:48:16 -0500, Casper Færgemand wrote: Is there any loss in performance instantiating an interface variable as a final class implementing only that interface, as opposed to a class variable? You mean the difference between: final class C : I {...} // this I i = new

Final class and interface

2014-03-03 Thread Casper Færgemand
Is there any loss in performance instantiating an interface variable as a final class implementing only that interface, as opposed to a class variable?

Re: Disabling the Garbage Collector

2014-03-03 Thread Adam D. Ruppe
On Monday, 3 March 2014 at 12:23:49 UTC, Jeroen Bollen wrote: If I were to compile without linking to the garbage collector, what would and what wouldn't work in D? You can get almost everything to work, though some built-in features will need to be replaced/supplemented by library things and

Issus with DMD 2.065

2014-03-03 Thread Hertz
Ever since I installed the latest DMD 2.065 I cant seem to compile and run .d files anymore. I'm installing dmd using the .deb file on Ubuntu. When it is installed and I try to compile a .d file the console gives me this. cannot find source code for runtime library file 'object.d' dmd

Re: adding static return?

2014-03-03 Thread Stanislav Blinov
I don't get it. That should be a static assert, not static if. Why would you even add into your build order a module that will never be actually compiled? If anything, static assert will prevent dead imports while such "static return" will silently swallow them. How would you propose handlin

Re: GC.BlkAttr.FINALIZE

2014-03-03 Thread Namespace
It sounds suspicious. Clearly, you are not accessing a1 there, and clearly a1 is set before being used. Any chance to reduce it? -Steve I don't know. But I know that my little trick doesn't work in lifetime.d although it works locally. Here what I tried: import std.stdio; struct Foo

Re: std.algorithm.find and array of needles?

2014-03-03 Thread captaindet
On 2014-03-03 16:19, John Colvin wrote: On Monday, 3 March 2014 at 22:03:24 UTC, captaindet wrote: On 2014-03-03 14:58, John Colvin wrote: On Monday, 3 March 2014 at 19:35:53 UTC, captaindet wrote: std.algorithm.find has an overload that works with several needles: // phobos doc example: int[

Re: Reading a string in binary mode

2014-03-03 Thread bearophile
Christof Schardt: By "trickery" I meant having to know about things like "import std.exception : assumeUnique" for this basic kind of task. Your function has signature (you use "ref" instead of "in" or "out" because it performs read/write): void rw(ref string x) A string is a immutable(ch

adding static return?

2014-03-03 Thread Xavier Bigand
I thought it could be nice to have a static return. My Idea is to remove unnecessary bracket encapsulation made with some static if statements. It will works like this : module xxx.opengl; import buildSettings; // contains some global constants static if (renderMode == directX) return; .

Re: Reading a string in binary mode

2014-03-03 Thread Christof Schardt
"John Colvin" schrieb im Newsbeitrag news:zjsykclxreagfhqsq...@forum.dlang.org... > On Monday, 3 March 2014 at 22:22:06 UTC, Christof Schardt wrote: >> "John Colvin" schrieb im Newsbeitrag >> news:dyfkblqonigrtmkwt...@forum.dlang.org... >>> On Monday, 3 March 2014 at 21:44:16 UTC, Christof Schar

Re: Nobody understands templates?

2014-03-03 Thread Frustrated
On Monday, 3 March 2014 at 18:46:24 UTC, Chris wrote: On Monday, 3 March 2014 at 18:03:12 UTC, Frustrated wrote: On Sunday, 2 March 2014 at 11:47:39 UTC, Steve Teale wrote: On Sunday, 2 March 2014 at 10:05:05 UTC, Dicebot wrote: There is nothing wrong about not using templates. Almost any c

Re: GC.BlkAttr.FINALIZE

2014-03-03 Thread Steven Schveighoffer
On Mon, 03 Mar 2014 15:34:18 -0500, Namespace wrote: On Monday, 3 March 2014 at 18:36:56 UTC, Steven Schveighoffer wrote: On Mon, 03 Mar 2014 12:03:12 -0500, Namespace wrote: On Monday, 3 March 2014 at 02:44:09 UTC, Namespace wrote: It's working now, I get all my debug infos I need. Bu

Re: Nobody understands templates?

2014-03-03 Thread Chris
On Monday, 3 March 2014 at 19:32:51 UTC, Dicebot wrote: On Monday, 3 March 2014 at 18:46:24 UTC, Chris wrote: E.g. an algorithm that finds the first instance of something might be different for each type (string, char, int) and the "abstract" implementation has to differentiate internally (if

Re: Reading a string in binary mode

2014-03-03 Thread John Colvin
On Monday, 3 March 2014 at 22:22:06 UTC, Christof Schardt wrote: "John Colvin" schrieb im Newsbeitrag news:dyfkblqonigrtmkwt...@forum.dlang.org... On Monday, 3 March 2014 at 21:44:16 UTC, Christof Schardt wrote: I'm evaluating D and try to write a binary io class. I got stuck with strings:

Re: Reading a string in binary mode

2014-03-03 Thread Ali Çehreli
On 03/03/2014 02:25 PM, Christof Schardt wrote: > Thanks, Ali, this works. Yay! :) > book be equipped with a TOC and an index? Yes, all of that will happen after I get back to working on the book and its ever increasing list of to-dos. :) Ali

Re: Reading a string in binary mode

2014-03-03 Thread Christof Schardt
"Ali Çehreli" schrieb im Newsbeitrag news:lf2ude$1njf$1...@digitalmars.com... > On 03/03/2014 01:44 PM, Christof Schardt wrote:> I'm evaluating D and try > to write a binary io class. > > I got stuck with strings: > > > > void rw(ref string x) > > { > > if(_isWriting) > >

Re: Reading a string in binary mode

2014-03-03 Thread Christof Schardt
"John Colvin" schrieb im Newsbeitrag news:dyfkblqonigrtmkwt...@forum.dlang.org... > On Monday, 3 March 2014 at 21:44:16 UTC, Christof Schardt wrote: >> I'm evaluating D and try to write a binary io class. >> I got stuck with strings: >> >> void rw(ref string x) >> { >> if(_isWriti

Re: std.algorithm.find and array of needles?

2014-03-03 Thread John Colvin
On Monday, 3 March 2014 at 22:03:24 UTC, captaindet wrote: On 2014-03-03 14:58, John Colvin wrote: On Monday, 3 March 2014 at 19:35:53 UTC, captaindet wrote: std.algorithm.find has an overload that works with several needles: // phobos doc example: int[] a = [ 1, 4, 2, 3 ]; assert(find(a, [ 1

Re: Reading a string in binary mode

2014-03-03 Thread Ali Çehreli
On 03/03/2014 01:44 PM, Christof Schardt wrote:> I'm evaluating D and try to write a binary io class. > I got stuck with strings: > > void rw(ref string x) > { > if(_isWriting) > { > int size = x.length; > _f.rawWrite((&size)[0..1]); >

Re: Reading a string in binary mode

2014-03-03 Thread John Colvin
On Monday, 3 March 2014 at 21:44:16 UTC, Christof Schardt wrote: I'm evaluating D and try to write a binary io class. I got stuck with strings: void rw(ref string x) { if(_isWriting) { int size = x.length; _f.rawWrite((&size)[0..1]); _f

Re: std.algorithm.find and array of needles?

2014-03-03 Thread captaindet
On 2014-03-03 14:58, John Colvin wrote: On Monday, 3 March 2014 at 19:35:53 UTC, captaindet wrote: std.algorithm.find has an overload that works with several needles: // phobos doc example: int[] a = [ 1, 4, 2, 3 ]; assert(find(a, [ 1, 3 ], 4) == tuple([ 4, 2, 3 ], 2)); the function i want to

Reading a string in binary mode

2014-03-03 Thread Christof Schardt
I'm evaluating D and try to write a binary io class. I got stuck with strings: void rw(ref string x) { if(_isWriting) { int size = x.length; _f.rawWrite((&size)[0..1]); _f.rawWrite(x); } else { int size

Re: std.algorithm.find and array of needles?

2014-03-03 Thread John Colvin
On Monday, 3 March 2014 at 19:35:53 UTC, captaindet wrote: std.algorithm.find has an overload that works with several needles: // phobos doc example: int[] a = [ 1, 4, 2, 3 ]; assert(find(a, [ 1, 3 ], 4) == tuple([ 4, 2, 3 ], 2)); the function i want to write has to deal with variadic argumen

Re: How to build DMD on windows ?

2014-03-03 Thread Remo
On Monday, 3 March 2014 at 19:51:45 UTC, Benjamin Thaut wrote: Am 28.02.2014 21:14, schrieb Remo: How to build DMD on windows ? And then run all the test for it? README.md is pretty empty at the moment. Of course it is possible to wait for some Fixes in DMD compiler may be it could be faster j

Re: How to build DMD on windows ?

2014-03-03 Thread Namespace
On Monday, 3 March 2014 at 19:51:45 UTC, Benjamin Thaut wrote: Am 28.02.2014 21:14, schrieb Remo: How to build DMD on windows ? And then run all the test for it? README.md is pretty empty at the moment. Of course it is possible to wait for some Fixes in DMD compiler may be it could be faster j

Re: GC.BlkAttr.FINALIZE

2014-03-03 Thread Namespace
On Monday, 3 March 2014 at 18:36:56 UTC, Steven Schveighoffer wrote: On Mon, 03 Mar 2014 12:03:12 -0500, Namespace wrote: On Monday, 3 March 2014 at 02:44:09 UTC, Namespace wrote: It's working now, I get all my debug infos I need. But: I have absolutly no idea how to get the correct TypeInfo

Re: How to build DMD on windows ?

2014-03-03 Thread Benjamin Thaut
Am 28.02.2014 21:14, schrieb Remo: How to build DMD on windows ? And then run all the test for it? README.md is pretty empty at the moment. Of course it is possible to wait for some Fixes in DMD compiler may be it could be faster just to fix them by my self and then hope that the fix will be acc

std.algorithm.find and array of needles?

2014-03-03 Thread captaindet
std.algorithm.find has an overload that works with several needles: // phobos doc example: int[] a = [ 1, 4, 2, 3 ]; assert(find(a, [ 1, 3 ], 4) == tuple([ 4, 2, 3 ], 2)); the function i want to write has to deal with variadic arguments serving as needles. unfortunately, i failed trying to make

Re: Nobody understands templates?

2014-03-03 Thread Dicebot
On Monday, 3 March 2014 at 18:46:24 UTC, Chris wrote: E.g. an algorithm that finds the first instance of something might be different for each type (string, char, int) and the "abstract" implementation has to differentiate internally (if string > else if int > else if ...). But this is no longe

Re: Nobody understands templates?

2014-03-03 Thread Chris
On Monday, 3 March 2014 at 17:24:08 UTC, Dominikus Dittes Scherkl wrote: On Monday, 3 March 2014 at 16:40:09 UTC, Chris wrote: I'm always willing to use templates, but maybe in fact the use cases are limited. I have a class for html elements (that implements DOM functionality), and a class for

Re: Nobody understands templates?

2014-03-03 Thread Chris
On Monday, 3 March 2014 at 18:03:12 UTC, Frustrated wrote: On Sunday, 2 March 2014 at 11:47:39 UTC, Steve Teale wrote: On Sunday, 2 March 2014 at 10:05:05 UTC, Dicebot wrote: There is nothing wrong about not using templates. Almost any compile-time design can be moved to run-time and express

Re: GC.BlkAttr.FINALIZE

2014-03-03 Thread Steven Schveighoffer
On Mon, 03 Mar 2014 12:03:12 -0500, Namespace wrote: On Monday, 3 March 2014 at 02:44:09 UTC, Namespace wrote: It's working now, I get all my debug infos I need. But: I have absolutly no idea how to get the correct TypeInfo in rt_finalize2. The ClassInfo is identified by casting the void*

Re: Nobody understands templates?

2014-03-03 Thread Tobias Pankrath
On Monday, 3 March 2014 at 18:03:12 UTC, Frustrated wrote: If you don't attempt to use templates, even in example code, you won't get it. What I don't get in this discussion is that all those fine phobos examples are neglected. Yes, it is library code, but writef/formattedWrite/std.conv.to,

Re: Mutexes and locking

2014-03-03 Thread yazd
On Monday, 3 March 2014 at 08:18:04 UTC, alexhairyman wrote: On Monday, 3 March 2014 at 07:38:05 UTC, Ali Çehreli wrote: On 03/02/2014 10:38 PM, alexhairyman wrote: > I think I'm missing something big, but I'm having troubles with mutexes > (using in a parallel foreach loop somewhere else); Why

Re: Nobody understands templates?

2014-03-03 Thread Frustrated
On Sunday, 2 March 2014 at 11:47:39 UTC, Steve Teale wrote: On Sunday, 2 March 2014 at 10:05:05 UTC, Dicebot wrote: There is nothing wrong about not using templates. Almost any compile-time design can be moved to run-time and expressed in more common OOP form. And using tool you have mastery

Re: Disabling the Garbage Collector

2014-03-03 Thread bearophile
Anonymouse: To write tidy code? Much like const correctness, avoiding magic numbers and globals, not polluting namespace overly, only import what you need etc etc. In general avoiding the self initialization of the GC doesn't make your code more tidy. Totally not activating the GC is only f

Re: Nobody understands templates?

2014-03-03 Thread Dominikus Dittes Scherkl
On Monday, 3 March 2014 at 16:40:09 UTC, Chris wrote: I'm always willing to use templates, but maybe in fact the use cases are limited. I have a class for html elements (that implements DOM functionality), and a class for building trees with the tags. Of course, for html tags only string as a t

Re: Is it possible to elegantly craft a class that can be used as shared and as normal?

2014-03-03 Thread Stanislav Blinov
On Monday, 3 March 2014 at 16:42:10 UTC, Gary Willoughby wrote: class Test { private int number; public void setNumber(int newValue) { number = newValue; } public int getNumber() { return number; } } I nee

Re: GC.BlkAttr.FINALIZE

2014-03-03 Thread Namespace
On Monday, 3 March 2014 at 02:44:09 UTC, Namespace wrote: It's working now, I get all my debug infos I need. But: I have absolutly no idea how to get the correct TypeInfo in rt_finalize2. The ClassInfo is identified by casting the void* pointer to a void** and then cast this void** to ClassInf

Re: Is it possible to elegantly craft a class that can be used as shared and as normal?

2014-03-03 Thread Gary Willoughby
On Monday, 3 March 2014 at 12:07:15 UTC, Tolga Cakiroglu wrote: Have you got a small example? import std.stdio; class Test{ private int number; public void setNumber( int newValue ) shared{ number = newValue; } public int getNumber() shared{ return number; } } void main()

Re: Nobody understands templates?

2014-03-03 Thread Chris
On Sunday, 2 March 2014 at 18:59:23 UTC, Steve Teale wrote: On Sunday, 2 March 2014 at 15:23:03 UTC, H. S. Teoh wrote: This is a pretty good primer to templates: https://semitwist.com/articles/article/view/template-primer-in-d The trouble is with most of these tutorials that they off

Re: Disabling the Garbage Collector

2014-03-03 Thread Anonymouse
On Monday, 3 March 2014 at 01:48:23 UTC, bearophile wrote: Jeroen Bollen: Is there maybe a way to disable the garbage collector from running unless you explicitly call it? I often seem to ask silly questions, but why do you need that? Bye, bearophile To write tidy code? Much like const cor

2.065 and MacPorts

2014-03-03 Thread Russel Winder
MacPorts DMD is still 2.064. There appears to be a notice that the maintainer position for this port is "vacant". I have no knowledge of creating or updating ports so cannot really volunteer to do this myself, but it would be good if some people did. I would be happy to be involved if others were

Re: Disabling the Garbage Collector

2014-03-03 Thread Jeroen Bollen
On Monday, 3 March 2014 at 02:33:49 UTC, Adam D. Ruppe wrote: On Sunday, 2 March 2014 at 23:21:49 UTC, Jeroen Bollen wrote: Is there maybe a way to disable the garbage collector from running unless you explicitly call it? That's really the default. The GC in D runs if and only if you do a GC

Re: Is it possible to elegantly craft a class that can be used as shared and as normal?

2014-03-03 Thread Tolga Cakiroglu
Have you got a small example? import std.stdio; class Test{ private int number; public void setNumber( int newValue ) shared{ number = newValue; } public int getNumber() shared{ return number; } } void main(){ auto test = new Test(); (cast(shared)test).set

Re: Mutexes and locking

2014-03-03 Thread alexhairyman
On Monday, 3 March 2014 at 07:38:05 UTC, Ali Çehreli wrote: On 03/02/2014 10:38 PM, alexhairyman wrote: > I think I'm missing something big, but I'm having troubles with mutexes > (using in a parallel foreach loop somewhere else); Why do the trylocks > return true shouldn't they return false bec