How does __traits and std.traits differ?

2015-07-24 Thread WhatMeWorry via Digitalmars-d-learn
Looking at the online documentation, it says: __traits are extensions to the language to enable programs, at compile time, to get at information internal to the compiler. std.traits are Templates which extract information about types and symbols at compile time. Do they both basically do

Re: How does __traits and std.traits differ?

2015-07-24 Thread Jacob Carlborg via Digitalmars-d-learn
On 2015-07-24 09:16, WhatMeWorry wrote: Looking at the online documentation, it says: __traits are extensions to the language to enable programs, at compile time, to get at information internal to the compiler. std.traits are Templates which extract information about types and symbols at

Re: Measuring Execution time

2015-07-24 Thread Yazan D via Digitalmars-d-learn
There is also http://linux.die.net/man/2/sched_setaffinity if you want to do it programmatically.

Re: Measuring Execution time

2015-07-24 Thread Yazan D via Digitalmars-d-learn
On Thu, 23 Jul 2015 16:43:01 +, Clayton wrote: On Wednesday, 22 July 2015 at 09:32:15 UTC, John Colvin wrote: On Wednesday, 22 July 2015 at 09:23:36 UTC, Clayton wrote: [...] The normal way of doing this would be using std.datetime.StopWatch: StopWatch sw; sw.start();

Re: How do you make a copy TO and object when you're INSIDE of it?

2015-07-24 Thread via Digitalmars-d-learn
Apart from what others have said, for a class `this` is the _reference_ to the current object, i.e. a pointer. If the compiler allowed assigning to it, it would not modify the contents of your object. If you want to assign all of the elements at once, you can use `tupleof` (untested):

Re: GLU in DerelictOrg

2015-07-24 Thread Spacen Jasset via Digitalmars-d-learn
On Wednesday, 22 July 2015 at 00:49:29 UTC, Mike Parker wrote: On Tuesday, 21 July 2015 at 16:34:35 UTC, Spacen Jasset wrote: On Tuesday, 21 July 2015 at 15:17:13 UTC, Alex Parrill wrote: On Tuesday, 21 July 2015 at 14:51:47 UTC, John Colvin wrote: Isn't glu considered legacy these days? I

Dynamic memory

2015-07-24 Thread Binarydepth via Digitalmars-d-learn
How do we get dynamic memory in D ? I want to use memory based on user input. In this case declare a bi-dimensional array (int[2][var]), var being the user input.

Re: How do you make a copy TO and object when you're INSIDE of it?

2015-07-24 Thread via Digitalmars-d-learn
On Friday, 24 July 2015 at 14:12:54 UTC, Steven Schveighoffer wrote: On 7/24/15 4:47 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: Apart from what others have said, for a class `this` is the _reference_ to the current object, i.e. a pointer. If the compiler allowed assigning to it,

Re: Dynamic memory

2015-07-24 Thread Binarydepth via Digitalmars-d-learn
On Friday, 24 July 2015 at 15:26:27 UTC, Adam D. Ruppe wrote: On Friday, 24 July 2015 at 15:22:15 UTC, Binarydepth wrote: I want to use memory based on user input. In this case declare a bi-dimensional array (int[2][var]), var being the user input. Declare: int[2][] your_array;

Re: Dynamic memory

2015-07-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 24 July 2015 at 15:33:45 UTC, Binarydepth wrote: int liCases [2][]; Those brackets are in the wrong place, you should write that as int[2][] liCases; The syntax you used there is a deprecated C compatibility feature. in C, arrays are defined differently and the dimensions go in

Re: How do you make a copy TO and object when you're INSIDE of it?

2015-07-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/24/15 4:47 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net wrote: Apart from what others have said, for a class `this` is the _reference_ to the current object, i.e. a pointer. If the compiler allowed assigning to it, it would not modify the contents of your object. If you want to

Re: Dynamic memory

2015-07-24 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 24 July 2015 at 15:22:15 UTC, Binarydepth wrote: I want to use memory based on user input. In this case declare a bi-dimensional array (int[2][var]), var being the user input. Declare: int[2][] your_array; your_array.length = var; The runtime will handle the dynamic memory

Re: Dynamic memory

2015-07-24 Thread Binarydepth via Digitalmars-d-learn
On Friday, 24 July 2015 at 15:26:27 UTC, Adam D. Ruppe wrote: On Friday, 24 July 2015 at 15:22:15 UTC, Binarydepth wrote: I want to use memory based on user input. In this case declare a bi-dimensional array (int[2][var]), var being the user input. Declare: int[2][] your_array;

Re: GLU in DerelictOrg

2015-07-24 Thread Alex Parrill via Digitalmars-d-learn
On Friday, 24 July 2015 at 12:56:29 UTC, Spacen Jasset wrote: Thanks Mike, that's fair enough. I shall just implement the functions I need I think until such time as I end up using the newer OpenGL 3 stuff. If you want, you can steal from Mesa's GLU implementation here:

Re: Sending an immutable object to a thread

2015-07-24 Thread Ali Çehreli via Digitalmars-d-learn
On 07/23/2015 06:48 AM, Frank Pagliughi wrote: So, passing a pointer to a stack-based reference from one thread is another is not necessarily a good thing to do, as the original reference might disappear while the thread is using it. Right. Is there a way to get the address of the actual

Re: How does __traits and std.traits differ?

2015-07-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, July 24, 2015 07:16:41 WhatMeWorry via Digitalmars-d-learn wrote: Looking at the online documentation, it says: __traits are extensions to the language to enable programs, at compile time, to get at information internal to the compiler. std.traits are Templates which extract

Re: Sending an immutable object to a thread

2015-07-24 Thread anonymous via Digitalmars-d-learn
On Friday, 24 July 2015 at 18:55:26 UTC, Frank Pagliughi wrote: So then, of course, I hope/wonder/assume that the pointer to the heap is sufficient to keep the heap memory alive, and that this would be OK from the GC perspective to do something like this: B* make_b_thing(int i) { cast(B*)

Re: Sending an immutable object to a thread

2015-07-24 Thread Frank Pagliughi via Digitalmars-d-learn
On Friday, 24 July 2015 at 18:02:58 UTC, Ali Çehreli wrote: Although the example casts to void*, ubyte* and others are possible as well, and casting back to the correct class type seems to work: Thanks, Ali. I just tried a few things, and apparently, you don't need to go to a different type

Re: Sending an immutable object to a thread

2015-07-24 Thread Frank Pagliughi via Digitalmars-d-learn
On Friday, 24 July 2015 at 19:28:35 UTC, anonymous wrote: I haven't followed the discussion, so I may be missing the point here. I started by asking how to send a reference to an immutable class object from one thread to another if the reference is one of several parameters being sent. The

Re: Sending an immutable object to a thread

2015-07-24 Thread anonymous via Digitalmars-d-learn
On Friday, 24 July 2015 at 21:51:44 UTC, Frank Pagliughi wrote: So then: is there a pointer notation to which you can cast the B reference, which thus points to the heap, but retains type identity of the heap object? There's no straight forward way to do that. D has no types for the actual