Re: C Memory

2013-05-04 Thread Diggory
On Sunday, 5 May 2013 at 06:35:38 UTC, Namespace wrote: Quick question: I have a SDL_Surface in one of my classes and the SDL_Surface contains (obviously) memory to the pixel data. Since I cannot free this memory with the DTor: what will happen? AFAIK this cannot be freed by the GC because it w

C Memory

2013-05-04 Thread Namespace
Quick question: I have a SDL_Surface in one of my classes and the SDL_Surface contains (obviously) memory to the pixel data. Since I cannot free this memory with the DTor: what will happen? AFAIK this cannot be freed by the GC because it was not allocated by it. So AFAIK this creates a memory l

Re: Check if tuple contains value at compile time

2013-05-04 Thread Diggory
On Sunday, 5 May 2013 at 01:44:19 UTC, bearophile wrote: Diggory: The documentation seems too say that "[mytuple]" will make an array, Nope. You have to extract the inherent typetuple first. And this is what the [] syntax does (tested): import std.stdio, std.typecons, std.algorithm; void

Re: Check if tuple contains value at compile time

2013-05-04 Thread bearophile
Diggory: The documentation seems too say that "[mytuple]" will make an array, Nope. You have to extract the inherent typetuple first. And this is what the [] syntax does (tested): import std.stdio, std.typecons, std.algorithm; void main() { auto t = tuple("foo", "bar", "spam"); ass

Re: Check if tuple contains value at compile time

2013-05-04 Thread Diggory
On Sunday, 5 May 2013 at 00:33:34 UTC, bearophile wrote: Diggory: It's not a TypeTuple, it's a tuple of strings. Then one simple way to do it is to convert it into an array of strings, and then use canFind: [mytuple[]].canFind(needle) Bye, bearophile OK, that makes sense but I'm not sur

Re: Is their a good book on learning Phobos?

2013-05-04 Thread Jonathan M Davis
On Saturday, May 04, 2013 21:54:08 WhatMeWorry wrote: > Particularly in regards to std.container? Ideally, I wish Mr. > Andrei Alexandrescu would write something like his masterpiece, > The D Programming Language. > > The examples embedded in this site and elsewhere seem a little > rudimentary. I

Re: Check if tuple contains value at compile time

2013-05-04 Thread bearophile
Diggory: It's not a TypeTuple, it's a tuple of strings. Then one simple way to do it is to convert it into an array of strings, and then use canFind: [mytuple[]].canFind(needle) Bye, bearophile

Re: Check if tuple contains value at compile time

2013-05-04 Thread Diggory
On Sunday, 5 May 2013 at 00:10:27 UTC, Simen Kjaeraas wrote: On 2013-05-05, 01:42, Diggory wrote: I'm trying to test using a "static if" statement if a tuple of strings contains a particular string. What's the easiest/best way to do this? http://dlang.org/phobos/std_typetuple#.staticIndexOf

Re: Check if tuple contains value at compile time

2013-05-04 Thread Simen Kjaeraas
On 2013-05-05, 01:42, Diggory wrote: I'm trying to test using a "static if" statement if a tuple of strings contains a particular string. What's the easiest/best way to do this? http://dlang.org/phobos/std_typetuple#.staticIndexOf -- Simen

Check if tuple contains value at compile time

2013-05-04 Thread Diggory
I'm trying to test using a "static if" statement if a tuple of strings contains a particular string. What's the easiest/best way to do this?

Re: how hash_t toHash() works?

2013-05-04 Thread Ivan Kazmenko
One more question... why associative arrays in D can't be implemented like here? http://svn.php.net/viewvc/php/php-src/trunk/Zend/zend_hash.h?view=markup it seems that php arrays uses hash tables too but they preserve orders. From what I see there, this code traverses a hash table in the or

Re: how hash_t toHash() works?

2013-05-04 Thread gedaiu
On Tuesday, 30 April 2013 at 17:48:08 UTC, Ivan Kazmenko wrote: - import std.functional; ... RedBlackTree !(MyRecord, binaryFun!"a.key < b.key", true) cont; ... cont = redBlackTree !("a.key < b.key", true, MyRecord) (); - Error: template instance RedBlackTree!(ValueRecord, bi

Is their a good book on learning Phobos?

2013-05-04 Thread WhatMeWorry
Particularly in regards to std.container? Ideally, I wish Mr. Andrei Alexandrescu would write something like his masterpiece, The D Programming Language. The examples embedded in this site and elsewhere seem a little rudimentary. I would like some real meaty examples like containers of conta

Re: D is totally useless

2013-05-04 Thread WhatMeWorry
You sir need Derelict3:https://github.com/aldacron/Derelict3 It not only has the gl.h you are looking for but FreeGlut, OGG, openAL, SDL2, etc.

Re: Avoid initializing a struct field.

2013-05-04 Thread jerro
What code have you used to test it, and what is the result you have seen? I was using this code: extern(C) void foo(Foo* r) { Foo tmp; *r = tmp; } And here is the generated assembly (when using "= void"): push %rbp mov%rsp,%rbp sub$0xc0,%rsp mov%rdi,-0x10(%rbp) movabs $0

Re: D is totally useless

2013-05-04 Thread Idan Arye
On Friday, 3 May 2013 at 16:48:42 UTC, Jesse Phillips wrote: On Thursday, 2 May 2013 at 20:23:53 UTC, Diggory wrote: The wgl*** functions and "SwapBuffers" ARE part of the windows api even though they are implemented in opengl32.dll (they are declared in wingdi.h IIRC) You recalled correctly,

Re: Avoid initializing a struct field.

2013-05-04 Thread bearophile
On Saturday, 4 May 2013 at 18:11:03 UTC, jerro wrote: Is there a way to avoid default initializing a struct field in D? The following doesn't seem to work: struct Foo { int[42] buffer = void; int bar; } I think it's supposed to work. If it doesn't work, then I think it's a compiler b

Avoid initializing a struct field.

2013-05-04 Thread jerro
Is there a way to avoid default initializing a struct field in D? The following doesn't seem to work: struct Foo { int[42] buffer = void; int bar; } I know I can do this: Foo foo = void But then all fields are uninitialized.

Re: GtkD - Changing the default windows font

2013-05-04 Thread Mike Wey
On 05/03/2013 08:05 PM, Mike Wey wrote: On 05/03/2013 09:39 AM, Mike James wrote: Running on Windows 7, the default font is very thin and indistinct on my machine - is there a system setting to change the default font? regards, Mike. I don't know, i'll see if i can find out how to set it.

Re: [GtkD] How to connect to notify::active signal?

2013-05-04 Thread Mike Wey
On 05/04/2013 05:20 AM, Alexandr Druzhinin wrote: 04.05.2013 1:18, Mike Wey пишет: On 05/03/2013 06:30 PM, Alexandr Druzhinin wrote: I need to connect to "notify::active" signal for Switch widget to process changing of its state. The guides say I shouldn't use onActivate signal, but "notify:act