Re: std.typecons.Proxy + inheritance breaks cast'ing to inherited type

2015-03-16 Thread Lukasz Wrzosek via Digitalmars-d-learn
Bug reported as https://issues.dlang.org/show_bug.cgi?id=14298

Re: How to generate a random string ...

2015-03-16 Thread Robert burner Schadek via Digitalmars-d-learn
On Monday, 16 March 2015 at 22:19:52 UTC, Gary Willoughby wrote: I guess it depends on the encoding? No the character itself are encoding independent. Some references: http://stackoverflow.com/questions/23853489/generate-a-random-unicode-string This will not work as the caller has to

Re: Dlang seems like java now,but why not let d more like C# Style?

2015-03-16 Thread Israel via Digitalmars-d-learn
On Saturday, 14 March 2015 at 23:46:28 UTC, Ellery Newcomer wrote: On Saturday, 14 March 2015 at 13:52:13 UTC, Craig Dillabaugh wrote: I don't have any C# experience so I can't compare those languages much, but I've heard people say their are D / C# similarities. Anyway, this isn't a

Re: A bug on the website dlang.org

2015-03-16 Thread Dennis Ritchie via Digitalmars-d-learn
On Monday, 16 March 2015 at 20:03:36 UTC, Marc Schütz wrote: You can file bugs against component websites there. Thanks. This has already been fixed AFAIK, it's just not yet deployed. OK.

Re: struct / cast / ? design problem

2015-03-16 Thread via Digitalmars-d-learn
The problem in your example is that your making a copy of the returned data. Of course any changes to that copy won't affect the original. You need to return a pointer to it (`ref` won't do if you want to store it in a local variable, because these can't be `ref`). struct BlockHead {

Re: ref for (const) variables

2015-03-16 Thread Namespace via Digitalmars-d-learn
On Monday, 16 March 2015 at 19:20:09 UTC, anonymous wrote: On Monday, 16 March 2015 at 18:47:00 UTC, Namespace wrote: const(Matrix)* m = t.getCurrentModelViewMatrix(); // currently } But IMO it would be a lot nicer if I could store the reference like this: ref const(Matrix) m =

Re: Using std.format required std.string?

2015-03-16 Thread ketmar via Digitalmars-d-learn
On Mon, 16 Mar 2015 12:32:01 +0100, Robert M. Münch wrote: I prefer to move things to the far future compatibility path ASAP. Reduce a lot of maintenance headaches. then you can check properties, not versions. ;-) static if (__traits(compiles, {import std.string : format;})) { import

Re: Dlang seems like java now,but why not let d more like C# Style?

2015-03-16 Thread Idan Arye via Digitalmars-d-learn
On Monday, 16 March 2015 at 12:18:42 UTC, Ellery Newcomer wrote: On Sunday, 15 March 2015 at 14:58:54 UTC, Idan Arye wrote: Even if we can't get the lambdas as syntax tress, the fact that we can send whatever types we want to the delegates and overload operators and stuff means we can still

How to generate a random string ...

2015-03-16 Thread Robert burner Schadek via Digitalmars-d-learn
... from all Unicode characters in an idiomatic D way? (std.interal.unicode_*) ``` T genUnicodeString(T)(size_t minChars, size_t maxChars) if(isSomeString!T) { ... } ```

Re: DlangUI EditLine question

2015-03-16 Thread Kyle via Digitalmars-d-learn
Thanks! I'll try this out after I get home.

Re: std.typecons.Proxy + inheritance breaks cast'ing to inherited type

2015-03-16 Thread John Colvin via Digitalmars-d-learn
On Monday, 16 March 2015 at 09:03:18 UTC, Lukasz Wrzosek wrote: Hello I was just exploring possibility to mimic multiple inheritance from C++ (do not ask why, just for fun). I've stumbled on below issue (let's say corner case) and most likely this is bug in implementation of template Proxy,

Re: Dlang seems like java now,but why not let d more like C# Style?

2015-03-16 Thread Ellery Newcomer via Digitalmars-d-learn
On Sunday, 15 March 2015 at 14:58:54 UTC, Idan Arye wrote: Even if we can't get the lambdas as syntax tress, the fact that we can send whatever types we want to the delegates and overload operators and stuff means we can still convert the lambdas into SQL. There are limitations on operator

Re: DlangUI EditLine question

2015-03-16 Thread Vadim Lopatin via Digitalmars-d-learn
On Sunday, 15 March 2015 at 16:21:21 UTC, Kyle wrote: I have a variable, x, which I want to update when the content of a DlangUI EditLine is modified. I tried making this work with the onContentChange method listed in the API documentation, but dmd told me it's not there. I've got this

Re: Using std.format required std.string?

2015-03-16 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-03-15 19:16:52 +, anonymous said: Answerting myself: static if (__traits(compiles, version_minor 67)) import std.string; // format() for versions 2.0.67 else import std.format; // format() for versions = 2.0.67 That doesn't do what you want. You need to `import std.compiler;`

Re: GDC fails to link with GSL and fortran code

2015-03-16 Thread ketmar via Digitalmars-d-learn
On Mon, 16 Mar 2015 16:44:45 +, Andrew Brown wrote: can you please show output of `dmd -v` and `gdc -v`, so we can see the actual commands they both using for linking? signature.asc Description: PGP signature

Re: What is the best practice of organization multi-threading ?

2015-03-16 Thread Suliman via Digitalmars-d-learn
UP

Re: struct / cast / ? design problem

2015-03-16 Thread Charles Hixson via Digitalmars-d-learn
On 03/15/2015 04:51 PM, ketmar via Digitalmars-d-learn wrote: On Sun, 15 Mar 2015 16:34:14 -0700, Charles Hixson via Digitalmars-d-learn wrote: if you know the exact layouts of `spare`, you can use union for that: struct S { // ... union { ulong[61] spare; struct { int vala;

GDC fails to link with GSL and fortran code

2015-03-16 Thread Andrew Brown via Digitalmars-d-learn
Hi, I'm trying to compile code which calls C and fortan routines from D on the linux cluster at work. I've managed to get it to work with all 3 compilers on my laptop, but LDC and GDC fail on the cluster (though DMD works perfectly). I'm using the precompiled compiler binaries on these

Re: std.typecons.Proxy + inheritance breaks cast'ing to inherited type

2015-03-16 Thread Lukasz Wrzosek via Digitalmars-d-learn
On Monday, 16 March 2015 at 12:03:12 UTC, John Colvin wrote: What behaviour would you expect if both IA and C inherited from IB? This case should assert at compile time. But my example shows that case with implicit case is working, but the explicit cast is not. That seems to be incorrect

Re: std.typecons.Proxy + inheritance breaks cast'ing to inherited type

2015-03-16 Thread Ali Çehreli via Digitalmars-d-learn
On 03/16/2015 08:28 AM, Lukasz Wrzosek wrote: On Monday, 16 March 2015 at 12:03:12 UTC, John Colvin wrote: What behaviour would you expect if both IA and C inherited from IB? This case should assert at compile time. But my example shows that case with implicit case is working, but the

Re: struct / cast / ? design problem

2015-03-16 Thread Charles Hixson via Digitalmars-d-learn
On 03/16/2015 09:16 AM, Charles Hixson via Digitalmars-d-learn wrote: On 03/15/2015 04:51 PM, ketmar via Digitalmars-d-learn wrote: On Sun, 15 Mar 2015 16:34:14 -0700, Charles Hixson via Digitalmars-d-learn wrote: if you know the exact layouts of `spare`, you can use union for that: struct

Re: What is the best practice of organization multi-threading ?

2015-03-16 Thread Ali Çehreli via Digitalmars-d-learn
On 03/15/2015 01:53 PM, Suliman wrote: I have App that read config sections. If the section is true I want to run it in new thread. if (parseconfig.obsmpplots_load == true) { auto obsmpplots = new ObsmpPlots(db); auto theTask = task(obsmpplots.getPlots);

Re: std.typecons.Proxy + inheritance breaks cast'ing to inherited type

2015-03-16 Thread Ali Çehreli via Digitalmars-d-learn
On 03/16/2015 04:59 PM, Lukasz Wrzosek wrote: Bug reported as https://issues.dlang.org/show_bug.cgi?id=14298 Thanks... I have carried the discussion over to the main newsgroup: http://forum.dlang.org/thread/me8e0a$1kp6$1...@digitalmars.com As I mention there, there is a workaround: Add a

Re: struct / cast / ? design problem

2015-03-16 Thread ketmar via Digitalmars-d-learn
On Mon, 16 Mar 2015 12:49:40 -0700, Charles Hixson via Digitalmars-d-learn wrote: yep, you're doing it wrong, as Marc already wrote. ;-) it's not very obvious, but this line makes a copy: auto val = tst.value; there are no `ref` type in D. `ref` is modifier for function arguments, but not

Re: What is the best practice of organization multi-threading ?

2015-03-16 Thread Ali Çehreli via Digitalmars-d-learn
On 03/16/2015 12:04 PM, Suliman wrote: Ali, please add text above to your book! Will do. Please email me your full name at acehr...@yahoo.com so that I can add it to the Acknowledgments section. Thank you, Ali

Re: How to generate a random string ...

2015-03-16 Thread Robert burner Schadek via Digitalmars-d-learn
On Monday, 16 March 2015 at 18:48:29 UTC, bearophile wrote: Perhaps by rejection? I mean, generating a uint, test if it's a character and repeat until the result is true. hm, that must not even terminate.

Re: struct / cast / ? design problem

2015-03-16 Thread Charles Hixson via Digitalmars-d-learn
On 03/16/2015 01:24 PM, via Digitalmars-d-learn wrote: The problem in your example is that your making a copy of the returned data. Of course any changes to that copy won't affect the original. You need to return a pointer to it (`ref` won't do if you want to store it in a local variable,

Re: How to generate a random string ...

2015-03-16 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 16 March 2015 at 13:33:55 UTC, Robert burner Schadek wrote: ... from all Unicode characters in an idiomatic D way? (std.interal.unicode_*) ``` T genUnicodeString(T)(size_t minChars, size_t maxChars) if(isSomeString!T) { ... } ``` I guess it depends on the encoding? Some

Re: struct / cast / ? design problem

2015-03-16 Thread ketmar via Digitalmars-d-learn
On Mon, 16 Mar 2015 11:18:16 -0700, Charles Hixson via Digitalmars-d-learn wrote: My current best answer is to turn the unused into a vector of bytes, and then pass that to the using routines as a ref. This still is wide open to errors at the calling end, but the BlockHead end can ensure that

Re: What is the best practice of organization multi-threading ?

2015-03-16 Thread Suliman via Digitalmars-d-learn
Ali, please add text above to your book!

Re: Garbage collector returning pointers

2015-03-16 Thread Robert M. Münch via Digitalmars-d-learn
On 2015-03-15 15:57:43 +, Marc Schütz said: Ok. I need to dig into how the interpreter handles the returned pointer and how the stack is handled. C usually uses manual memory management, therefore I would expect that the interpreter actually documents whom the pointer belongs to, and who

Re: What is the best practice of organization multi-threading ?

2015-03-16 Thread Suliman via Digitalmars-d-learn
Ali, again big thanks for your book, without it I was not able how to work with D. But for me now absolutely clear what difference between: auto theTask = task(someFunction); and: auto theTask = task!anOperation();

ref for (const) variables

2015-03-16 Thread Namespace via Digitalmars-d-learn
Currently, if you want to store a long getter into a variable without copying it (because it may be a big struct), your only way is to store it as a pointer: struct Matrix { float[16] values= [ 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 ]; }

Re: What is the best practice of organization multi-threading ?

2015-03-16 Thread Ali Çehreli via Digitalmars-d-learn
On 03/16/2015 11:28 AM, Suliman wrote: difference between: auto theTask = task(someFunction); and: auto theTask = task!anOperation(); tl;dr - Prefer task!anOperation() unless you can't. :) task() is flexible enough to take what to execute either as a function (or delegate) pointer

Re: How to generate a random string ...

2015-03-16 Thread bearophile via Digitalmars-d-learn
Robert burner Schadek: ... from all Unicode characters in an idiomatic D way? Perhaps by rejection? I mean, generating a uint, test if it's a character and repeat until the result is true. Bye, bearophile

Re: ref for (const) variables

2015-03-16 Thread anonymous via Digitalmars-d-learn
On Monday, 16 March 2015 at 18:47:00 UTC, Namespace wrote: const(Matrix)* m = t.getCurrentModelViewMatrix(); // currently } But IMO it would be a lot nicer if I could store the reference like this: ref const(Matrix) m = t.getCurrentModelViewMatrix(); // nicer [Of course

Re: GDC fails to link with GSL and fortran code

2015-03-16 Thread Johannes Pfau via Digitalmars-d-learn
Am Mon, 16 Mar 2015 16:44:45 + schrieb Andrew Brown aabrow...@hotmail.com: Hi, I'm trying to compile code which calls C and fortan routines from D on the linux cluster at work. I've managed to get it to work with all 3 compilers on my laptop, but LDC and GDC fail on the cluster

Re: A bug on the website dlang.org

2015-03-16 Thread via Digitalmars-d-learn
On Monday, 16 March 2015 at 20:00:24 UTC, Dennis Ritchie wrote: I don't know where to write about a bug on the website, so I decided to write in this section. This is the official bug tracker: https://issues.dlang.org/enter_bug.cgi You can file bugs against component websites there. This

A bug on the website dlang.org

2015-03-16 Thread Dennis Ritchie via Digitalmars-d-learn
I don't know where to write about a bug on the website, so I decided to write in this section. This page is not displayed correctly: http://dlang.org/phobos/std_format.html

Re: ref for (const) variables

2015-03-16 Thread via Digitalmars-d-learn
On Monday, 16 March 2015 at 19:20:09 UTC, anonymous wrote: On Monday, 16 March 2015 at 18:47:00 UTC, Namespace wrote: const(Matrix)* m = t.getCurrentModelViewMatrix(); // currently } But IMO it would be a lot nicer if I could store the reference like this: ref const(Matrix) m =

Re: struct / cast / ? design problem

2015-03-16 Thread Charles Hixson via Digitalmars-d-learn
On 03/16/2015 11:55 AM, ketmar via Digitalmars-d-learn wrote: On Mon, 16 Mar 2015 11:18:16 -0700, Charles Hixson via Digitalmars-d-learn wrote: My current best answer is to turn the unused into a vector of bytes, and then pass that to the using routines as a ref. This still is wide open to

std.typecons.Proxy + inheritance breaks cast'ing to inherited type

2015-03-16 Thread Lukasz Wrzosek via Digitalmars-d-learn
Hello I was just exploring possibility to mimic multiple inheritance from C++ (do not ask why, just for fun). I've stumbled on below issue (let's say corner case) and most likely this is bug in implementation of template Proxy, isn't it ? import std.typecons; class IA {} class IB {} class C

Removing structs from assoc array while iterating over it

2015-03-16 Thread Matt via Digitalmars-d-learn
I am creating a simple SDL_Texture manager, and was wondering if the following code would work: --- // 'list' is am assoc array of a struct containing a pointer and ref counter. // max_list_length is set to 20 if it's ever found to be 0 // compact list if(list.length == max_list_length){