!in operator

2015-08-02 Thread Ali Çehreli via Digitalmars-d-learn
Is my understanding below correct? Does any documentation need updating? Operator precedence table lists !in as an operator: http://wiki.dlang.org/Operator_precedence Operator overloading documentation does not mention it: http://dlang.org/operatoroverloading.html#binary However, 'a !in

Re: Trouble with template parameter matching

2015-08-02 Thread Fusxfaranto via Digitalmars-d-learn
On Sunday, 2 August 2015 at 08:08:05 UTC, tcak wrote: [code] void func1(N)( const N name ) if( is(N: string) || is(N: char[]) ) { func2( name ); } [...] This seems like the reasonable behavior to me. Perhaps you should use Unqual?

Randomisation of array order

2015-08-02 Thread Matt via Digitalmars-d-learn
I was planning to use a dynamic array of indices to represent a deck of cards, and was wondering if there was any easy way to shuffle the arrays contents? I checked the library docs, but came to the conclusion that sorting arrays is a much more common operation :) If anyone has a suggestion

Trouble with template parameter matching

2015-08-02 Thread tcak via Digitalmars-d-learn
[code] void func1(N)( const N name ) if( is(N: string) || is(N: char[]) ) { func2( name ); } void func2(N)( const N name ) if( is(N: string) || is(N: char[]) ) {} void main(){ char[] blah = ['b', 'l', 'a', 'h']; func1( blah ); //func1( blah );

Re: Randomisation of array order

2015-08-02 Thread Matt via Digitalmars-d-learn
...And then I realised that I hadn't looked inside std.random. Question solved, because I am a dumbass.

Re: Randomisation of array order

2015-08-02 Thread cym13 via Digitalmars-d-learn
On Sunday, 2 August 2015 at 09:24:12 UTC, Matt wrote: I was planning to use a dynamic array of indices to represent a deck of cards, and was wondering if there was any easy way to shuffle the arrays contents? I checked the library docs, but came to the conclusion that sorting arrays is a much

Re: store template value

2015-08-02 Thread maarten van damme via Digitalmars-d-learn
Oh, neat. This saves the day :) 2015-08-01 23:22 GMT+02:00 Ali Çehreli digitalmars-d-learn@puremagic.com: On 08/01/2015 08:37 AM, maarten van damme via Digitalmars-d-learn wrote: I have a class that creates a task in it's constructor. How do I store this created task as one of it's value

Re: How disruptive is the GC?

2015-08-02 Thread Temtaime via Digitalmars-d-learn
I'm writing a game engine in D. Try to minimize allocations and that's will be OK. I'm using delegates and all the phobos stuff. I allocate only in few places at every frame. So i can reach 1K fps on a complicated scene. GC is not a problem. DMD optimizes so ugly that all the math is very,

Re: Struct that destroys its original handle on copy-by-value

2015-08-02 Thread Joseph Rushton Wakeling via Digitalmars-d-learn
On 02/08/15 03:38, Dicebot via Digitalmars-d-learn wrote: On Saturday, 1 August 2015 at 17:50:28 UTC, John Colvin wrote: I'm not sure how good an idea it is to totally enforce a range to be non-copyable, even if you could deal with the function call chain problem. Even in totally save-aware

Dynamic bindings to global variables

2015-08-02 Thread remi thebault via Digitalmars-d-learn
Hello I wrote static bindings to a C library. I want to also offer a version(Dynamic) of the bindings. I follow and use derelict-util to get the address of function pointers. In the library I bind, there is also global variables. here's one example in the static bindings: extern __gshared

Re: Dynamic bindings to global variables

2015-08-02 Thread Mike Parker via Digitalmars-d-learn
On Sunday, 2 August 2015 at 15:31:48 UTC, remi thebault wrote: Hello I wrote static bindings to a C library. I want to also offer a version(Dynamic) of the bindings. I follow and use derelict-util to get the address of function pointers. In the library I bind, there is also global

Re: Trouble with template parameter matching

2015-08-02 Thread anonymous via Digitalmars-d-learn
On Sunday, 2 August 2015 at 08:08:05 UTC, tcak wrote: [code] void func1(N)( const N name ) if( is(N: string) || is(N: char[]) ) { func2( name ); } void func2(N)( const N name ) if( is(N: string) || is(N: char[]) ) {} void main(){ char[] blah = ['b', 'l', 'a',

Re: Dynamic bindings to global variables

2015-08-02 Thread remi thebault via Digitalmars-d-learn
On Sunday, 2 August 2015 at 16:20:29 UTC, remi thebault wrote: On Sunday, 2 August 2015 at 15:38:34 UTC, Mike Parker wrote: You have to declare it as a pointer, then retrieve the pointer in the same way you do the function pointers, via the system loader (GetProcAddress/dlsym). and how would

Is Key Type?

2015-08-02 Thread Xinok via Digitalmars-d-learn
is there a trait in D or Phobos which will tell you if a type can be used as a key for an associative array? For example, where T is some type: static assert(isKeyType!T) int[T] hashTable = ...

Re: Dynamic bindings to global variables

2015-08-02 Thread remi thebault via Digitalmars-d-learn
On Sunday, 2 August 2015 at 15:38:34 UTC, Mike Parker wrote: You have to declare it as a pointer, then retrieve the pointer in the same way you do the function pointers, via the system loader (GetProcAddress/dlsym). and how would you make this source compatible with the static binding

Re: Is Key Type?

2015-08-02 Thread Gary Willoughby via Digitalmars-d-learn
On Sunday, 2 August 2015 at 17:55:16 UTC, Xinok wrote: is there a trait in D or Phobos which will tell you if a type can be used as a key for an associative array? For example, where T is some type: static assert(isKeyType!T) int[T] hashTable = ... import std.stdio; enum

Using rdmd to create shared object files

2015-08-02 Thread via Digitalmars-d-learn
Hello, I am trying to use rdmd to create shared object files. The command that I am using is rdmd --build-only -shared -fPIC -defaultlib= foo.d This creates a file called foo - wich is not exactly what I expectd. However dmd -shared -fPIC -defaultlib= foo.d creates a file called foo.so -

Re: How disruptive is the GC?

2015-08-02 Thread via Digitalmars-d-learn
On Wednesday, 29 July 2015 at 09:25:50 UTC, Snape wrote: I'm in the early stages of building a little game with OpenGL (in D) and I just want to know the facts about the GC before I decide to either use it or work around it. Lots of people have said lots of things about it, but some of that

Re: store template value

2015-08-02 Thread Ali Çehreli via Digitalmars-d-learn
On 08/02/2015 05:15 AM, maarten van damme via Digitalmars-d-learn wrote: Oh, neat. This saves the day :) Awesome! :) However, that solution depends on the implementation details of std.parallelism. It is possible to do the same thing by inheriting from an 'interface' and hiding the templated

Re: Array start index

2015-08-02 Thread QAston via Digitalmars-d-learn
On Saturday, 1 August 2015 at 23:02:51 UTC, bachmeier wrote: But what type of programming are you doing? Even after decades of programming and trying out dozens of languages, zero-based indexing still gets me at times when the arrays I work with represent vectors and matrices. Especially when