Module import failing after $ dub add mypackage

2021-07-16 Thread Scotpip via Digitalmars-d-learn
Another newbie question I'm afraid. Trying to import and use my first package from the registry. I installed D from the Windows dmd-2.097.0.exe I created the project with ```$ dub init myproject``` In the project root I've run: ``` $ dub add msgpack-d Adding dependency msgpack-d ~>1.0.3

Re: No rdmd.exe in /bin64 on Windows - is this an issue?

2021-07-16 Thread Scotpip via Digitalmars-d-learn
On Friday, 16 July 2021 at 08:22:14 UTC, RazvanN wrote: On Monday, 12 July 2021 at 23:57:37 UTC, Scotpip wrote: Hi guys Just installed the DMD 2.097.0 .exe download for Windows on my 64 bit Win 10 workstation. [...] PR: https://github.com/dlang/installer/pull/484 Good work!

Re: Module import failing after $ dub add mypackage

2021-07-16 Thread rikki cattermole via Digitalmars-d-learn
On 17/07/2021 3:31 AM, Scotpip wrote: In dub.sdl I see: ```dependency "msgpack-d" version="~>1.0.3"``` In dub.selections.json I see: ``` { "fileVersion": 1, "versions": {     "msgpack-d": "1.0.3" } } ``` Okay, its been added to your dub project. So far so good. When I

Re: No rdmd.exe in /bin64 on Windows - is this an issue?

2021-07-16 Thread RazvanN via Digitalmars-d-learn
On Monday, 12 July 2021 at 23:57:37 UTC, Scotpip wrote: Hi guys Just installed the DMD 2.097.0 .exe download for Windows on my 64 bit Win 10 workstation. [...] PR: https://github.com/dlang/installer/pull/484

Re: opIndexUnary post in-/decrement how to ?

2021-07-16 Thread wjoe via Digitalmars-d-learn
On Thursday, 15 July 2021 at 15:39:59 UTC, Tejas wrote: On Thursday, 15 July 2021 at 13:28:19 UTC, wjoe wrote: On Thursday, 15 July 2021 at 12:09:20 UTC, Tejas wrote: [...] The only way, for me, to explain the error message ```opIndex isn't an lvalue and can't be modified.``` for

Re: Module import failing after $ dub add mypackage

2021-07-16 Thread Scotpip via Digitalmars-d-learn
On Friday, 16 July 2021 at 16:42:50 UTC, Mike Parker wrote: I did encounter some missing symbols, though (`ntohl` and `ntohs`) as msgpack-d isn't linking with Ws2-32.lib. I added `pragma(lib, "Ws2_32")` to the top of the file to resolve it. (And I filed an issue:

Re: Module import failing after $ dub add mypackage

2021-07-16 Thread Mike Parker via Digitalmars-d-learn
On Friday, 16 July 2021 at 17:14:12 UTC, Mike Parker wrote: I haven't had occasion to make use of any serialization libraries myself, but you can start here: https://wiki.dlang.org/Serialization_Libraries Also: https://code.dlang.org/search?q=serialization

Re: Hello world/Web server task on RosettaCode fails

2021-07-16 Thread jfondren via Digitalmars-d-learn
On Friday, 16 July 2021 at 20:04:21 UTC, jfondren wrote: static const greeting = q"EOF Or just `immutable greeting = ...`

Creating immutable arrays in @safe code

2021-07-16 Thread Dennis via Digitalmars-d-learn
I like passing around immutable data, but I don't like creating it. Here are some toy examples to illustrate: ```D immutable(int)[] positive(int[] input) @safe { return input.filter!(x => x > 0).array; } ``` Error: cannot implicitly convert expression `array(filter(input))` of type

Re: Creating immutable arrays in @safe code

2021-07-16 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jul 16, 2021 at 10:23:31PM +, Dennis via Digitalmars-d-learn wrote: > On Friday, 16 July 2021 at 20:45:11 UTC, H. S. Teoh wrote: > > Have you tried `pure`? > > The code in question is all `@safe pure nothrow`. Hmm, OK. Not sure why .array isn't being inferred as unique... but yeah,

Re: Creating immutable arrays in @safe code

2021-07-16 Thread Ali Çehreli via Digitalmars-d-learn
On 7/16/21 3:21 PM, Dennis wrote: > But `pure` is no silver bullet: Agreed. I occasionally struggle with these issues as well. Here is a related one: import std; void foo(const int[] a) { auto b = a.array; b.front = 42; // Error: cannot modify `const` expression `front(b)` } I think

Re: Creating immutable arrays in @safe code

2021-07-16 Thread Dennis via Digitalmars-d-learn
On Friday, 16 July 2021 at 20:45:11 UTC, H. S. Teoh wrote: Have you tried `pure`? The code in question is all `@safe pure nothrow`.

Re: Creating immutable arrays in @safe code

2021-07-16 Thread Dennis via Digitalmars-d-learn
On Friday, 16 July 2021 at 20:39:41 UTC, Ali Çehreli wrote: So to me, newly created data should be mutable for the most usability. It's clear that I stripped away too much context with the toy examples, so let me try to add some back. I don't like forcing the use of `immutable` in general,

Re: Module import failing after $ dub add mypackage

2021-07-16 Thread Mike Parker via Digitalmars-d-learn
On Friday, 16 July 2021 at 16:54:18 UTC, Scotpip wrote: Yup - I have it running now but the code does seem to be a bit neglected and I'm seeing a depreciation warning too. I chose it because it's much the most downloaded serialisation package and is used in a couple of other popular packages.

Re: Creating immutable arrays in @safe code

2021-07-16 Thread Ali Çehreli via Digitalmars-d-learn
On 7/16/21 1:19 PM, Dennis wrote: > I like passing around immutable data I think the D community needs to talk more about guidelines around 'immutable'. We don't... And I lack a complete understanding myself. :) To me, 'immutable' is a demand of the user from the provider that the data will

Re: Module import failing after $ dub add mypackage

2021-07-16 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jul 16, 2021 at 04:54:18PM +, Scotpip via Digitalmars-d-learn wrote: [...] > I simply need a fast binary serialisation lib to read and write a > large list of structs to local disk - it's not for inter-app > communication. The struct is simple and only contains primitive D data >

Hello world/Web server task on RosettaCode fails

2021-07-16 Thread btiffin via Digitalmars-d-learn
Using gdc-11 and Seamonkey. https://rosettacode.org/wiki/Hello_world/Web_server#D does not compile. ```d prompt$ gdc-11 helloServer.d helloServer.d:12:29: error: cannot cast expression currSock = listener.accept() of type std.socket.Socket to bool 12 | while(cast(bool)(currSock =

Re: Creating immutable arrays in @safe code

2021-07-16 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jul 16, 2021 at 08:19:32PM +, Dennis via Digitalmars-d-learn wrote: [...] > ```D > immutable(int)[] positive(int[] input) @safe > { > return input.filter!(x => x > 0).array; > } > ``` [...] > I could make another primitive (`iarraySort`), but I wonder if there > are more convenient

Re: Module import failing after $ dub add mypackage

2021-07-16 Thread Scotpip via Digitalmars-d-learn
On Friday, 16 July 2021 at 15:42:32 UTC, rikki cattermole wrote: ``$ dub build`` inside of ``myproject`` should work. Thanks - that was helpful. For anyone else with this issue I've figured out what went wrong. I had more than one main() function in the project - I was using the others as

Re: Module import failing after $ dub add mypackage

2021-07-16 Thread Mike Parker via Digitalmars-d-learn
On Friday, 16 July 2021 at 15:31:49 UTC, Scotpip wrote: I'm completely stuck till I can get this fixed, so any help would be very much appreciated! I used the example from the readme at: https://code.dlang.org/packages/msgpack-d which I pasted into the generated `app.d`. And all the

Re: Module import failing after $ dub add mypackage

2021-07-16 Thread Mike Parker via Digitalmars-d-learn
On Friday, 16 July 2021 at 16:44:31 UTC, Scotpip wrote: Again, if this helps anyone my current setup is to have a single main() in app.d. I changed the main() in my sandboxes to runSandbox(), and I import and run from app.d rather than directly. Or with a couple of keystrokes I can switch to

Re: Hello world/Web server task on RosettaCode fails

2021-07-16 Thread jfondren via Digitalmars-d-learn
On Friday, 16 July 2021 at 19:25:32 UTC, btiffin wrote: Using gdc-11 and Seamonkey. https://rosettacode.org/wiki/Hello_world/Web_server#D does not compile. The `while` as you noted is wrong. The server also doesn't turn REUSEADDR on for the server socket, so this will be very annoying to

Re: Hello world/Web server task on RosettaCode fails

2021-07-16 Thread btiffin via Digitalmars-d-learn
On Friday, 16 July 2021 at 20:04:21 UTC, jfondren wrote: On Friday, 16 July 2021 at 19:25:32 UTC, btiffin wrote: Using gdc-11 and Seamonkey. https://rosettacode.org/wiki/Hello_world/Web_server#D does not compile. The `while` as you noted is wrong. The server also doesn't turn REUSEADDR on

Re: Creating immutable arrays in @safe code

2021-07-16 Thread ag0aep6g via Digitalmars-d-learn
On 17.07.21 00:27, H. S. Teoh wrote: Hmm, OK. Not sure why .array isn't being inferred as unique... but yeah, you probably have to resort to using @trusted with .assumeUnique. In addition to `pure`, you also need a const/immutable input and a mutable output, so that the output cannot be a