Re: How to make a struct containing an associative array to deeply copy (for repeated usage in foreach) ?

2024-03-15 Thread bachmeier via Digitalmars-d-learn
On Friday, 15 March 2024 at 20:36:56 UTC, rkompass wrote: I'm quite new to D yet. But I have some acquaintance with Python. Therefore, together with templates the discovery of the Variant type was inspiring me to the following: I wanted to explore if it's possible to do sort of type-agnostic

Re: How to make a struct containing an associative array to deeply copy (for repeated usage in foreach) ?

2024-03-15 Thread rkompass via Digitalmars-d-learn
On Friday, 15 March 2024 at 17:15:56 UTC, monkyyy wrote: On Friday, 15 March 2024 at 09:03:25 UTC, rkompass wrote: @Monkyyy: I adopted your solution, it is perfect. I only have one problem left: The foreach loop with associative arrays has two cases: `foreach(key, val; arr)` and `foreach(x;

Re: Deriving a struct from another one via template: Easy way to propagate UDAs?

2024-03-15 Thread cc via Digitalmars-d-learn
On Thursday, 14 March 2024 at 23:19:37 UTC, Inkrementator wrote: I am trying to derive a struct from another. I want to modify each field such that type of it goes from some T to Nullable!T, preserving all fieldnames and UDAs. This is trivially easy if your types are visible at module level,

Re: dub: Could not resolve configuration for package demo

2024-03-15 Thread mw via Digitalmars-d-learn
On Friday, 15 March 2024 at 18:04:25 UTC, Inkrementator wrote: You'll have to either fix the old vibe-d version, or fork msgpack-rpc to work with current vibe-d, whatever is more appropriate and easier. I'm trying to fix it with the latest vibe-d 0.10.0, now the new error: ```

Re: dub: Could not resolve configuration for package demo

2024-03-15 Thread mw via Digitalmars-d-learn
On Friday, 15 March 2024 at 18:04:25 UTC, Inkrementator wrote: On Friday, 15 March 2024 at 17:48:26 UTC, mw wrote: ``` $ dub build Could not resolve configuration for package demo ``` Trying to build your dependency msgpack-rpc, it spits out ``` Warning The sub configuration directive

Re: dub: Could not resolve configuration for package demo

2024-03-15 Thread mw via Digitalmars-d-learn
OK, looks something wrong with dub / or vibe-d 0.10.0 https://github.com/msgpack-rpc/msgpack-rpc-d/blob/master/examples/with_http_server/dub.sdl#L5 with ``` dependency "vibe-d" version="~>0.7.25" ``` `dub build` can at least starts. But ``` dependency "vibe-d" version="~>0.10.0" ``` ``` $

Re: dub: Could not resolve configuration for package demo

2024-03-15 Thread Inkrementator via Digitalmars-d-learn
On Friday, 15 March 2024 at 17:48:26 UTC, mw wrote: ``` $ dub build Could not resolve configuration for package demo ``` Trying to build your dependency msgpack-rpc, it spits out ``` Warning The sub configuration directive "vibe-d" -> [libevent] references a configuration that does not

dub: Could not resolve configuration for package demo

2024-03-15 Thread mw via Digitalmars-d-learn
Very simple thing from https://dub.pm/getting-started/first-steps/ After I add dependencies, it cannot build: ``` $ cat dub.json { "authors": [ "mw" ], "copyright": "Copyright © 2024, mw", "description": "msgpack-rpc-d demo.", "license":

Re: Challenge: Make a data type for holding one of 8 directions allowing increment and overflow

2024-03-15 Thread Daniel N via Digitalmars-d-learn
On Tuesday, 12 March 2024 at 05:38:03 UTC, Liam McGillivray wrote: I am in need of a data type for holding direction information; one of 8 directions on a single axis. They are named in terms of compass directions. If D had a 4-bit datatype, I would just use this and do `+=2` whenever I want

Re: How to make a struct containing an associative array to deeply copy (for repeated usage in foreach) ?

2024-03-15 Thread monkyyy via Digitalmars-d-learn
On Friday, 15 March 2024 at 09:03:25 UTC, rkompass wrote: @Monkyyy: I adopted your solution, it is perfect. I only have one problem left: The foreach loop with associative arrays has two cases: `foreach(key, val; arr)` and `foreach(x; arr)`. In the second case only the values are iterated.

Re: How to make a struct containing an associative array to deeply copy (for repeated usage in foreach) ?

2024-03-15 Thread rkompass via Digitalmars-d-learn
@Monkyyy: I adopted your solution, it is perfect. I only have one problem left: The foreach loop with associative arrays has two cases: `foreach(key, val; arr)` and `foreach(x; arr)`. In the second case only the values are iterated. With the present solution the iteration delivers (key, val)