Re: dub doesn't work with dmd 1:2.082.0-1.0?
On Thursday, 13 September 2018 at 14:31:53 UTC, Jesse Phillips wrote: Can you find /usr/bin/dmd or run dmd? Sorry if I wasn't clear enough, but I have dmd installed, and dub WAS working until upgrade of dmd. I suspect that problem occurs because dub wasn't upgraded from 1.10 -> 1.11, due to some problems with ArchLinux32 packaging - dub doesn't have dmd as dependency, probably because it doesn't require dmd specifically, but there is a 'provide' thingy that all D compiler packages have, so that's one way to fix this - to add this thingy as dependecy to dub, but maintainers seem to have problems with building newer versions of dub for 32-bit OS, the are already discussing this issue, so yeah, problem is not in dub/dmd itself (never suspected it to be), but rather, in compatability with 32 bit systems or between themselves. If anyone here is good with building dub, please take a look at this thread: https://bbs.archlinux32.org/viewtopic.php?pid=5004 , maybe you will be able to help?
Re: dub doesn't work with dmd 1:2.082.0-1.0?
On Thursday, 13 September 2018 at 06:11:53 UTC, rmc wrote: There don't seem to be any changes to dub or dmd directly related to this error perhaps its a packaging issue? I really don't know, looks like it, but it's really weird, like, why and what exactly happened? I'll try asking same question on ArchLinux32 forums - maybe, maintainer forgot something or I dunno. Just out of curiosity; Why are you using ArchLinux32? Pretty old laptop, only supports i686 systems. I don't really need anything else as I only use it for some hobby programming when I'm away from my desktop.
dub doesn't work with dmd 1:2.082.0-1.0?
dub was working nice until I updated my system (I run ArchLinux32) just now. dmd was updated from version 1:2.081.2-1.0 to 1:2.082.0-1.0 (according to pacman package manager). After that, I couldn't invoke dub for anything. Here is the attempt to run `dub --vverbose`: ``` Using dub registry url 'https://code.dlang.org/' Refreshing local packages (refresh existing: true)... Looking for local package map at /var/lib/dub/packages/local-packages.json Looking for local package map at /home/superprower/.dub/packages/local-packages.json Try to load local package map at /home/superprower/.dub/packages/local-packages.json iterating dir /home/superprower/.dub/packages/ iterating dir /home/superprower/.dub/packages/ entry ncurses-master iterating dir /home/superprower/.dub/packages/ entry local-packages.json iterating dir /home/superprower/.dub/packages/ entry d-profile-viewer-1.1.3 No package found in current working directory. Failed to invoke the compiler /usr/bin/dmd to determine the build platform: Error: missing or null command line arguments Full exception: object.Exception@source/dub/compilers/compiler.d(127): Failed to invoke the compiler /usr/bin/dmd to determine the build platform: Error: missing or null command line arguments ??:? pure @safe bool std.exception.enforce!().enforce!(bool).enforce(bool, lazy const(char)[], immutable(char)[], uint) [0xa744bd] ??:? dub.platform.BuildPlatform dub.compilers.compiler.Compiler.probePlatform(immutable(char)[], immutable(char)[][], immutable(char)[]) [0x80759e] ??:? dub.platform.BuildPlatform dub.compilers.dmd.DMDCompiler.determinePlatform(ref dub.compilers.buildsettings.BuildSettings, immutable(char)[], immutable(char)[]) [0x81323f] ??:? [0x810de2] ??:? void dub.commandline.PackageBuildCommand.setupPackage(dub.dub.Dub, immutable(char)[], immutable(char)[]) [0x910e46] ??:? int dub.commandline.GenerateCommand.execute(dub.dub.Dub, immutable(char)[][], immutable(char)[][]) [0x92b158] ??:? int dub.commandline.RunCommand.execute(dub.dub.Dub, immutable(char)[][], immutable(char)[][]) [0x92b0ab] ??:? int dub.commandline.runDubCommandLine(immutable(char)[][]) [0x9f87e3] ??:? _Dmain [0x9fe3bf] ``` I downgraded dmd for now, but what may be the cause of this? I couldn't find anything related to this particular error (`missing or null command line arguments`).
Re: Returning dynamic array from the function?
On Saturday, 8 September 2018 at 10:05:31 UTC, rikki cattermole wrote: onReceive: "The event handler that receives incoming data. Be sure to copy the incoming ubyte[] since it is not guaranteed to be valid after the callback returns." It could be a buffer on the stack, either way, .dup it before you cast. Yeah, it worked, thank you. I knew it was something trivial like that. It appears I slightly misunderstood by this paragraph https://dlang.org/spec/arrays.html#array-copying - I missed that slice operator is supposed to be on the left-side rather than right (I thought adding `[]` to the `data` would do the trick). Also, is this me and my bad English, or first comment in code in this paragraph (linked above, not in the discussion) is supposed to be something different? Shouldn't it be reference?
Re: Returning dynamic array from the function?
On Saturday, 8 September 2018 at 09:36:21 UTC, rikki cattermole wrote: We're going to need to see a minified version of the code to see what you're doing. Sure, here it is: ``` auto getBoards() { string[] boardList; auto url = baseUrl ~ "/api/v2/boards"; auto http = HTTP(url); http.method = HTTP.Method.get; http.onReceive = (ubyte[] data) { auto content = cast(string) data[]; boardList = strip(content, "[", "]").split(","); foreach (ref b; boardList) { b = strip(b, `"`); } return data.length; }; http.perform(); writeln(boardList); return boardList; } ``` This is a member function of some class. It doesn't really have any fields, so I left if out. In it, I use curl library to getch some data and split it. Next, I try to use this function to get this list: ``` Fetcher fetcher = new Fetcher; auto boards = fetcher.getBoards(); writeln(boards); ``` I printed array twice: inside the function and after return. Here is the output: ``` ["a", "burg", "cyb", "d", "lain", "mu", "new", "tech", "test", "u", "v", "all"] [x"F9"c, x"FA 01 00 00"c, "\0\0\0", "d", "lain", "mu", "new", "tech", "test", "u", "v", "all"] ``` As you can see, when outside of the funtion, first few elements of the array contain garbage. I would like to know both why this happens and how do I avoid it (i.e. what is the correct way of returning dynamic array).
Returning dynamic array from the function?
I have a function that produces dynamic array of strings. I would like to return this array from this function. I understand that dynamic arrays are of reference type, and thus if I try to return array variable, I will actually return a pointer to the first element of the array on the heap. Problem is, when I return dynamic array and try to print it outside of the function, I see garbage in a first few elements. My humble experience with languages like C++ doesn't really help with understanding how Garbage Collector (if it's because of it, because if I understand correctly, I can imagine memory being de-allocated because we get out of scope of local variable that points to the array, thus there are no more pointers to this memory, thus it gets de-allocated, but we still return reference to this memory, so GC shouldn't really free it?) can cause this - can anyone please explain me what's exactly going on and what would be the proper way to return dynamic array from the function? Thanks in advance.