Re: A little of coordination for Rosettacode

2013-06-18 Thread Simen Kjaeraas
On 2013-06-18, 05:00, bearophile wrote: With your code I have found a dmd compiler bug, are you able and willing to further reduce this? Tried this with 2.063.2, and there are three errors in the code - deserializeInto should return its buffer, the switch on line 19 needs a default: case,

Re: Finalize GC memory

2013-06-18 Thread Namespace
I'd be worried about whether it actually called the destructors of the members of the struct. IIRC, you actually have to play around with TypeInfo in order to be able to correctly manually destroy a struct rather than simply calling its __dtor method, but it's not something that I ever do, so I

Re: D slicing

2013-06-18 Thread Colin Grogan
On Monday, 17 June 2013 at 23:48:36 UTC, Ali Çehreli wrote: On 06/17/2013 04:34 PM, Colin Grogan wrote: Wondering what way I'd go about this, I want to slice an array into two arrays. First array containing every even index (i.e. 0,2,4,6,8..$) Second slice containing every odd index (i.e.

Re: Finalize GC memory

2013-06-18 Thread Namespace
Here my new version: void Delete(T)(ref T var) if (isAssignable!(T, typeof(null)) !isStaticArray!T) { const bool isPtr = is(T : U*, U); static if (isPtr (is(U == struct) || is(U == class))) .destroy(*var); static if (is(T : U[], U))

Re: AnalyzeD

2013-06-18 Thread qznc
On Tuesday, 18 June 2013 at 00:20:38 UTC, Andrej Mitrovic wrote: On Thursday, 30 May 2013 at 08:26:01 UTC, bioinfornatics wrote: hi Someone know if AnalyzeD could to be used from command line ? i.e http://dconf.org/talks/rohe.html I failed to find AnalyzeD source code thanks I think it's

Re: Finalize GC memory

2013-06-18 Thread bearophile
Namespace: Here my new version: void Delete(T)(ref T var) if (isAssignable!(T, typeof(null)) !isStaticArray!T) { ... That should fulfill all wishes. :) Its name should start with a lowercase, according to the D style. Bye, bearophile

Re: Finalize GC memory

2013-06-18 Thread Namespace
On Tuesday, 18 June 2013 at 09:16:05 UTC, bearophile wrote: Namespace: Here my new version: void Delete(T)(ref T var) if (isAssignable!(T, typeof(null)) !isStaticArray!T) { ... That should fulfill all wishes. :) Its name should start with a lowercase, according to the D style.

Re: A little of coordination for Rosettacode

2013-06-18 Thread bearophile
Simen Kjaeraas: Tried this with 2.063.2, and there are three errors in the code - deserializeInto should return its buffer, the switch on line 19 needs a default: case, and deserializeInto tries to modify its non-buffer argument (which in this case is a const string. None of these seem to be

Re: Finalize GC memory

2013-06-18 Thread Namespace
Just for you: http://dpaste.1azy.net/3b46c669 This code works now perfect and works also with forward referenced opaque structures.

Re: How to expand an expression along with a parameter tuple?

2013-06-18 Thread Artur Skawina
On 06/18/13 03:51, TommiT wrote: On Monday, 17 June 2013 at 13:59:34 UTC, Artur Skawina wrote: struct _ForEach(alias MAP, TS...) { NTup!(TS.length, typeof(MAP(TS[0].init))) tuple; this(TS values) { foreach (i, ref v; values) tuple[i] = MAP(v); }

Re: How to expand an expression along with a parameter tuple?

2013-06-18 Thread bearophile
Artur Skawina: slicing a struct does not (and can not) produce an auto-expanding tuple, unless I'm missing some recent language change... Sorry, I have misunderstood the type, the [] works on typetuples. Bye, bearophile

Re: How to expand an expression along with a parameter tuple?

2013-06-18 Thread TommiT
On Tuesday, 18 June 2013 at 10:57:00 UTC, Artur Skawina wrote: On 06/18/13 03:51, TommiT wrote: Change the call to bar(1, 3L); and it wouldn't even compile. It's because all the types of _ForEach.tuple are the same as the first element of TS... I mean... the same as the type of MAP(TS[0])

Re: make Pid constructor public

2013-06-18 Thread Steven Schveighoffer
On Mon, 17 Jun 2013 18:38:34 -0400, Timothee Cour thelastmamm...@gmail.com wrote: inside std.process it says: // Pids are only meant to be constructed inside this module, so we make the constructor private. However, this makes a number of useful functions from std.process useless unless

Re: can we detect at compile time module ctor/dtor cycles ?

2013-06-18 Thread Steven Schveighoffer
On Mon, 17 Jun 2013 21:19:57 -0400, Timothee Cour thelastmamm...@gmail.com wrote: I understand your point, however I argued above that we should run a test at compile time to detect cycles. It won't catch all cycles (because of certain di files), but it will catch most of them (at least all

Re: Finalize GC memory

2013-06-18 Thread Steven Schveighoffer
On Tue, 18 Jun 2013 03:59:37 -0400, Namespace rswhi...@googlemail.com wrote: I'd be worried about whether it actually called the destructors of the members of the struct. IIRC, you actually have to play around with TypeInfo in order to be able to correctly manually destroy a struct rather

Re: Finalize GC memory

2013-06-18 Thread Namespace
Be careful what hidden members you call, some of them are not what you think they are. For example? As a guide, you should take a look at the destroy function in object to see the proper method of destroying things. -Steve

Re: Finalize GC memory

2013-06-18 Thread Steven Schveighoffer
On Tue, 18 Jun 2013 09:34:44 -0400, Namespace rswhi...@googlemail.com wrote: Be careful what hidden members you call, some of them are not what you think they are. For example? For example, __dtor may not be the full destructor, but just the code represented by ~this(). I think this is

Re: Example on how to spawn a thread using a class method?

2013-06-18 Thread Gary Willoughby
Ah right, so you use a function as a wrapper around the delegate. Thanks.

Re: Can someone give me a little program design advice please?

2013-06-18 Thread Gary Willoughby
Interesting thanks.

Re: GC dead-locking ?

2013-06-18 Thread Marco Leise
Am Mon, 17 Jun 2013 10:46:19 -0700 schrieb Sean Kelly s...@invisibleduck.org: On Jun 13, 2013, at 2:22 AM, Marco Leise marco.le...@gmx.de wrote: Here is an excerpt from a stack trace I got while profiling with OProfile: #0 sem_wait () from /lib64/libpthread.so.0 #1

Re: A little of coordination for Rosettacode

2013-06-18 Thread Adam D. Ruppe
On Tuesday, 18 June 2013 at 09:22:05 UTC, bearophile wrote: third is the one that triggers a crash of my DMD version. I am keeping my compiler updated, I have compiled it yesterday, and it crashes after giving the error: test.d(28): Error: cannot modify const expression s Now I don't know if

Re: A little of coordination for Rosettacode

2013-06-18 Thread bearophile
Adam D. Ruppe: I can't reproduce the compiler crash you saw though. Thank you. Then it's somehow just my compiler... Bye, bearophile

Re: can we detect at compile time module ctor/dtor cycles ?

2013-06-18 Thread Timothee Cour
On Tue, Jun 18, 2013 at 6:01 AM, Steven Schveighoffer schvei...@yahoo.comwrote: On Mon, 17 Jun 2013 21:19:57 -0400, Timothee Cour thelastmamm...@gmail.com wrote: I understand your point, however I argued above that we should run a test at compile time to detect cycles. It won't catch all

Tips on making regex more performant?

2013-06-18 Thread Gary Willoughby
Below is an example snippet of code to test for performance of regex matches. I need to parse a large log and extract data from it and i've noticed a huge increase in time of the loop when reading and using regex. ... auto alert = regex(r^Alert ([0-9]+)); while ((line

Re: Tips on making regex more performant?

2013-06-18 Thread 1100110
On 06/18/2013 01:53 PM, Gary Willoughby wrote: Below is an example snippet of code to test for performance of regex matches. I need to parse a large log and extract data from it and i've noticed a huge increase in time of the loop when reading and using regex. ... auto alert =

Re: Tips on making regex more performant?

2013-06-18 Thread Gary Willoughby
enum alert = ctRegex!r^Alert ([0-9]+); And then use it the same way. Thanks. Hmmm.. i get 500K (worse performance) using that. :/ Any more tips?

how to compare immutable ints?

2013-06-18 Thread Charles Hixson
(Sorry if this double posts. I'm having trouble getting through at all.) How should I compare immutable ints to ensure that they are actually equal? I was quite surprised to receive the following error message: cbt2.d(732): Error: function object.Object.opEquals (Object o) is not callable

Re: how to compare immutable ints?

2013-06-18 Thread Steven Schveighoffer
On Tue, 18 Jun 2013 15:37:44 -0400, Charles Hixson charleshi...@earthlink.net wrote: (Sorry if this double posts. I'm having trouble getting through at all.) How should I compare immutable ints to ensure that they are actually equal? I was quite surprised to receive the following error

Re: Tips on making regex more performant?

2013-06-18 Thread bearophile
Gary Willoughby: Any more tips? Try using the LDC2 compiler, with the ctRegex, and using the correct compilation flags (like ldmd2 -O -release -inline -noboundscheck). If that fails one solution is to write your own finite state machine where the state is encoded by the program counter,

Re: Tips on making regex more performant?

2013-06-18 Thread Jacob Carlborg
On 2013-06-18 21:22, Gary Willoughby wrote: Thanks. Hmmm.. i get 500K (worse performance) using that. :/ D has basically the fastest regular expression library/module. It's faster than V8. Any more tips? How about reading in larger chunks than single lines? -- /Jacob Carlborg

Re: Tips on making regex more performant?

2013-06-18 Thread Dmitry Olshansky
18-Jun-2013 22:53, Gary Willoughby пишет: Below is an example snippet of code to test for performance of regex matches. I need to parse a large log and extract data from it and i've noticed a huge increase in time of the loop when reading and using regex. ... auto alert =

Re: Tips on making regex more performant?

2013-06-18 Thread Dmitry Olshansky
18-Jun-2013 23:22, Gary Willoughby пишет: enum alert = ctRegex!r^Alert ([0-9]+); And then use it the same way. Thanks. Hmmm.. i get 500K (worse performance) using that. :/ My bet would be allocations are taking the bulk of time. Any chance to compile it with -profile? Any more tips?

Re: Tips on making regex more performant?

2013-06-18 Thread Dmitry Olshansky
19-Jun-2013 00:34, Jacob Carlborg пишет: On 2013-06-18 21:22, Gary Willoughby wrote: Thanks. Hmmm.. i get 500K (worse performance) using that. :/ D has basically the fastest regular expression library/module. It's faster than V8. As much as I'm appeased to hear this it's isn't simply

Error: cannot implicitly convert expression

2013-06-18 Thread Agustin
Hello!, i'm having a problem and i don't know how to fix it :(. /** * Define a common structure for any event. * * @author Wolftein wolft...@ghrum.org */ public class Event(T) { private bool cancelled_; private shared static HandlerList!T handler_; /**

std.process: how to process stdout chunk by chunk without waiting for process termination

2013-06-18 Thread Timothee Cour
I'd like to do the following: auto pipes = pipeShell(command, Redirect.stdout | Redirect.stderr); while(true){ version(A1) string line=pipes.stdout.readln; version(A2) auto line=pipes.stdout.readChunk(10); version(A3) auto line=pipes.stdout.readChar(); // do something with line

Re: Error: cannot implicitly convert expression

2013-06-18 Thread Agustin
On Tuesday, 18 June 2013 at 21:39:35 UTC, Agustin wrote: Hello!, i'm having a problem and i don't know how to fix it :(. /** * Define a common structure for any event. * * @author Wolftein wolft...@ghrum.org */ public class Event(T) { private bool cancelled_; private shared

Re: std.process: how to process stdout chunk by chunk without waiting for process termination

2013-06-18 Thread Steven Schveighoffer
On Tue, 18 Jun 2013 17:41:57 -0400, Timothee Cour thelastmamm...@gmail.com wrote: I'd like to do the following: auto pipes = pipeShell(command, Redirect.stdout | Redirect.stderr); while(true){ version(A1) string line=pipes.stdout.readln; version(A2) auto line=pipes.stdout.readChunk(10);

Is there a keyword to access the base class

2013-06-18 Thread Stephen Jones
I am trying to do this: import std.stdio; import std.conv; class Bar{ } class Foo : Bar{ int val = 10; } class Foos : Bar{ int val = 20; string str = some more memory; } void main(){ Bar[] bars; bars ~= new Foo(); bars ~= new Foos();

Re: Is there a keyword to access the base class

2013-06-18 Thread Ali Çehreli
On 06/18/2013 03:10 PM, Stephen Jones wrote: I am trying to do this: import std.stdio; import std.conv; class Bar{ } class Foo : Bar{ int val = 10; } class Foos : Bar{ int val = 20; string str = some more memory; } void main(){ Bar[] bars; bars ~= new Foo();

Re: Is there a keyword to access the base class

2013-06-18 Thread Stephen Jones
On Tuesday, 18 June 2013 at 22:15:51 UTC, Ali Çehreli wrote: On 06/18/2013 03:10 PM, Stephen Jones wrote: I am trying to do this: import std.stdio; import std.conv; class Bar{ } class Foo : Bar{ int val = 10; } class Foos : Bar{ int val = 20; string str = some more memory; }

Re: Error: cannot implicitly convert expression

2013-06-18 Thread Agustin
On Tuesday, 18 June 2013 at 21:43:17 UTC, Agustin wrote: On Tuesday, 18 June 2013 at 21:39:35 UTC, Agustin wrote: Hello!, i'm having a problem and i don't know how to fix it :(. /** * Define a common structure for any event. * * @author Wolftein wolft...@ghrum.org */ public class Event(T) {

Re: Is there a keyword to access the base class

2013-06-18 Thread Gary Willoughby
I iterated on Ali's solution with more OOP to demonstrate features you may find interesting. import std.stdio; interface IBar { @property int val(); } class Bar : IBar { protected int _val; @property int val() { return this._val; } }

Re: Is there a keyword to access the base class

2013-06-18 Thread Steven Schveighoffer
On Tue, 18 Jun 2013 18:10:49 -0400, Stephen Jones siwe...@gmail.com wrote: I know I can cast, but how do I know what base class each b in the foreach loop is? Just an FYI, you are using the wrong terminology. In this case, Bar is the base class, and Foo and Foos are the *derived*

Re: how to compare immutable ints?

2013-06-18 Thread Charles Hixson
3rd or 4th try: On 06/18/2013 12:40 PM, Steven Schveighoffer wrote: On Tue, 18 Jun 2013 15:37:44 -0400, Charles Hixson charleshi...@earthlink.net wrote: (Sorry if this double posts. I'm having trouble getting through at all.) How should I compare immutable ints to ensure that they are

Re: how to compare immutable ints?

2013-06-18 Thread Charles Hixson
2nd attempted reply: On 06/18/2013 12:40 PM, Steven Schveighoffer wrote: On Tue, 18 Jun 2013 15:37:44 -0400, Charles Hixson charleshi...@earthlink.net wrote: (Sorry if this double posts. I'm having trouble getting through at all.) How should I compare immutable ints to ensure that they are

Re: GC dead-locking ?

2013-06-18 Thread Sean Kelly
On Jun 18, 2013, at 7:01 AM, Marco Leise marco.le...@gmx.de wrote: Am Mon, 17 Jun 2013 10:46:19 -0700 schrieb Sean Kelly s...@invisibleduck.org: On Jun 13, 2013, at 2:22 AM, Marco Leise marco.le...@gmx.de wrote: Here is an excerpt from a stack trace I got while profiling with OProfile: