View previous topic :: View next topic |
Author |
Message |
Linker
Joined: 06 Nov 2006 Posts: 29 Location: Almaty, Kazakhstan
|
Posted: Tue Jul 03, 2007 1:19 pm Post subject: Little announcement/Help needed |
|
|
I've made some progress in development. The new version will be available soon. It will include Pluecker and Quaternion classes, and some more.
However, I have more and more questions raising in my mind.
One terrible thing is the lack of constant references in D. Does anyone know how to handle it? For some time, all the functions that take structures as parameters had their parameters passed by value (yes, copying the contents all over).
Is this fine or not? I guess not, so I placed 'ref' everywhere I found. The thing is that 'ref' allows parameter to change, while most of the time parameters are constant.
How is this handled in D? Right now I have some nasty hacks in my code to pass 'const Vec3 vec3_zero = ...' to a function like 'void foo( ref Vec3 v )'. If I do a copy of vec3_zero, then compiler shuts up, but since a temporary is created, it should be sort of constant... (this is just my intuition )
I've just stumbled across DMD 2.0. DMD 1.XX and DMD 2.XX: two different compilers? Can anybody shed some light on this? |
|
Back to top |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Tue Jul 03, 2007 2:04 pm Post subject: |
|
|
passing structs by reference has been a long-standing thorn in side for D, since they are implicitly read/write (as you note). The big change for DMD 2.0 is a rewrite of the const/invariant/final semantics, part of which will support passing read-only structs by reference. However, the 2.0 compiler is experimental at this time -- stick with ref for now, and rely on documentation to ensure the users don't write to those structs |
|
Back to top |
|
|
Linker
Joined: 06 Nov 2006 Posts: 29 Location: Almaty, Kazakhstan
|
Posted: Wed Jul 04, 2007 11:34 am Post subject: |
|
|
I've tried that DMD 2.0 final-const-invariant system, and it works just fine, though I've stumbled upon crash-bugs in compiler.
So I'm doing as you described. Thanks. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|