Re: best D equivalent to C'stimeval

2014-03-30 Thread ed
On Monday, 31 March 2014 at 06:25:40 UTC, Jonathan M Davis wrote: On Monday, March 31, 2014 05:09:22 ed wrote: Hi, Just wondering what the best replacement for C timeval is in D. I'm looking at std.datetime.SysTime, but std.datetime is huge so I'm not sure. If you want an overview of std.da

Re: best D equivalent to C'stimeval

2014-03-30 Thread Jonathan M Davis
On Monday, March 31, 2014 05:09:22 ed wrote: > Hi, > > Just wondering what the best replacement for C timeval is in D. > I'm looking at std.datetime.SysTime, but std.datetime is huge so > I'm not sure. If you want an overview of std.datetime, read http://dlang.org/intro-to-datetime.html But yes

Re: Getting the current datetime converted into a string for writing to stdout

2014-03-30 Thread Jonathan M Davis
On Sunday, March 30, 2014 08:25:42 Andre Artus wrote: > Considering the international spread of D users I find it > surprising that the date & time formatting functions in phobos > are not localizable. If could go back, there wouldn't even be anything to localize. toSimpleString is there because

Re: destructor, postblit constructor --- force calling always

2014-03-30 Thread monarch_dodra
On Monday, 31 March 2014 at 01:03:22 UTC, Carl Sturtivant wrote: What about destructors, are they always called, or is this another optimization if the struct is in it's default .init state? AFAIK, a destructor is always called when an object goes out of scope... unless, it's being moved out

best D equivalent to C'stimeval

2014-03-30 Thread ed
Hi, Just wondering what the best replacement for C timeval is in D. I'm looking at std.datetime.SysTime, but std.datetime is huge so I'm not sure. Thanks, ed

Parsing

2014-03-30 Thread Joel
I've got a program that uses user input, but I'm having trouble with it. Here's an example, the unenclosed numbers (1 2 3 in example) add entries: 0 Achievement 1 2 3 c"Won!" st"4 5 6" <- user input (create 3 entries all with st"4 5 6") 0 Achievement 1 house [4, 5, 6] 2 rock [4, 5, 6] 3 mou

Re: Change forum password

2014-03-30 Thread evilrat
On Sunday, 30 March 2014 at 19:17:38 UTC, Carl Sturtivant wrote: I don't know where to ask this. How do I change the password associated with my use of this forum? the only way is to ask administrator.

Re: destructor, postblit constructor --- force calling always

2014-03-30 Thread Carl Sturtivant
D's structs don't have identity. That means, they can be moved without notice at any point in the program. AFAIK the compiler even does that when handling exceptions in a few cases (e.g. with structs on the stack). Having moveable value types allows for a lot of optimizations, both on the compi

Re: Template magic exercise

2014-03-30 Thread Frustrated
On Sunday, 30 March 2014 at 12:42:16 UTC, Jack Applegame wrote: Target is to create a template for mapping member "array accessor" to member function. For example: class Foo { ... int elementsAccessor(size_t index) { ... } ... mixin MagicTemplateMixin!("elements", elementsAccessor);

Re: Template magic exercise

2014-03-30 Thread Artur Skawina
On 03/30/14 15:36, Jack Applegame wrote: > Wraper structure again. Is there solution without it? No. D only allows op overloading in structs/unions/classes, so one of those will be necessary. The simpliest solution would be something like: class C { int elementsAccessor(size_t index) { .

Avoiding Range Checks in Slice Expressions

2014-03-30 Thread Nordlöw
Does DMD currently avoid range checks in array slice expressions such as f(x[0..$/2]) f(x[$/2..$]) typically found in divide-and-conquer algorithms such as quicksort? If not, what would it require to implement it?

Re: Avoiding Range Checks in Slice Expressions

2014-03-30 Thread bearophile
Nordlöw: Does DMD currently avoid range checks in array slice expressions such as f(x[0..$/2]) f(x[$/2..$]) You have two simple ways to answer your question: try to go past the slices and look if D raises an error, and look at the asm produced with various compiler switches. Bye, bearoph

Re: destructor, postblit constructor --- force calling always

2014-03-30 Thread Benjamin Thaut
Am 30.03.2014 21:35, schrieb Carl Sturtivant: Context: struct values that are (non-ref) parameters & local variables. Is there a way to arrange that a particular struct's special constructors (postblit,destructor) should always be called even on move, or on destruction of a default initialized

destructor, postblit constructor --- force calling always

2014-03-30 Thread Carl Sturtivant
Context: struct values that are (non-ref) parameters & local variables. Is there a way to arrange that a particular struct's special constructors (postblit,destructor) should always be called even on move, or on destruction of a default initialized value, temporary or not, etcetera, i.e. en

Change forum password

2014-03-30 Thread Carl Sturtivant
I don't know where to ask this. How do I change the password associated with my use of this forum?

Re: Does anyone have an example of use of core.sync.Condition

2014-03-30 Thread Jack Applegame
On Sunday, 30 March 2014 at 16:09:37 UTC, Matt wrote: I have little experience in multi-threading programming, and was digging into std.concurrency, but I don't really understand the Condition class as it was used there. Could someone provide a bare-bones use of this class? I would be much obli

Re: Does anyone have an example of use of core.sync.Condition

2014-03-30 Thread Ali Çehreli
On 03/30/2014 09:09 AM, Matt wrote: I have little experience in multi-threading programming, and was digging into std.concurrency, but I don't really understand the Condition class as it was used there. Could someone provide a bare-bones use of this class? I would be much obliged, thanks. I hav

Re: Does anybody have an example of overloading a function to accept char[] or string parameter

2014-03-30 Thread bearophile
Gary Miller: char[] ReplaceAllSubstrings(inout char[] Original, in char[] SearchString, in char[] Substring) { string SOriginal = Original.dup; string SSearchString = SearchString.dup;

Re: Getting a class' name, but not fully qualified?

2014-03-30 Thread Dicebot
On Sunday, 30 March 2014 at 16:42:54 UTC, Matt wrote: On Sunday, 30 March 2014 at 16:33:47 UTC, Dicebot wrote: This is not explicitly mentioned anywhere because "runtime type information" (http://dlang.org/phobos/object.html#.Classinfo) is a wide-spread term with strong meaning. what about .

Re: Getting a class' name, but not fully qualified?

2014-03-30 Thread Matt
On Sunday, 30 March 2014 at 16:33:47 UTC, Dicebot wrote: This is not explicitly mentioned anywhere because "runtime type information" (http://dlang.org/phobos/object.html#.Classinfo) is a wide-spread term with strong meaning. what about .stringof? I don't think it mentions about the fact that

Re: Getting a class' name, but not fully qualified?

2014-03-30 Thread Dicebot
On Sunday, 30 March 2014 at 16:26:48 UTC, Matt wrote: On Friday, 28 March 2014 at 13:38:01 UTC, Dicebot wrote: .classinfo name is name for actual class instance referenced from the variable it was applied to. It happens to be fully qualified but key difference here is that it uses RTTI (run-t

Re: Getting a class' name, but not fully qualified?

2014-03-30 Thread Matt
On Friday, 28 March 2014 at 13:38:01 UTC, Dicebot wrote: .classinfo name is name for actual class instance referenced from the variable it was applied to. It happens to be fully qualified but key difference here is that it uses RTTI (run-time type information) to access "real" type of polymor

Does anyone have an example of use of core.sync.Condition

2014-03-30 Thread Matt
I have little experience in multi-threading programming, and was digging into std.concurrency, but I don't really understand the Condition class as it was used there. Could someone provide a bare-bones use of this class? I would be much obliged, thanks.

Re: Does anybody have an example of overloading a function to accept char[] or string parameter

2014-03-30 Thread evilrat
On Sunday, 30 March 2014 at 15:58:52 UTC, Gary Miller wrote: Are there any alternate libraries for D that have a mutable string datatype or is there a way to override the immutable characteristic of the string datatype by reallocating it or something? string.dup property does a copy of origi

Does anybody have an example of overloading a function to accept char[] or string parameter

2014-03-30 Thread Gary Miller
In a lot of my string manipulation functions I need the flexibility of passing a string but other times I need to pass a char[] so that I can change the contents of the string in the function. Because the string data type is immutable I get errors if I pass it as a parameter and try to chang

Re: Template magic exercise

2014-03-30 Thread Jack Applegame
Wraper structure again. Is there solution without it?

Re: scanner parser generator

2014-03-30 Thread needs
thanks i take a look at it. actually i thought along the lines of antlr or coo/r. On Sunday, 30 March 2014 at 13:20:49 UTC, evilrat wrote: On Sunday, 30 March 2014 at 13:08:08 UTC, needs wrote: hi, i need a scanner parser generator that generates d code. i found abandoned, primitive and d1 pr

Re: Template magic exercise

2014-03-30 Thread anonymous
On Sunday, 30 March 2014 at 12:42:16 UTC, Jack Applegame wrote: Target is to create a template for mapping member "array accessor" to member function. For example: class Foo { ... int elementsAccessor(size_t index) { ... } ... mixin MagicTemplateMixin!("elements", elementsAccessor);

Re: scanner parser generator

2014-03-30 Thread evilrat
On Sunday, 30 March 2014 at 13:08:08 UTC, needs wrote: hi, i need a scanner parser generator that generates d code. i found abandoned, primitive and d1 projects. is there something one can use with the current version and -m64? regards pegged? http://code.dlang.org

scanner parser generator

2014-03-30 Thread needs
hi, i need a scanner parser generator that generates d code. i found abandoned, primitive and d1 projects. is there something one can use with the current version and -m64? regards

Re: Template magic exercise

2014-03-30 Thread Jack Applegame
Sorry. Not "getter", should be "elementsAccessor" instead.

Template magic exercise

2014-03-30 Thread Jack Applegame
Target is to create a template for mapping member "array accessor" to member function. For example: class Foo { ... int elementsAccessor(size_t index) { ... } ... mixin MagicTemplateMixin!("elements", elementsAccessor); // or better alias elements = SuperMagicTemplate!elementsAccess

Re: Interfacing C++ to D --> or better: C++ --> C ---> D (DLL)

2014-03-30 Thread evilrat
On Sunday, 30 March 2014 at 11:16:16 UTC, BeschBesch wrote: have you looked at exported symbols in dll? it may be C++ from what you said(lib not designed for C++?), so you can try extern(C++) on D side instead extern(C). or add manually #ifdef __cplusplus and extern "C" on lib side(if its not t

Re: Interfacing C++ to D --> or better: C++ --> C ---> D (DLL)

2014-03-30 Thread BeschBesch
have you looked at exported symbols in dll? it may be C++ from what you said(lib not designed for C++?), so you can try extern(C++) on D side instead extern(C). or add manually #ifdef __cplusplus and extern "C" on lib side(if its not that big of course). First of all: I started with a C++-dll

Re: Getting the current datetime converted into a string for writing to stdout

2014-03-30 Thread Andre Artus
On Saturday, 29 March 2014 at 05:01:14 UTC, Gary Miller wrote: -- SNIP -- I only need it down to the second and from my current machine so I don't need to use any of the more accurate clocks used for benchmarking right now. On Saturday, 29 March 2014 at 09:30:44 UTC, Gary Willoughby wrote:

Re: Interfacing C++ to D --> or better: C++ --> C ---> D (DLL)

2014-03-30 Thread evilrat
On Saturday, 29 March 2014 at 15:03:18 UTC, BeschBesch wrote: I want to use a set of functions that rely on a library which is not available for D (Harfbuzz). So I just wrote myself a set a functions that will do anything I need (Init, Free, Fonts, Text, etc). The DLL is working fine and dyna