Re: Tuple fields/types

2016-06-30 Thread Meta via Digitalmars-d-learn
On Thursday, 30 June 2016 at 21:53:42 UTC, Jordan Wilson wrote: Hello, For tuples, does the fieldNames property have a 1-1 correspondence with the Types property? It appears that way in my testing: alias MyData = Tuple!(string,"a",int,"b"); foreach (i, type; MyData.Types){ writeln

Re: Tuple fields/types

2016-06-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 30 June 2016 at 21:53:42 UTC, Jordan Wilson wrote: Hello, For tuples, does the fieldNames property have a 1-1 correspondence with the Types property? It appears that way in my testing: alias MyData = Tuple!(string,"a",int,"b"); foreach (i, type; MyData.Types){ writeln

Re: GTKD - CSS class color "flash" delay

2016-06-30 Thread TheDGuy via Digitalmars-d-learn
On Thursday, 30 June 2016 at 20:11:17 UTC, Mike Wey wrote: Is the complete source available some ware? Yes, here: http://pastebin.com/h0Nx1mL6

Get program stats at run time

2016-06-30 Thread Special opOps via Digitalmars-d-learn
How can I get the program stats at run time such as minimum and maximum amount of memory and cpu used, cpu architecture, os, etc?

Tuple fields/types

2016-06-30 Thread Jordan Wilson via Digitalmars-d-learn
Hello, For tuples, does the fieldNames property have a 1-1 correspondence with the Types property? It appears that way in my testing: alias MyData = Tuple!(string,"a",int,"b"); foreach (i, type; MyData.Types){ writeln (MyData.fieldNames[i]," ",type.stringof); // a string // b int

Re: Associative array of const items

2016-06-30 Thread Q. Schroll via Digitalmars-d-learn
On Thursday, 30 June 2016 at 17:08:45 UTC, Jonathan Marler wrote: Is there a way to have an associative array of const values? I thought it would have been: const(T)[K] map; map[x] = y; but the second line gives Error: cannot modify const expression. I would think that the const(T)[K] would

Re: Get current date and time with std.datetime

2016-06-30 Thread Luke Picardo via Digitalmars-d-learn
On Monday, 24 October 2011 at 15:29:41 UTC, Jonathan M Davis wrote: On Friday, October 07, 2011 19:58:12 Joel Christensen wrote: > http://d-programming-language.org/intro-to-datetime.html Thanks Jonathan, that helped I think, (haven't read it all, though). But I've got errors with some of the

Re: GTKD - CSS class color "flash" delay

2016-06-30 Thread Mike Wey via Digitalmars-d-learn
On 06/30/2016 08:53 AM, TheDGuy wrote: On Wednesday, 29 June 2016 at 10:41:21 UTC, TheDGuy wrote: I tried to debug a little and what i don't understand is, that i get two times 'blue' on the console, even though yellow and blue lit up but yellow stayed at the flash color: private void

Associative array of const items

2016-06-30 Thread Jonathan Marler via Digitalmars-d-learn
Is there a way to have an associative array of const values? I thought it would have been: const(T)[K] map; map[x] = y; but the second line gives Error: cannot modify const expression. I would think that the const(T)[K] would behave similarly to const(T)[], where you can modify the array,

Re: Cast vs Virtual Method vs TypeId?

2016-06-30 Thread QAston via Digitalmars-d-learn
On Thursday, 30 June 2016 at 00:25:53 UTC, Jonathan Marler wrote: I'd like to hear peoples thoughts on the various solutions for the following problem. Say you have some hierarchy of classes like: class GameObject { // ... } class Entity : GameObject { // ... } class Player : Entity {

Re: Cast vs Virtual Method vs TypeId?

2016-06-30 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 30 June 2016 at 00:27:57 UTC, rikki cattermole wrote: On 30/06/2016 12:25 PM, Jonathan Marler wrote: Assume you have a function that accepts a GameObject but does something special if that GameObject happens to be an instance of the Player class. How would you go about determining

Re: What's the secret to static class members

2016-06-30 Thread Dejan Lekic via Digitalmars-d-learn
On Thursday, 30 June 2016 at 01:11:09 UTC, Mike Parker wrote: I think it's safe to say this guy is just trolling and we can ignore him. I was about to say the same, Mike. He is either trolling, or genuinely did not even bother to learn some language basics...

Re: thread-safe shared field access

2016-06-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/30/16 10:10 AM, jj75607 wrote: For example I have a shared from different threads variable. What piece of code is correctly thread-safe? First: shared class A { shared(int) x; Note, no need to mark x shared. 'A' implicitly shares everything. void test1() {

thread-safe shared field access

2016-06-30 Thread jj75607 via Digitalmars-d-learn
For example I have a shared from different threads variable. What piece of code is correctly thread-safe? First: shared class A { shared(int) x; void test1() { x = 10; x += 5 writeln(x); } } Or second: import core.atomic; shared

Re: compilation error with shared ReadWriteMutex

2016-06-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/30/16 8:41 AM, jj75607 wrote: On Thursday, 30 June 2016 at 12:25:54 UTC, Steven Schveighoffer wrote: On 6/30/16 8:18 AM, jj75607 wrote: [...] You don't need to mark this shared, because the entire class is shared, all members are implicitly marked shared. [...] Thanks! Is this

Re: compilation error with shared ReadWriteMutex

2016-06-30 Thread jj75607 via Digitalmars-d-learn
On Thursday, 30 June 2016 at 12:25:54 UTC, Steven Schveighoffer wrote: On 6/30/16 8:18 AM, jj75607 wrote: [...] You don't need to mark this shared, because the entire class is shared, all members are implicitly marked shared. [...] Thanks! Is this a compilation only 'cast' with no

Re: opEquals on shared object

2016-06-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/30/16 8:30 AM, jj75607 wrote: On Thursday, 30 June 2016 at 12:21:03 UTC, Steven Schveighoffer wrote: On 6/30/16 6:26 AM, jj75607 wrote: Hello! I need to overload opEquals on shared class C shared class C { override bool opEquals(Object o) { return false; } } But compilation fails

Re: opEquals on shared object

2016-06-30 Thread jj75607 via Digitalmars-d-learn
On Thursday, 30 June 2016 at 12:21:03 UTC, Steven Schveighoffer wrote: On 6/30/16 6:26 AM, jj75607 wrote: Hello! I need to overload opEquals on shared class C shared class C { override bool opEquals(Object o) { return false; } } But compilation fails with the message: Error: function

Re: compilation error with shared ReadWriteMutex

2016-06-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/30/16 8:18 AM, jj75607 wrote: I wrote shared class with rwmutex import core.sync.rwmutex; shared class Shared { ReadWriteMutex rwmutex; int[] items; this() { rwmutex = new ReadWriteMutex(); } } But it fails with: Error: cannot implicitly

Re: opEquals on shared object

2016-06-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/30/16 6:26 AM, jj75607 wrote: Hello! I need to overload opEquals on shared class C shared class C { override bool opEquals(Object o) { return false; } } But compilation fails with the message: Error: function f700.C.opEquals does not override any function, did you mean to override

compilation error with shared ReadWriteMutex

2016-06-30 Thread jj75607 via Digitalmars-d-learn
I wrote shared class with rwmutex import core.sync.rwmutex; shared class Shared { ReadWriteMutex rwmutex; int[] items; this() { rwmutex = new ReadWriteMutex(); } } But it fails with: Error: cannot implicitly convert expression (new

Re: EnumToFlags

2016-06-30 Thread Basile B. via Digitalmars-d-learn
On Thursday, 30 June 2016 at 02:39:22 UTC, JS wrote: I created a type that makes working with flags much easier. Please review for issues and enhancements. It would be nice to simplify the value size code. [...] You can look at this, it's more or less the same concept:

opEquals on shared object

2016-06-30 Thread jj75607 via Digitalmars-d-learn
Hello! I need to overload opEquals on shared class C shared class C { override bool opEquals(Object o) { return false; } } But compilation fails with the message: Error: function f700.C.opEquals does not override any function, did you mean to override 'object.Object.opEquals'? What am I

Re: EnumToFlags

2016-06-30 Thread ag0aep6g via Digitalmars-d-learn
On 06/30/2016 04:39 AM, JS wrote: struct EnumToFlags(alias E) { import std.traits, std.conv, std.string, std.algorithm, std.array; static if (E.max < 8) alias vtype = ubyte; Convention says: Capitalize user-defined type names. So it should be "Vtype" or maybe "VType"

Re: Local fixed sized arrays

2016-06-30 Thread Johan Engelen via Digitalmars-d-learn
On Monday, 27 June 2016 at 21:58:04 UTC, "Smoke" Adams wrote: I'm in need of a way to create a local array that isn't GC'ed. It must be dynamic in the sense of setting the size at compile time but it will be used only in scope and only on structs. `alloca` is made for that purpose.

Re: GTKD - CSS class color "flash" delay

2016-06-30 Thread TheDGuy via Digitalmars-d-learn
On Wednesday, 29 June 2016 at 10:41:21 UTC, TheDGuy wrote: I tried to debug a little and what i don't understand is, that i get two times 'blue' on the console, even though yellow and blue lit up but yellow stayed at the flash color: private void letButtonsFlash(){ foreach(Button