Re: Confusion over what types have value vs reference semantics
On Sunday, 11 September 2016 at 16:14:59 UTC, Mike Parker wrote: On Sunday, 11 September 2016 at 16:10:04 UTC, Mike Parker wrote: And here, no memory is allocated. barSlice.ptr is the same as bar.ptr and barSlice.length is the same as bar.length. However, if you append a new element: barSlice ~= 10; The GC will allocate memory for a new array and barSlice will no longer point to bar. It will now have four elements. I should clarify that this holds true for all slices, not just slices of static arrays. The key point is that appending to a slice will only allocate if the the .capacity property of the slice is 0. Slices of static arrays will always have a capacity of 0. Slices of slices might not, i.e. there may be room in the memory block for more elements. Thanks for the detailed answer. I still don't get the advantage of passing slices into functions by value allowing modification to elements of the original array. Is there an way to specify that a true independent copy of an array should be passed into the function? E.g, in c++ func(Vector v) causes a copy of the argument to be passed in.
Confusion over what types have value vs reference semantics
Hi, Are there universal rules that I can apply to determine what types have reference or value semantics? I know that for the basic primitive C types (int, bool, etc) has value semantics. In particular, I'm still trying to understand stack vs GC-managed arrays, and slices. Finally, I have an associative array, and I want to pass it into a function. The function is only reading data. Would putting ref on in function parameter pass it by reference?
Reading hexidecimal from a file
Hi, I want to read a text file that contains sha1 hashes in hexidecimal, then convert the hashes back into ubyte[20]. Examples of some lines: E9785DC5 D43B5F67 F1B7D1CB 33279B7C 284E2593 04150E8F 1840BCA2 972BE1C5 2DE81039 0C486F9C How can I do this? The documentation for format strings is pretty dense, so couldn't understand most of it.
Re: Library for serialization of data (with cycles) to JSON and binary
On Saturday, 6 August 2016 at 16:25:48 UTC, Ilya Yaroshenko wrote: On Saturday, 6 August 2016 at 16:11:03 UTC, Neurone wrote: Is there a library that can serialize data (which may contain cycles) into JSON and a binary format that is portable across operating systems? JSON: http://code.dlang.org/packages/asdf Binary: http://code.dlang.org/packages/cerealed "ASDF is currently only very loosely validating jsons and with certain functions even silently and on purpose ignoring failing Objects" Is there a way of turning this off?
Library for serialization of data (with cycles) to JSON and binary
Is there a library that can serialize data (which may contain cycles) into JSON and a binary format that is portable across operating systems?
Re: Using D in Games and bindings to c++ libraries
On Saturday, 6 August 2016 at 08:04:45 UTC, rikki cattermole wrote: On 06/08/2016 6:28 PM, Neurone wrote: On Saturday, 6 August 2016 at 04:01:03 UTC, rikki cattermole wrote: You can safely forget about RakNet by the looks. "While I still get some inquiries, as of as of March 13, 2015 I've decided to stop licensing so I can focus on changing the world through VR." So based upon this, what would you like to do? Scratch or another pre-existing protocol like proto-buffers? It is a mature library, which has been open sourced under the BSD license when Oculus baught it. Hence why I want to use this instead of reinventing the wheel. They really need to update its old website then. I've had a look at the code, its mostly classes and is very c style. You won't have trouble making bindings. The main steps if you want to give it a go are: 1. Compile via MSVC (either 32 or 64bit are fine) can be static of dynamic 2. Compile D with -m32mscoff or -m64 and link against above binary You will almost definitely want to use 64bit binaries not 32bit if you use dub. I know there is a D target for SWIG but I have never really used it. But I do not believe you need any magical tool to do the binding creation for you. The headers should convert over nicely as is for you. Do I use the DMD compiler? Also, would Dub not work with 64-bit executables? I still need to use 32-bit to support systems that aren't 64-bit yet. Also, is it possible to use D like a traditional scripting language? The use case is adding content to the server (which may contain D scripts) without restarting it for a full recompile.
Re: Using D in Games and bindings to c++ libraries
On Saturday, 6 August 2016 at 04:01:03 UTC, rikki cattermole wrote: You can safely forget about RakNet by the looks. "While I still get some inquiries, as of as of March 13, 2015 I've decided to stop licensing so I can focus on changing the world through VR." So based upon this, what would you like to do? Scratch or another pre-existing protocol like proto-buffers? It is a mature library, which has been open sourced under the BSD license when Oculus baught it. Hence why I want to use this instead of reinventing the wheel.
Using D in Games and bindings to c++ libraries
Hi, I have some experience with c++, and am considering using either D or python for a game. 1. It is going to be online-based, would D be a good choice for writing both the client and server? I haven't seen any online games using D yet. 2. A concern is interfacing with c++. I'll like to use the RakNet networking library, but there aren't any bindings for it. a) Are there instructions available for using Calypso on windows? Couldn't find any, and it looks like a good alternative to writing one by hand. b) How well would SWIG work? I haven't used multiple programming languages in a project before, so have no experience doing this sort of thing.