DlangUI FileDialog not working

2016-05-02 Thread stunaep via Digitalmars-d-learn
FileDialog is showing a blank white window for me. Only tested on windows 7 so far, but if I run dmledit, the filedialog on there works fine. It's weird because I am using almost exactly the same code. Here is what it looks like http://i.imgur.com/qslu7tJ.png handleAction code:

How can I save a class use the RedBlackTree?

2016-05-02 Thread Dsby via Digitalmars-d-learn
this is the test Code: import std.container.rbtree; import std.stdio; class TClass { int i; } void main() { RedBlackTree!(TClass) list = new RedBlackTree!(TClass)(); auto t = new TClass(); list.insert(t); writeln("The rbtree length is ",list.length()); list.removeKey(t)

Re: Setting a list of values

2016-05-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/2/16 6:00 PM, sigod wrote: On Monday, 2 May 2016 at 10:15:04 UTC, Marc Schütz wrote: On Monday, 2 May 2016 at 08:46:31 UTC, Ali Çehreli wrote: [...] Warning (better: disallowing altogether) about `=>` directly followed by `{` should be enough to cover all cases. To express that you reall

Re: inferred size for static array initialization

2016-05-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/2/16 4:14 PM, Namespace wrote: I used it very often, but always assigned the result to an auto-type variable, never to a slice. Using auto is fine, but the slice should not happen if you are assigning slice to a local var. There is a bug report on this: https://issues.dlang.org/show_bug

Re: relative benefit of .reserve and .length

2016-05-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/2/16 5:57 PM, Eto Demerzel wrote: For example: auto invalid_tokens = uninitializedArray!(string[])(result.failure); invalid_tokens.length = 0; foreach (index, ref token_result; result.results) { if (token_result.error == "NotRegistered") { invalid_toke

Re: Setting a list of values

2016-05-02 Thread sigod via Digitalmars-d-learn
On Monday, 2 May 2016 at 10:15:04 UTC, Marc Schütz wrote: On Monday, 2 May 2016 at 08:46:31 UTC, Ali Çehreli wrote: [...] Warning (better: disallowing altogether) about `=>` directly followed by `{` should be enough to cover all cases. To express that you really want a lambda returning a lam

Re: relative benefit of .reserve and .length

2016-05-02 Thread Eto Demerzel via Digitalmars-d-learn
On Monday, 2 May 2016 at 14:47:01 UTC, Steven Schveighoffer wrote: On 4/29/16 6:10 AM, sigod wrote: On Thursday, 28 April 2016 at 14:08:26 UTC, Steven Schveighoffer wrote: On 4/28/16 8:56 AM, Jay Norwood wrote: [...] .reserve should make an improvement for large amount of appending, since

Re: inferred size for static array initialization

2016-05-02 Thread Namespace via Digitalmars-d-learn
On Monday, 2 May 2016 at 20:05:15 UTC, Steven Schveighoffer wrote: On 5/2/16 3:38 PM, Namespace wrote: The assembler might be safe in some instances, but that doesn't reflect the original internal representation in the compiler. Some other configuration of calls may allow the compiler to reuse

Re: inferred size for static array initialization

2016-05-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/2/16 3:38 PM, Namespace wrote: The assembler might be safe in some instances, but that doesn't reflect the original internal representation in the compiler. Some other configuration of calls may allow the compiler to reuse that memory, and then you run into problems. I'm wondering if you us

Re: inferred size for static array initialization

2016-05-02 Thread Namespace via Digitalmars-d-learn
The assembler might be safe in some instances, but that doesn't reflect the original internal representation in the compiler. Some other configuration of calls may allow the compiler to reuse that memory, and then you run into problems. I'm wondering if you used my rewrite if it would actually

Re: inferred size for static array initialization

2016-05-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/2/16 3:12 PM, Namespace wrote: On Monday, 2 May 2016 at 19:08:52 UTC, Steven Schveighoffer wrote: On 5/2/16 3:02 PM, Namespace wrote: On Monday, 2 May 2016 at 18:57:49 UTC, Namespace wrote: A slice of a no-longer-existing temporary! Admittedly, this is not an issue with your code, but a d

Re: inferred size for static array initialization

2016-05-02 Thread Namespace via Digitalmars-d-learn
On Monday, 2 May 2016 at 19:08:52 UTC, Steven Schveighoffer wrote: On 5/2/16 3:02 PM, Namespace wrote: On Monday, 2 May 2016 at 18:57:49 UTC, Namespace wrote: A slice of a no-longer-existing temporary! Admittedly, this is not an issue with your code, but a deeper issue of allowing slicing of r

Re: inferred size for static array initialization

2016-05-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/2/16 3:02 PM, Namespace wrote: On Monday, 2 May 2016 at 18:57:49 UTC, Namespace wrote: A slice of a no-longer-existing temporary! Admittedly, this is not an issue with your code, but a deeper issue of allowing slicing of rvalues. This works: int[] as = [1, 2, 3].s; writeln(as[2]); O

Re: inferred size for static array initialization

2016-05-02 Thread Namespace via Digitalmars-d-learn
A slice of a no-longer-existing temporary! Admittedly, this is not an issue with your code, but a deeper issue of allowing slicing of rvalues. This works: int[] as = [1, 2, 3].s; writeln(as[2]); Bug or feature? Or did I may misunderstood you? You can drop auto. It's just a placeholder

Re: constructed variadic call

2016-05-02 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 2 May 2016 at 18:22:52 UTC, Erik Smith wrote: Is there way to construct an "argument pack" from a non-static array (like the switch below)? I need to transport a variadic call through a void*. switch (a.length) { case 1: foo(a[1]); break; case 2: foo(a[1], a[2]); break; case

Re: Method doesn't compile when defined in a mixin, but is fine without?

2016-05-02 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 1 May 2016 at 14:01:51 UTC, pineapple wrote: On Sunday, 1 May 2016 at 13:46:14 UTC, ag0aep6g wrote: On 01.05.2016 15:32, pineapple wrote: static string vectorpropertymixin(string name, string SDL_getter, string SDL_setter){ [...] mixin(vectorpropertymixin( "minsize", "SDL_Get

Re: inferred size for static array initialization

2016-05-02 Thread Namespace via Digitalmars-d-learn
On Monday, 2 May 2016 at 18:57:49 UTC, Namespace wrote: A slice of a no-longer-existing temporary! Admittedly, this is not an issue with your code, but a deeper issue of allowing slicing of rvalues. This works: int[] as = [1, 2, 3].s; writeln(as[2]); Of course this slice is only valid as

constructed variadic call

2016-05-02 Thread Erik Smith via Digitalmars-d-learn
Is there way to construct an "argument pack" from a non-static array (like the switch below)? I need to transport a variadic call through a void*. switch (a.length) { case 1: foo(a[1]); break; case 2: foo(a[1], a[2]); break; case 3: foo(a[1], a[2], a[3]); break; ... }

Re: inferred size for static array initialization

2016-05-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 5/2/16 1:43 PM, Namespace wrote: On Monday, 2 May 2016 at 13:00:27 UTC, Erik Smith wrote: Is there a way to initialize a static array and have it's size inferred (and that works for arrays of structs using braced literals)? This would make it easier to maintain longer static array definition

Re: inferred size for static array initialization

2016-05-02 Thread Namespace via Digitalmars-d-learn
On Monday, 2 May 2016 at 13:00:27 UTC, Erik Smith wrote: Is there a way to initialize a static array and have it's size inferred (and that works for arrays of structs using braced literals)? This would make it easier to maintain longer static array definitions. The code below doesn't work whe

Re: inferred size for static array initialization

2016-05-02 Thread Erik Smith via Digitalmars-d-learn
I tried to combine the two solutions (Basile with the wrapper, Marco with the struct initializer support) but it didn't work. The struct initializer is not a array literal (seems obvious now). I might go with the 2nd but it's pretty heavy just to get the size. Thanks. struct S { int a

Re: inferred size for static array initialization

2016-05-02 Thread Marco Leise via Digitalmars-d-learn
Am Mon, 2 May 2016 18:52:11 +0200 schrieb ag0aep6g : > On 02.05.2016 15:53, Marco Leise wrote: > >immutable tab = { static enum S[] s = [ > > `static enum`? What kind of black magic is this? I don't know, but it works, haha. -- Marco

Re: inferred size for static array initialization

2016-05-02 Thread ag0aep6g via Digitalmars-d-learn
On 02.05.2016 15:53, Marco Leise wrote: immutable tab = { static enum S[] s = [ `static enum`? What kind of black magic is this?

Re: relative benefit of .reserve and .length

2016-05-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On 4/29/16 6:10 AM, sigod wrote: On Thursday, 28 April 2016 at 14:08:26 UTC, Steven Schveighoffer wrote: On 4/28/16 8:56 AM, Jay Norwood wrote: [...] .reserve should make an improvement for large amount of appending, since you pre-allocate the data. [...] How about `assumeSafeAppend`? Does

Re: inferred size for static array initialization

2016-05-02 Thread Marco Leise via Digitalmars-d-learn
Am Mon, 02 May 2016 13:00:27 + schrieb Erik Smith : > Is there a way to initialize a static array and have it's size > inferred (and that works for arrays of structs using braced > literals)? This would make it easier to maintain longer static > array definitions. The code below doesn't w

Re: inferred size for static array initialization

2016-05-02 Thread Basile B via Digitalmars-d-learn
On Monday, 2 May 2016 at 13:22:01 UTC, Basile B wrote: On Monday, 2 May 2016 at 13:00:27 UTC, Erik Smith wrote: Is there a way to initialize a static array and have it's size inferred (and that works for arrays of structs using braced literals)? This would make it easier to maintain longer st

Re: inferred size for static array initialization

2016-05-02 Thread Basile B via Digitalmars-d-learn
On Monday, 2 May 2016 at 13:00:27 UTC, Erik Smith wrote: Is there a way to initialize a static array and have it's size inferred (and that works for arrays of structs using braced literals)? This would make it easier to maintain longer static array definitions. The code below doesn't work whe

inferred size for static array initialization

2016-05-02 Thread Erik Smith via Digitalmars-d-learn
Is there a way to initialize a static array and have it's size inferred (and that works for arrays of structs using braced literals)? This would make it easier to maintain longer static array definitions. The code below doesn't work when removing the array size even though the array is declar

how do I prevent null errors when using __traits(derivedMembers

2016-05-02 Thread Pedro Lopes via Digitalmars-d-learn
Hello, I've been poking around with "__traits", and I came across a problem: whenever I run a code like this "__traits(derivedMembers,members[i]);" I inevitably find a member that has no derived members, and inevitably the compiler tells me that I have an error: "Error: argument has no mem

Static introspection in a class hierarchy

2016-05-02 Thread Rene Zwanenburg via Digitalmars-d-learn
I'm in the process of making my code compile with DMD 2.071. There's a construction I've been using which now results in a deprecation message, and I'm not sure how to properly fix it. It's a bit like design by introspection within a class hierarchy. For example: abstract class Base { priv

Re: Setting a list of values

2016-05-02 Thread Marc Schütz via Digitalmars-d-learn
On Monday, 2 May 2016 at 08:46:31 UTC, Ali Çehreli wrote: On 05/01/2016 12:54 PM, Xinok wrote: > On Sunday, 1 May 2016 at 05:42:00 UTC, Ali Çehreli wrote: >> On 04/30/2016 10:05 PM, Joel wrote: >> > This has no effect: >> > _bars.each!(a => { a._plots.fillColor = Color(255, 180, 0); >> }); >> >>

Re: Setting a list of values

2016-05-02 Thread Ali Çehreli via Digitalmars-d-learn
On 05/01/2016 12:54 PM, Xinok wrote: > On Sunday, 1 May 2016 at 05:42:00 UTC, Ali Çehreli wrote: >> On 04/30/2016 10:05 PM, Joel wrote: >> > This has no effect: >> > _bars.each!(a => { a._plots.fillColor = Color(255, 180, 0); >> }); >> >> This is a common issue especially for people who know lambd