Passing myself, a struct, as a C callback context

2015-03-29 Thread Paul O'Neil via Digitalmars-d-learn
I'm registering a callback with some C code. The simplified story is here, but the actual code is on GitHub [1] at the end if you care. The call looks something like this. void register(void(*fp)(void*), void* context); I have a class that holds state for the callback and registers itself:

Re: Specify an entire directory tree for string imports

2015-03-29 Thread Baz via Digitalmars-d-learn
On Monday, 30 March 2015 at 02:13:22 UTC, Alex Parrill wrote: I have a directory structure like this: . | test.d | \---test | test1.txt | \---subfolder test2.txt I am running test.d using this command:

Re: Passing myself, a struct, as a C callback context

2015-03-29 Thread weaselcat via Digitalmars-d-learn
On Monday, 30 March 2015 at 02:53:36 UTC, Paul O'Neil wrote: As of dmd 2.067, doing this is deprecated. where is this documented? I don't see it in the release notes.

Re: Specify an entire directory tree for string imports

2015-03-29 Thread Rikki Cattermole via Digitalmars-d-learn
On 30/03/2015 3:51 p.m., Baz wrote: On Monday, 30 March 2015 at 02:13:22 UTC, Alex Parrill wrote: I have a directory structure like this: . | test.d | \---test | test1.txt | \---subfolder test2.txt I am running test.d using this

D1 operator overloading in D2

2015-03-29 Thread ketmar via Digitalmars-d-learn
it's still working. moreover, it is used in Phobos! and yet it's not documented anywhere. what i want to know is whether they will be removed for good, or brought back and properly documented? the current situation is awful: compiler has special treatment for some aggregate members, but

Re: std.logger sharedLog usage

2015-03-29 Thread lobo via Digitalmars-d-learn
On Sunday, 29 March 2015 at 12:37:23 UTC, Robert burner Schadek wrote: On Sunday, 29 March 2015 at 01:36:24 UTC, lobo wrote: Hi, I'm trying to use std.experimental.logger and I'd like the logf(), tracef() style functions to log to a file and stdout. (note: I can use sharedLog.logf(),

Re: final switch on Algebraic

2015-03-29 Thread Meta via Digitalmars-d-learn
On Sunday, 29 March 2015 at 23:19:31 UTC, Freddy wrote: Is there any way to do a final switch statement in std.variant's Algebraic. Not currently. However, std.variant.visit is probably what you want. It enforces that you handle all types contained in the Algebraic. import std.variant;

Re: Passing myself, a struct, as a C callback context

2015-03-29 Thread Paul O'Neil via Digitalmars-d-learn
On 03/29/2015 10:57 PM, weaselcat wrote: On Monday, 30 March 2015 at 02:53:36 UTC, Paul O'Neil wrote: As of dmd 2.067, doing this is deprecated. where is this documented? I don't see it in the release notes. I don't see it in the release notes either, but it's happening. Maybe it's an

Re: Passing myself, a struct, as a C callback context

2015-03-29 Thread ketmar via Digitalmars-d-learn
On Sun, 29 Mar 2015 22:53:35 -0400, Paul O'Neil wrote: I'm registering a callback with some C code. The simplified story is here, but the actual code is on GitHub [1] at the end if you care. The call looks something like this. void register(void(*fp)(void*), void* context); I have a

Re: reinterpret_cast float to uint

2015-03-29 Thread ketmar via Digitalmars-d-learn
On Sun, 29 Mar 2015 17:33:02 +, Namespace wrote: On Sunday, 29 March 2015 at 16:29:40 UTC, ketmar wrote: On Sun, 29 Mar 2015 16:00:05 +, matovitch wrote: On Sunday, 29 March 2015 at 14:50:24 UTC, ketmar wrote: On Sun, 29 Mar 2015 13:45:10 +, matovitch wrote: you can also use

Specify an entire directory tree for string imports

2015-03-29 Thread Alex Parrill via Digitalmars-d-learn
I have a directory structure like this: . | test.d | \---test | test1.txt | \---subfolder test2.txt I am running test.d using this command: rdmd -Jtest test.d I can do `import(test1.txt)` from

Re: Associative Array of Const Objects?

2015-03-29 Thread ketmar via Digitalmars-d-learn
On Sun, 29 Mar 2015 20:29:49 +, bitwise wrote: The verbosity and blatant disregard for DRY makes me CRY. See what I did there.. ;) you can always `alias` it to something funny or obscene. signature.asc Description: PGP signature

Re: Passing myself, a struct, as a C callback context

2015-03-29 Thread lobo via Digitalmars-d-learn
On Monday, 30 March 2015 at 02:53:36 UTC, Paul O'Neil wrote: I'm registering a callback with some C code. The simplified story is here, but the actual code is on GitHub [1] at the end if you care. The call looks something like this. void register(void(*fp)(void*), void* context); I have a

Re: DerelictGL3.reload() returns wrong (?) GLVersion (GL32, should be 33)

2015-03-29 Thread Rene Zwanenburg via Digitalmars-d-learn
On Sunday, 29 March 2015 at 01:27:01 UTC, Koi wrote: Hello, today i implemented OpenGL instancing, and it crashed when calling glVertexAttribDivisor (OpenGL 3.3). So i checked DerelictGL3.reload() and it returned GLVersion.GL32, not GL33. My graphic card (NVidia GT 240) should support

Re: reinterpret_cast float to uint

2015-03-29 Thread ketmar via Digitalmars-d-learn
On Sun, 29 Mar 2015 13:45:10 +, matovitch wrote: you can also use unions. signature.asc Description: PGP signature

Re: DerelictGL3.reload() returns wrong (?) GLVersion (GL32, should be 33)

2015-03-29 Thread Mike Parker via Digitalmars-d-learn
On 3/29/2015 10:26 AM, Koi wrote: Hello, today i implemented OpenGL instancing, and it crashed when calling glVertexAttribDivisor (OpenGL 3.3). So i checked DerelictGL3.reload() and it returned GLVersion.GL32, not GL33. My graphic card (NVidia GT 240) should support GL33 and an OpenGL

Re: DerelictGL3.reload() returns wrong (?) GLVersion (GL32, should be 33)

2015-03-29 Thread Koi via Digitalmars-d-learn
On Sunday, 29 March 2015 at 14:34:39 UTC, Rene Zwanenburg wrote: On Sunday, 29 March 2015 at 01:27:01 UTC, Koi wrote: How do you create your context? OpenGL version needs to be specified when creating it, for example when using GLFW: glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);

Re: reinterpret_cast float to uint

2015-03-29 Thread matovitch via Digitalmars-d-learn
On Sunday, 29 March 2015 at 14:50:24 UTC, ketmar wrote: On Sun, 29 Mar 2015 13:45:10 +, matovitch wrote: you can also use unions. Good idea ! In my case I think it was better to cast, but this could be helpful another time thanks ! :)

Re: Passing myself, a struct, as a C callback context

2015-03-29 Thread weaselcat via Digitalmars-d-learn
On Monday, 30 March 2015 at 03:02:07 UTC, Paul O'Neil wrote: On 03/29/2015 10:57 PM, weaselcat wrote: On Monday, 30 March 2015 at 02:53:36 UTC, Paul O'Neil wrote: As of dmd 2.067, doing this is deprecated. where is this documented? I don't see it in the release notes. I don't see it in

Re: reinterpret_cast float to uint

2015-03-29 Thread matovitch via Digitalmars-d-learn
On Sunday, 29 March 2015 at 13:39:47 UTC, matovitch wrote: Hi, floats are stored on 32 bits using ieee754...and I would like (for some obscure reason) to reinterpret a such float into a 32 bits uint (i.e without altering the memory). A simple : import std.stdio; void main() { float f =

Re: std.logger sharedLog usage

2015-03-29 Thread Robert burner Schadek via Digitalmars-d-learn
On Sunday, 29 March 2015 at 01:36:24 UTC, lobo wrote: Hi, I'm trying to use std.experimental.logger and I'd like the logf(), tracef() style functions to log to a file and stdout. (note: I can use sharedLog.logf(), sharedLog.tracef(), but I prefer just logf()) So I did this: shared static

reinterpret_cast float to uint

2015-03-29 Thread matovitch via Digitalmars-d-learn
Hi, floats are stored on 32 bits using ieee754...and I would like (for some obscure reason) to reinterpret a such float into a 32 bits uint (i.e without altering the memory). A simple : import std.stdio; void main() { float f = 0.5; uint i = cast(uint)(f); writeln(i); } doesn't

Re: reinterpret_cast float to uint

2015-03-29 Thread ketmar via Digitalmars-d-learn
On Sun, 29 Mar 2015 16:00:05 +, matovitch wrote: On Sunday, 29 March 2015 at 14:50:24 UTC, ketmar wrote: On Sun, 29 Mar 2015 13:45:10 +, matovitch wrote: you can also use unions. Good idea ! In my case I think it was better to cast, but this could be helpful another time thanks !

Re: reinterpret_cast float to uint

2015-03-29 Thread Namespace via Digitalmars-d-learn
On Sunday, 29 March 2015 at 16:29:40 UTC, ketmar wrote: On Sun, 29 Mar 2015 16:00:05 +, matovitch wrote: On Sunday, 29 March 2015 at 14:50:24 UTC, ketmar wrote: On Sun, 29 Mar 2015 13:45:10 +, matovitch wrote: you can also use unions. Good idea ! In my case I think it was better to

Re: Associative Array of Const Objects?

2015-03-29 Thread bitwise via Digitalmars-d-learn
I'm a little confused at this point why this doesn't work either: const(Test) test = new Test(); // fine test = new Test(); // error In C++, There is a clear distinction: const Test *test1 = nullptr; // const before type test1 = new Test(); // fine Test

Re: OT; Donald Knuth on beauty, efficiency, and the programmer as artist

2015-03-29 Thread Laeeth Isharc via Digitalmars-d-learn
The whole art/science vein of these Knuth quotes seems like a lot of BS, trying to situate computer programming in the long-standing and overblown science/humanities divide. I should like to see an argument rather than mere assertion. Steve Jobs is not an authority on this subject, but I

Re: Associative Array of Const Objects?

2015-03-29 Thread bitwise via Digitalmars-d-learn
perhaps something like Rebindable could be used. Looking at Rebindable now, there is a useful example. There should probably be a mention of this on the const/immutable docs. For people coming from C++, this will not be obvious. auto a = Rebindable!(const Widget)(new Widget); a.y();

Re: Associative Array of Const Objects?

2015-03-29 Thread bearophile via Digitalmars-d-learn
bitwise: I'm a little confused at this point why this doesn't work either: const and immutable are rather different between C++ and D, I suggest you to take a look at the documentation: http://dlang.org/const-faq.html Bye, bearophile

Re: OT; Donald Knuth on beauty, efficiency, and the programmer as artist

2015-03-29 Thread Laeeth Isharc via Digitalmars-d-learn
On Saturday, 28 March 2015 at 09:04:51 UTC, Messenger wrote: On Saturday, 28 March 2015 at 01:09:44 UTC, Laeeth Isharc wrote: On Friday, 27 March 2015 at 11:33:39 UTC, Kagamin wrote: Hmm... science exists only as long as we don't understand something, then it disappears and only knowledge

Re: OT; Donald Knuth on beauty, efficiency, and the programmer as artist

2015-03-29 Thread Joakim via Digitalmars-d-learn
On Sunday, 29 March 2015 at 18:05:28 UTC, Laeeth Isharc wrote: I appreciate that many of us have better things to do. But I had been thinking about why I find D appealing, and how I would get this across to future partners, and had also been thinking about various forum comments equating

Re: OT; Donald Knuth on beauty, efficiency, and the programmer as artist

2015-03-29 Thread Joakim via Digitalmars-d-learn
On Friday, 27 March 2015 at 06:31:40 UTC, Laeeth Isharc wrote: In this talk I shall try to explain why I think Art is the appropriate word. I will discuss what it means for something to be an art, in contrast to being a science; I will try to examine whether arts are good things or bad things;

Re: Associative Array of Const Objects?

2015-03-29 Thread bitwise via Digitalmars-d-learn
On Sunday, 29 March 2015 at 19:04:30 UTC, anonymous wrote: Notice how you have that '*' there that allows you to distinguish the data from the reference. You can have a mutable pointer to const data in D, too: struct Test {} const(Test)* test1 = null; test1 = new Test; /* fine */

Re: Associative Array of Const Objects?

2015-03-29 Thread bitwise via Digitalmars-d-learn
Although, I suppose this is still a step up from C# which has not const at all =O

Re: OT; Donald Knuth on beauty, efficiency, and the programmer as artist

2015-03-29 Thread Laeeth Isharc via Digitalmars-d-learn
On Sunday, 29 March 2015 at 18:51:19 UTC, Joakim wrote: On Sunday, 29 March 2015 at 18:05:28 UTC, Laeeth Isharc wrote: I appreciate that many of us have better things to do. But I had been thinking about why I find D appealing, and how I would get this across to future partners, and had also

Re: OT; Donald Knuth on beauty, efficiency, and the programmer as artist

2015-03-29 Thread Joakim via Digitalmars-d-learn
On Sunday, 29 March 2015 at 18:41:36 UTC, Laeeth Isharc wrote: The whole art/science vein of these Knuth quotes seems like a lot of BS, trying to situate computer programming in the long-standing and overblown science/humanities divide. I should like to see an argument rather than mere

Re: Associative Array of Const Objects?

2015-03-29 Thread anonymous via Digitalmars-d-learn
On Sunday, 29 March 2015 at 19:13:32 UTC, bitwise wrote: Interesting, but I still don't understand why D doesn't have something like this: const Test test;// or const(Test) test; test = new Test() // fine, underlaying data is const, the reference is not Test const test = new Test();

Re: Associative Array of Const Objects?

2015-03-29 Thread bitwise via Digitalmars-d-learn
1) Such placement based syntax is foreign to D. I would have to agree that this is a strange way to do things in any language. The great int* a vs int *a debate... 2) It would be special syntax just for class types. IMO, it would be worth it 3) It's not how C++ rolls. `const Test test;`

Re: Associative Array of Const Objects?

2015-03-29 Thread anonymous via Digitalmars-d-learn
On Sunday, 29 March 2015 at 18:43:32 UTC, bitwise wrote: I'm a little confused at this point why this doesn't work either: const(Test) test = new Test(); // fine test = new Test(); // error In C++, There is a clear distinction: const Test *test1 = nullptr; // const

Extracting Sorted Storage from BinaryHeap

2015-03-29 Thread Nordlöw
What's the most efficient way to extract a the storage from a BinaryHeap and then sort it? Is there a better way other than binaryHeap.release.sort than makes use of the heap property? For example while (!binaryHeap.empty) { sortedStorage ~= binaryHeap.front;

Re: Associative Array of Const Objects?

2015-03-29 Thread anonymous via Digitalmars-d-learn
On Sunday, 29 March 2015 at 20:29:50 UTC, bitwise wrote: 3) It's not how C++ rolls. `const Test test;` and `Test const test;` are equivalent in C++. You need that '*' in C++, too, to make a distinction between reference and data. I'm a little confused. I was comparing a C++ pointer-to-class

Re: Extracting Sorted Storage from BinaryHeap

2015-03-29 Thread Ivan Kazmenko via Digitalmars-d-learn
On Sunday, 29 March 2015 at 20:05:22 UTC, Nordlöw wrote: What's the most efficient way to extract a the storage from a BinaryHeap and then sort it? Is there a better way other than binaryHeap.release.sort than makes use of the heap property? For example while (!binaryHeap.empty)

final switch on Algebraic

2015-03-29 Thread Freddy via Digitalmars-d-learn
Is there any way to do a final switch statement in std.variant's Algebraic.