D - in/inout Optimisation Question
- J Anderson (11/11) Jan 07 2004 What happens when you pass a struct into a function as "in" and only
- Walter (5/15) May 18 2004 The compiler can do either as long as the results are the same. Whether
- Denis R (4/4) Apr 09 2005 Hello,
- clayasaurus (7/15) Apr 09 2005 GDC can (http://home.earthlink.net/~dvdfrdmn/d/)
What happens when you pass a struct into a function as "in" and only read from that variable. ie struct foo {int x, y, z, w;} void func(in foo g) { int x = g.x; } Will the compiler optimise this to a reference, or will it copy the entire struct on to the stack? Am I better to use inout or a pointer? Anderson
Jan 07 2004
"J Anderson" <REMOVEanderson badmama.com.au> wrote in message news:bthn5h$2j1b$1 digitaldaemon.com...What happens when you pass a struct into a function as "in" and only read from that variable. ie struct foo {int x, y, z, w;} void func(in foo g) { int x = g.x; } Will the compiler optimise this to a reference, or will it copy the entire struct on to the stack? Am I better to use inout or a pointer?The compiler can do either as long as the results are the same. Whether using a pointer is faster or not depends on the details of the CPU, the size of the struct, how it's used inside the function, etc.
May 18 2004
Hello, I was wondering when will it be possible (I beleive its not yet supported) to create code for dynamically loaded libraries under linux/unix. That is, position independent code, like with the -fpic switch on gcc compiler. Also, will the dynamic library loading/unloading be part of the standard D ? So that you can use these libs same on windows and linux say.
Apr 09 2005
Denis R wrote:Hello, I was wondering when will it be possible (I beleive its not yet supported) to create code for dynamically loaded libraries under linux/unix. That is, position independent code, like with the -fpic switch on gcc compiler. Also, will the dynamic library loading/unloading be part of the standard D ? So that you can use these libs same on windows and linux say.GDC can (http://home.earthlink.net/~dvdfrdmn/d/) On windows there is std.loader, however loader isn't included in the linux libphobos.a for some reason, I don't know why, you can add it yourself by adding loader.d to the command line. The Derelict project has its own x-platform loader. (derelict.util.*) (www.dsource.org/projects/derelict)
Apr 09 2005