Re: Unmanaged drop in replacemet for [] and length -= 1

2016-06-18 Thread Joerg Joergonson via Digitalmars-d-learn
Also, how to handle foreach(i, x; w) (use index + value)?

Unmanaged drop in replacemet for [] and length -= 1

2016-06-18 Thread Joerg Joergonson via Digitalmars-d-learn
I wanted to switch to std.container.Array but it doesn't seem to mimic [] for some odd ball reason. I threw this class together and it seems to work. The only problem is that I can't do carray.length -= 1; I can't override `-=` because that is on the class. can I override it for length

Re: canFind doesn't work on Array, replacing [] with array doesn't work, etc...

2016-06-18 Thread Joerg Joergonson via Digitalmars-d-learn
On Saturday, 18 June 2016 at 17:46:26 UTC, ag0aep6g wrote: On Saturday, 18 June 2016 at 17:02:40 UTC, Joerg Joergonson wrote: 3. can't use canFind from algorithm. Complains it can't find a matching case. I tried many variations to get this to work. canFind takes a range. Array isn't a range

Re: How to get access to Voldemort / private thingies

2016-06-18 Thread Johan Engelen via Digitalmars-d-learn
On Saturday, 18 June 2016 at 17:50:51 UTC, cy wrote: On Saturday, 18 June 2016 at 08:41:30 UTC, Johan Engelen wrote: Without going in too much detail, the problem is that I am not linking to opaque .o files. The problem is the compiler has to assume you *might* be linking to opaque .o files,

Re: How to group similar member functions from different classes?

2016-06-18 Thread kinke via Digitalmars-d-learn
On Saturday, 18 June 2016 at 07:03:25 UTC, cy wrote: So how would you do it? Defining A.foo, B.foo, etc in one place, and A.bar, B.bar, etc in another? No such thing in D. But you can always be creative and use an overloaded helper function containing the actual implementation if you want to

Re: How to group similar member functions from different classes?

2016-06-18 Thread cy via Digitalmars-d-learn
On Saturday, 18 June 2016 at 07:03:25 UTC, cy wrote: So how would you do it? Defining A.foo, B.foo, etc in one place, and A.bar, B.bar, etc in another? The only thing I've been able to figure is a horrible hack, where your member functions are something like // off in define_foos.d

Re: How to get access to Voldemort / private thingies

2016-06-18 Thread cy via Digitalmars-d-learn
On Saturday, 18 June 2016 at 08:41:30 UTC, Johan Engelen wrote: Without going in too much detail, the problem is that I am not linking to opaque .o files. The problem is the compiler has to assume you *might* be linking to opaque .o files, so it can't provide any introspection capabilities.

Re: Templated class defaults and inheritence

2016-06-18 Thread Joerg Joergonson via Digitalmars-d-learn
This is solved through simple inheritance constraints and aliasing with qualification. class X; class subfoo; class subbaz : subfoo; class foo(T) if (is(T : subfoo)) X; class baz(T) if (is(T : subbaz)) foo!T; then when we need foo with "default", alias foo = qualified.foo!subfoo; Without

Re: canFind doesn't work on Array, replacing [] with array doesn't work, etc...

2016-06-18 Thread ag0aep6g via Digitalmars-d-learn
On Saturday, 18 June 2016 at 17:02:40 UTC, Joerg Joergonson wrote: 3. can't use canFind from algorithm. Complains it can't find a matching case. I tried many variations to get this to work. canFind takes a range. Array isn't a range itself, but you can get one by slicing it with []:

canFind doesn't work on Array, replacing [] with array doesn't work, etc...

2016-06-18 Thread Joerg Joergonson via Digitalmars-d-learn
Have working code that uses []. Trying to replace with Array! 1. Can't use make in field initialization. Complains about malloc in static context. 2. can't decrement the length. So Darr.length = Darr.length - 1; fails This means we can't remove the element easily. I see a removeBack but

Re: Can anybody install DDT on Eclipse Neon or Mars?

2016-06-18 Thread Seb via Digitalmars-d-learn
On Saturday, 18 June 2016 at 16:46:26 UTC, Mark wrote: I've spent may hours trying to do this in OSX. Everything goes fine from the marketplace window...until I restart Eclipse and find no files have been added? Any words of consolation or advice will be greatly appreciated. Desperately,

Can anybody install DDT on Eclipse Neon or Mars?

2016-06-18 Thread Mark via Digitalmars-d-learn
I've spent may hours trying to do this in OSX. Everything goes fine from the marketplace window...until I restart Eclipse and find no files have been added? Any words of consolation or advice will be greatly appreciated. Desperately, Mark

Re: Is it possible to create a static factory method on a templated struct?

2016-06-18 Thread ketmar via Digitalmars-d-learn
On Saturday, 18 June 2016 at 16:05:53 UTC, Gary Willoughby wrote: I've tried the following code and I get the error: you still have to instantiate you `Foo` here: auto foo = Foo.of!(string); no, you can't call even static methods of *uninstantiated* template. uninstantiated template

Re: ARSD PNG memory usage

2016-06-18 Thread Joerg Joergonson via Digitalmars-d-learn
On Saturday, 18 June 2016 at 02:01:29 UTC, Adam D. Ruppe wrote: On Saturday, 18 June 2016 at 01:20:16 UTC, Joerg Joergonson wrote: Error: undefined identifier 'sleep', did you mean function 'Sleep'? "import core.thread; sleep(10);" It is `Thread.sleep(10.msecs)` or whatever time - `sleep`

Re: Templated class defaults and inheritence

2016-06-18 Thread Joerg Joergonson via Digitalmars-d-learn
On Saturday, 18 June 2016 at 12:15:56 UTC, Klaus Kalsesh wrote: On Saturday, 18 June 2016 at 02:11:23 UTC, Joerg Joergonson wrote: I have something like class X; class subfoo : X; class subbaz : X; class foo : X { subfoo bar; } class baz : X; which I have modified so that class subbaz

Is it possible to create a static factory method on a templated struct?

2016-06-18 Thread Gary Willoughby via Digitalmars-d-learn
I've tried the following code and I get the error: Error: template Foo(A) does not have property 'of' struct Foo(A) { private int _foo; @disable this(); public this(int foo) { this._foo = foo; } public static auto of(B)()

Re: How to enable feedback for AssertError?

2016-06-18 Thread your_name via Digitalmars-d-learn
Sorry for the necromancy. I failed to reproduce the issue for single threaded programs. Which is good. As far as std.concurrency is concerned I still have questions. 1. How does the main thread of a program print an (Assert)Error/Exception when it is terminated by it ? 2. Where is the

Re: Is there a more elegant way of testing T for multiple types?

2016-06-18 Thread ag0aep6g via Digitalmars-d-learn
On 06/18/2016 04:37 PM, Gary Willoughby wrote: Here I'm testing T is either a class or interface: void foo(T)(T bar) if (is(T == class) || is(T == interface)) { ... } Is there a more elegant way of testing T for multiple types? Because it doesn't scale well if I need to add more. I would

Is there a more elegant way of testing T for multiple types?

2016-06-18 Thread Gary Willoughby via Digitalmars-d-learn
Here I'm testing T is either a class or interface: void foo(T)(T bar) if (is(T == class) || is(T == interface)) { ... } Is there a more elegant way of testing T for multiple types? Because it doesn't scale well if I need to add more. I would love to use something like this: void

Re: Vanilla Vim with D

2016-06-18 Thread Dlangofile via Digitalmars-d-learn
On Saturday, 18 June 2016 at 12:36:04 UTC, Adam D. Ruppe wrote: On Saturday, 18 June 2016 at 07:55:41 UTC, Dlangofile wrote: - compile from inside (rdmd or dmd right now) - jump in the code fixing the compilation errors? :set makeprg=rdmd\ % Do that to setup, then just :make to tell it to

Re: Vanilla Vim with D

2016-06-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 18 June 2016 at 07:55:41 UTC, Dlangofile wrote: - compile from inside (rdmd or dmd right now) - jump in the code fixing the compilation errors? :set makeprg=rdmd\ % Do that to setup, then just :make to tell it to run that command and jump around to the errors it sees.

Re: Templated class defaults and inheritence

2016-06-18 Thread Klaus Kalsesh via Digitalmars-d-learn
On Saturday, 18 June 2016 at 02:11:23 UTC, Joerg Joergonson wrote: I have something like class X; class subfoo : X; class subbaz : X; class foo : X { subfoo bar; } class baz : X; which I have modified so that class subbaz : subfoo; class baz : foo; (essentially baz is now a derivation

Re: How to get access to Voldemort / private thingies

2016-06-18 Thread Johan Engelen via Digitalmars-d-learn
Someone figured out how to do it and put it in std.traits! ;-) Example: ``` import std.stdio; import core.thread; import std.traits; void main() { Fields!Thread[11] a; writeln(typeid(a)); } ``` This prints "core.thread.Thread.Context" , which is a private struct type of

Re: How to get access to Voldemort / private thingies

2016-06-18 Thread Johan Engelen via Digitalmars-d-learn
On Friday, 17 June 2016 at 21:07:31 UTC, cy wrote: On Friday, 17 June 2016 at 19:49:18 UTC, Johan Engelen wrote: Hi all, Is there another way to get access to Voldemort class methods, or private class members, other than using [... snip ...] Because of the guarantee that you can link to

Re: Variadic function with parameters all of a specific type

2016-06-18 Thread Nordlöw via Digitalmars-d-learn
On Friday, 17 June 2016 at 21:20:01 UTC, Timon Gehr wrote: void foo(T[] a...)@nogc{} void bar()@nogc{ foo(1,2,3); } Ahh, cool. I was completely unaware of this feature. Doc here: https://dlang.org/spec/function.html#typesafe_variadic_functions

Vanilla Vim with D

2016-06-18 Thread Dlangofile via Digitalmars-d-learn
Hi to all, I'm trying to approach Vim as an editor for D, starting from scratch... I've a pretty vanilla vimrc, and only CtrlP as a plugin: not a so bad experience right now! First question, what's the best, simplest and fast approach for: - compile from inside (rdmd or dmd right now) -

Re: vibe.d - asynchronously wait() for process to exit

2016-06-18 Thread cy via Digitalmars-d-learn
On Friday, 17 June 2016 at 13:53:15 UTC, Vladimir Panteleev wrote: Geod24 on IRC suggested signalfd + createFileDescriptorEvent. I think this would work, but isn't it possible to wrap the fd returned by signalfd into a Vibe.d stream and read it directly? I'm just not sure how. Well, vibe.d

How to group similar member functions from different classes?

2016-06-18 Thread cy via Digitalmars-d-learn
When I define functions like: class A { abstract void format(...) {...} } class B : A { void format(...) {...} } class C : A { void format(...) {...} } and so on, often these different member functions all share a lot in common. Maybe they are the only ones that require formatting