Where are the solutions for the exercises of the dlang tour???

2016-06-09 Thread Richter via Digitalmars-d-learn
I've been trying to solve the exercise of the caesar encryption for practicing with arrays with no luck. I'm new to D Thanks for your help. :D

Re: shared Mutex?

2016-06-09 Thread cy via Digitalmars-d-learn
On Thursday, 9 June 2016 at 20:53:38 UTC, tcak wrote: (cast()mx).lock(); I was told casting away shared when there are still references to it is a bad idea. Like, the Mutex object might get corrupted if the garbage collector tries to move it while another thread is using it. So th

Re: stretto...@tutanota.com

2016-06-09 Thread Mike Parker via Digitalmars-d-learn
On Thursday, 9 June 2016 at 22:19:33 UTC, Stretto wrote: I have some class like class bar { } class foo : bar { bar[] stuff; } and have another class class dong : bar { int x; } Now sometimes stuff will contain dong's, but I cannot access its members it without a cast. fooo.stuff[0

Re: stretto...@tutanota.com

2016-06-09 Thread Stretto via Digitalmars-d-learn
Ultimately what I want to do is access a member foo.Dongs[i]; Where Dongs is essentially a "view" in to the Bars array and only accesses types of type Dong. It seems one can't do both an override on a name("Dongs") and an index on the overridden name(`[i]`)? It is not appropriate to use fo

stretto...@tutanota.com

2016-06-09 Thread Stretto via Digitalmars-d-learn
I have some class like class bar { } class foo : bar { bar[] stuff; } and have another class class dong : bar { int x; } Now sometimes stuff will contain dong's, but I cannot access its members it without a cast. fooo.stuff[0].x // invalid because bar doesn't contain x; Hence, ((c

Re: Parse File at compile time, but not embedded

2016-06-09 Thread Joerg Joergonson via Digitalmars-d-learn
On Tuesday, 7 June 2016 at 22:09:58 UTC, Alex Parrill wrote: On Monday, 6 June 2016 at 21:57:20 UTC, Pie? wrote: On Monday, 6 June 2016 at 21:31:32 UTC, Alex Parrill wrote: [...] Not necessarily, You chased that rabbit quite far! The data your reading could contain sensitive information only

Formated string with assert inside template constraints?

2016-06-09 Thread ArturG via Digitalmars-d-learn
is it supposed to work? normally it works e.g. assert(0, "some\nstring"); prints: some string but if you do it inside a template constraint like this: void someTemp(T)(T t) if(isCallable!T.call!((b){assert(b, "some\nstring");})) { } it prints: some\x0astring

Re: shared Mutex?

2016-06-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 6/9/16 2:31 PM, cy wrote: Is core.sync.mutex.Mutex even usable in D anymore? It seems every mutex that wasn't shared would be part of thread local data, so two threads locking on the same mutex would actually be locking separate mutexes. Yes, but this is because Mutex existed way before sha

Re: shared Mutex?

2016-06-09 Thread tcak via Digitalmars-d-learn
On Thursday, 9 June 2016 at 18:31:16 UTC, cy wrote: I was thinking of using threads in a D program (ignores unearthly wailing) and I need 1 thread for each unique string resource (database connection info). So I did this: shared BackgroundDB[string] back; I don't see any way to make less data

Re: Parse File at compile time, but not embedded

2016-06-09 Thread cy via Digitalmars-d-learn
On Tuesday, 7 June 2016 at 22:09:58 UTC, Alex Parrill wrote: Accessing a SQL server at compile time seems like a huge abuse of CTFE (and I'm pretty sure it's impossible at the moment). Why do I need to install and set up a MySQL database in order to build your software? Presumably you would

Re: Constraining template with function signature

2016-06-09 Thread cy via Digitalmars-d-learn
The other way is better, but since you asked... On Wednesday, 8 June 2016 at 01:42:55 UTC, Carl Vogel wrote: Now, I can use something like isCallable std.traits to make sure the predicate is a Callable, and there are various function traits in the module that I could combine with `is` clauses

Re: Pointer problems, changing for no reasons

2016-06-09 Thread cy via Digitalmars-d-learn
I can't help but notice that loadModel is not a static member function, yet you don't seem to call it with a Model object in your "get" function. Also have a look at std.typecons.RefCounted if you want reference counted data..

Re: Fibers under the hood

2016-06-09 Thread Jack Stouffer via Digitalmars-d-learn
On Thursday, 9 June 2016 at 16:13:21 UTC, Jonathan Marler wrote: I don't see that documentation anywhere on that page. https://issues.dlang.org/show_bug.cgi?id=16148

shared Mutex?

2016-06-09 Thread cy via Digitalmars-d-learn
I was thinking of using threads in a D program (ignores unearthly wailing) and I need 1 thread for each unique string resource (database connection info). So I did this: shared BackgroundDB[string] back; I don't see any way to make less data shared there. If it weren't shared, it would be thr

Re: Fibers under the hood

2016-06-09 Thread Jonathan Marler via Digitalmars-d-learn
On Thursday, 9 June 2016 at 11:45:01 UTC, Andrew Edwards wrote: On 6/9/16 2:15 PM, Jonathan Marler wrote: On Thursday, 9 June 2016 at 05:07:33 UTC, Nikolay wrote: On Thursday, 9 June 2016 at 04:57:30 UTC, Jonathan Marler wrote: I've googled and searched through the forums but haven't found too

Re: a lambda with arguments has type void?

2016-06-09 Thread Artur Skawina via Digitalmars-d-learn
On 06/09/16 07:20, cy via Digitalmars-d-learn wrote: > Like this is why it doesn't really make sense: > > import std.stdio; > > auto foo(Callable)(Callable c) { > return c(42); > } > > auto foo2(alias c)() { > return c(42); > } > > void main() { > // this works, when you know it's an int

Re: Fibers under the hood

2016-06-09 Thread Andrew Edwards via Digitalmars-d-learn
On 6/9/16 2:15 PM, Jonathan Marler wrote: On Thursday, 9 June 2016 at 05:07:33 UTC, Nikolay wrote: On Thursday, 9 June 2016 at 04:57:30 UTC, Jonathan Marler wrote: I've googled and searched through the forums but haven't found too much on how fibers are implemented. How does yield return execu

Re: how convert the range to slice ?

2016-06-09 Thread Nordlöw via Digitalmars-d-learn
On Monday, 2 February 2015 at 21:04:11 UTC, Nordlöw wrote: Made it PR at https://github.com/D-Programming-Language/dmd/pull/4371 Synched with DMD D conversion and improved isInputRange and message at: https://github.com/dlang/dmd/pull/4371

Pointer problems, changing for no reasons

2016-06-09 Thread Begah via Digitalmars-d-learn
I have a really weird bug in my application, i succeeded in making a small program with the bare munimum to show that bug. The full source code of the application + a dub.json file are at https://github.com/Begah/D_Pointer_Problem ( < 300 LOC ) I have a template called ResourceManager (asset.

Re: template with enum arg ?

2016-06-09 Thread chmike via Digitalmars-d-learn
This is awesome! I added it to my D cookbook. Thank you very much.