Re: cmake-d and gdc/gdmd compiler
On Tuesday, 4 April 2017 at 18:42:45 UTC, timvol wrote: Hi guys, I'm trying to cross-compile a project using CMake and gdc (or better: the gdmd port). My CMakeLists-file is the following: For cross-compiling, CMake uses a so called "toolchain" file [1] where you define the system paths similar to the target system. I confess that never cross-compiled any code with cmake-d, but in principle it should work. Dragos [1] https://cmake.org/cmake/help/v3.7/manual/cmake-toolchains.7.html#cross-compiling-for-linux
'_input' field not found in MapResult
After minimizing a more complex program I got the following small example that produces a rather strange error. The error says that MapResult has no field '_input' although the sole MapResult definition has such a field. What is the explanation for this error? ``` auto foo(T)(T ) { import std.algorithm : joiner, map; import std.array : array; enum a = "x".map!(j => `"".map!(y => y.foo)`); enum b = a.joiner; enum c = b.array; return mixin("[" ~ c ~ "]"); } void main() { foo("abc"); } ``` Compiler output (dmd 2.073.2): % rdmd foo.d /usr/include/dmd/phobos/std/algorithm/iteration.d(580): Error: couldn't find field _input of type const(char[]) in MapResult("x", null) /usr/include/dmd/phobos/std/algorithm/iteration.d(580): called from here: empty(this._input) /usr/include/dmd/phobos/std/algorithm/iteration.d(2402): called from here: this._items.empty() /usr/include/dmd/phobos/std/algorithm/iteration.d(2453): called from here: Result(MapResult, null).this(r) foo.d(8):called from here: joiner(MapResult("x", null)) foo.d-mixin-11(11): Error: template instance foo.foo!dchar error instantiating /usr/include/dmd/phobos/std/algorithm/iteration.d(593): instantiated from here: __lambda3!dchar /usr/include/dmd/phobos/std/algorithm/iteration.d(488): instantiated from here: MapResult!(__lambda3, string) foo.d-mixin-11(11):instantiated from here: map!string foo.d(16):instantiated from here: foo!string Failed: ["dmd", "-v", "-o-", "foo.d", "-I."]
Re: How to split a string/array with multiple separators?
On Wednesday, 16 December 2015 at 14:18:28 UTC, Borislav Kosharov wrote: I want to split a string using multiple separators. In std.array the split function has a version where it takes a range as a separator, but it works differently than what I want. Say if I call it with " -> " it will search for the whole thing together. I want to pass split a list of separators say [":", ",", ";"] and if it finds any of those to split it. Sorry if this questions is stupid but I cant find how to do it. void main() { import std.stdio: writeln; writeln("abc,def;ghi".splitter!(a => !":,;".find(a).empty).array); }
Re: No Unix socket support?
On Wednesday, 29 July 2015 at 13:39:33 UTC, simendsjo wrote: Is there no Unix socket support in Phobos? Or vibe? Or any other library? I've found some discussions: * https://issues.dlang.org/show_bug.cgi?id=9384 * http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/10870/ , but it seems there are no support yet. With the exception of the abstract type [1] it should work just fine. [1] http://man7.org/linux/man-pages/man7/unix.7.html
Re: Fastest Way of Accessing Entries in an AA
On Thursday, 8 January 2015 at 15:45:27 UTC, Nordlöw wrote: Is key in aa ? aa[key] : ValueType.init; the most efficient way to maybe return a value from an associative array aa? aa.get(key, ValueType.init)
Re: Member access of __gshared global object
This describes the semantics of regular arrays. Are you sure it also applies to AAs? I thought they will keep referring to the same data once they are initialized. But I might be mistaken... This can be easily tested. And... you are right! In the current implementation (I couldn't find any specification) the AA contains just a pointer[1]. I suppose that initially this pointer is null and on copy the pointer is copied, so that after initialization any change of the copy is visible in the original. [1] https://github.com/D-Programming-Language/druntime/blob/master/src/rt/aaA.d#L82-85
Re: Member access of __gshared global object
On Wednesday, 6 August 2014 at 14:36:23 UTC, Marc Schütz wrote: This would defeat the purpose, see the original post. sorry, I red just the last post. __gshared has no influence on this. auto cmds = CONFIG.commands; cmds["list"] = new Command(...); cmds is a thread local variable referencing the shared AA. But if you add new elements to cmds, cmd will be reallocated and the shared AA will remain unchanged. Though, updated values of existing keys will be visible in the original, because no relocation takes place. If you want to change the original you need a pointer or a reference (for a setter function). auto cmds = &CONFIG.commands; (*cmds)["list"] = new Command(...);
Re: Member access of __gshared global object
1. The only way that I can initialize it is to assign a value. But I want to initialize an empty AA, is that possible? Like arrays, associative arrays have value semantics. This means that they can be always referenced. It is easier to see this with an array: int[] a1 = null; writeln(a1.ptr); writeln(a1.length); will print "null" and 0; The array is in fact a pair: ptr and length. The pair is allocated like any other primitive or struct and thus cannot be null. This means if you want an empty AA you can write aa1 = null; or more explicit aa1 = typeof(aa1).init; 2. CONFIG.commands is not `null` before initialized, it is '[]'(when I writeln it). But it still behave like what you described (except that it won't produce an NullPointer Exception. See 1.
Re: CMake for D
Any alternatives?? I moved cmaked2 to github [1], updated and simplified the usage a little (system cmake patch not necessary anymore). You can give it a try. Dub registry support is also on the way. Regards Dragos [1] - https://github.com/dcarp/cmake-d