Re: Properties don't work as expected

2016-07-06 Thread zodd via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 09:48:59 UTC, Lodovico Giaretta wrote: Nice work. Personally, I'd do it this way: http://pastebin.com/38n0fEtF This way: - instead of 4 pointers (2 per delegate), the wrapper only contains 1 pointer; - once written, it only requires one line per property to be

Re: How to get current time as long or ulong?

2016-07-06 Thread yawniek via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 18:16:31 UTC, Charles Hixson wrote: What I'm looking for is the opposite of the "FromUnixTime" function. i often use long toNsUnixTime(SysTime t) { return (t.stdTime - 621_355_968_000_000_000L)*100; } as a helper. any chance that something like this can be put

Re: Asynchronous Programming and Eventhandling in D

2016-07-06 Thread Eugene Wissner via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 08:39:03 UTC, chmike wrote: On Tuesday, 5 July 2016 at 20:38:53 UTC, Eugene Wissner wrote: On Tuesday, 5 July 2016 at 08:24:43 UTC, O/N/S wrote: Hi ("Grüss Gott") I like the asynchronous events in Javascript. Is something similar possible in D? Found Dragos

Go’s march to low-latency GC

2016-07-06 Thread chmike via Digitalmars-d-learn
In case you missed it https://blog.twitch.tv/gos-march-to-low-latency-gc-a6fa96f06eb7#.emwja62y1

Re: How to get current time as long or ulong?

2016-07-06 Thread H. S. Teoh via Digitalmars-d-learn
On Wed, Jul 06, 2016 at 10:19:19AM -0700, Charles Hixson via Digitalmars-d-learn wrote: [...] > The same time needs to be used for two different purposes (or I have > to keep two separate times). One time is used during a particular run > of the program to compare when two different things

Re: Asynchronous Programming and Eventhandling in D

2016-07-06 Thread Eugene Wissner via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 14:57:08 UTC, chmike wrote: On Wednesday, 6 July 2016 at 11:33:53 UTC, Eugene Wissner wrote: The only reason libev was choosen is that it is the simplest implementation I know about. A few C files. I had an educational purpose: I wanted to see how an event loop

Re: How to get current time as long or ulong?

2016-07-06 Thread Charles Hixson via Digitalmars-d-learn
On 07/06/2016 10:32 AM, H. S. Teoh via Digitalmars-d-learn wrote: On Wed, Jul 06, 2016 at 10:19:19AM -0700, Charles Hixson via Digitalmars-d-learn wrote: [...] The same time needs to be used for two different purposes (or I have to keep two separate times). One time is used during a

Re: Typesafe variadic functions requiring at least one argument

2016-07-06 Thread kinke via Digitalmars-d-learn
In case you want a compile error if no arguments are specified, you can use something like this: void foo()() { static assert(0); } void foo(int[] ints...) { assert(ints); } void main() { foo(1, 2, 3); foo(); }

Typesafe variadic functions requiring at least one argument

2016-07-06 Thread pineapple via Digitalmars-d-learn
I'd like to do something like this but it doesn't seem to be legal - void test(int[] ints...) if(ints.length){ // stuff } Not being able to specify this interferes with how I'd like to define my method overloads. What's the best way to achieve what I'm looking for?

Endiannes & Splitting Values

2016-07-06 Thread BitGuy via Digitalmars-d-learn
I'm trying to implement a feistel cipher that'll give the same results regardless of the endianness of the machine it runs on. To make the cipher I need to split a 64bit value into two 32bit values, mess with them, and then put them back together. I can think of a few ways to split a 64bit

Re: Typesafe variadic functions requiring at least one argument

2016-07-06 Thread kinke via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 19:50:11 UTC, pineapple wrote: I'd like to do something like this but it doesn't seem to be legal - void test(int[] ints...) if(ints.length){ // stuff } Not being able to specify this interferes with how I'd like to define my method overloads.

Re: Endiannes & Splitting Values

2016-07-06 Thread Alex Parrill via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 21:44:37 UTC, BitGuy wrote: I'm trying to implement a feistel cipher that'll give the same results regardless of the endianness of the machine it runs on. To make the cipher I need to split a 64bit value into two 32bit values, mess with them, and then put them back

Re: Properties don't work as expected

2016-07-06 Thread ketmar via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 10:25:44 UTC, zodd wrote: Thank you for a great example! D's power still surprises me a lot. just be careful to not carry wrapper around for too long, so it won't outlive it's parent. p.s. or this (abomination, i know!). ripped out of one of my monkeycoding

Re: Endiannes & Splitting Values

2016-07-06 Thread Lodovico Giaretta via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 21:44:37 UTC, BitGuy wrote: I'm trying to implement a feistel cipher that'll give the same results regardless of the endianness of the machine it runs on. To make the cipher I need to split a 64bit value into two 32bit values, mess with them, and then put them back

Re: Go’s march to low-latency GC

2016-07-06 Thread Jack Stouffer via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 16:58:45 UTC, chmike wrote: In case you missed it https://blog.twitch.tv/gos-march-to-low-latency-gc-a6fa96f06eb7#.emwja62y1 This should have been posted in General.

Re: Asynchronous Programming and Eventhandling in D

2016-07-06 Thread chmike via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 11:33:53 UTC, Eugene Wissner wrote: The only reason libev was choosen is that it is the simplest implementation I know about. A few C files. I had an educational purpose: I wanted to see how an event loop works on low level. Asyncio was for me no-go, since I've

Re: Build a SysTime from a string

2016-07-06 Thread Andrea Fontana via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 14:55:51 UTC, Jonathan M Davis wrote: auto st = SysTime.fromISOExtString("2011-03-02T15:30:00+01:00"); That's perfect. I didn't notice that static method. My fault!

Re: How to get current time as long or ulong?

2016-07-06 Thread Charles Hixson via Digitalmars-d-learn
On 07/05/2016 05:23 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Tuesday, July 05, 2016 12:51:54 Charles Hixson via Digitalmars-d-learn wrote: On 07/05/2016 11:43 AM, Jonathan M Davis via Digitalmars-d-learn wrote: On Tuesday, July 05, 2016 11:16:31 Charles Hixson via

Re: Build a SysTime from a string

2016-07-06 Thread Jack Stouffer via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 15:38:00 UTC, Andrea Fontana wrote: On Wednesday, 6 July 2016 at 14:55:51 UTC, Jonathan M Davis wrote: auto st = SysTime.fromISOExtString("2011-03-02T15:30:00+01:00"); That's perfect. I didn't notice that static method. My fault! Also, if you need to parse other

Re: Typesafe variadic functions requiring at least one argument

2016-07-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 06, 2016 19:50:11 pineapple via Digitalmars-d-learn wrote: > I'd like to do something like this but it doesn't seem to be > legal - > > void test(int[] ints...) if(ints.length){ > // stuff > } > > Not being able to specify this interferes with how I'd like to

Re: Build a SysTime from a string

2016-07-06 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, July 06, 2016 14:15:22 Andrea Fontana via Digitalmars-d-learn wrote: > Ok, I have a string like: > 2011-03-02T15:30:00+01:00 > > I need to convert it in a SysTime object. > > My problem is that from documentation I can't understand how to > set +01:00 timezone on systime. I guess

Build a SysTime from a string

2016-07-06 Thread Andrea Fontana via Digitalmars-d-learn
Ok, I have a string like: 2011-03-02T15:30:00+01:00 I need to convert it in a SysTime object. My problem is that from documentation I can't understand how to set +01:00 timezone on systime. I guess I'm missing something... Andrea

Re: Build a SysTime from a string

2016-07-06 Thread Dejan Lekic via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 14:15:22 UTC, Andrea Fontana wrote: My problem is that from documentation I can't understand how to set +01:00 timezone on systime. I guess I'm missing something... As far as I know, you can't do that. Quote from the documentation: """ Unlike DateTime, the time

Re: Build a SysTime from a string

2016-07-06 Thread Andrea Fontana via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 14:19:56 UTC, Dejan Lekic wrote: On Wednesday, 6 July 2016 at 14:15:22 UTC, Andrea Fontana wrote: My problem is that from documentation I can't understand how to set +01:00 timezone on systime. I guess I'm missing something... As far as I know, you can't do that.

Re: Asynchronous Programming and Eventhandling in D

2016-07-06 Thread rikki cattermole via Digitalmars-d-learn
On 06/07/2016 8:39 PM, chmike wrote: On Tuesday, 5 July 2016 at 20:38:53 UTC, Eugene Wissner wrote: On Tuesday, 5 July 2016 at 08:24:43 UTC, O/N/S wrote: Hi ("Grüss Gott") I like the asynchronous events in Javascript. Is something similar possible in D? Found Dragos Carp's asynchronous

Re: Properties don't work as expected

2016-07-06 Thread zodd via Digitalmars-d-learn
So, I've created a simple wrapper template to achieve what I want. It reminds me of the C++ - a bunch of additional code to solve a simple problem (which shouldn't be an issue at all). I'm a newbie in D thus I could do something wrong or nonoptimal. Please, criticize my code:

Re: Asynchronous Programming and Eventhandling in D

2016-07-06 Thread chmike via Digitalmars-d-learn
On Tuesday, 5 July 2016 at 20:38:53 UTC, Eugene Wissner wrote: On Tuesday, 5 July 2016 at 08:24:43 UTC, O/N/S wrote: Hi ("Grüss Gott") I like the asynchronous events in Javascript. Is something similar possible in D? Found Dragos Carp's asynchronous library

Re: Properties don't work as expected

2016-07-06 Thread ketmar via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 05:51:04 UTC, Ola Fosheim Grøstad wrote: Maybe you could give me an useful example in D that does not involve «static if» or «string mixins» that would be difficult to represent in C++? anything involving templates. c++ template syntax is awful.

Re: Properties don't work as expected

2016-07-06 Thread Lodovico Giaretta via Digitalmars-d-learn
On Wednesday, 6 July 2016 at 09:08:11 UTC, zodd wrote: So, I've created a simple wrapper template to achieve what I want. It reminds me of the C++ - a bunch of additional code to solve a simple problem (which shouldn't be an issue at all). I'm a newbie in D thus I could do something wrong or