Re: Simple way to handle rvalues and templates.

2022-02-26 Thread Ali Çehreli via Digitalmars-d-learn
On 2/26/22 19:38, Chris Piker wrote: > But this doesn't work: > ```d > import std.bitmanip, std.system; > ubyte[8192] data; > > ushort us = data[4..6].read!(ushort, Endian.bigEndian); > ``` > The reasons for this are probably old hat for seasoned D programmers by > this is really confusing for

Simple way to handle rvalues and templates.

2022-02-26 Thread Chris Piker via Digitalmars-d-learn
Hi D I have bit of code that was tripping me up. I need to parse small fields out of a big binary read, and it looks like some operations just can't be composed when it comes to using templates. So this works: ```d import std.bitmanip, std.system; ubyte[8192] data; ubyte[] temp =

Re: Source code for vibe.d listenTCP()

2022-02-26 Thread Chris Piker via Digitalmars-d-learn
On Sunday, 27 February 2022 at 01:45:35 UTC, Adam D Ruppe wrote: and my website also offers a "see implementation" link at the bottom which has some inline code navigation jump links too to help. Yes! Freaking awesome! This needs to be a link on the regular D pages, or at least in the package

Re: Source code for vibe.d listenTCP()

2022-02-26 Thread Adam D Ruppe via Digitalmars-d-learn
On Saturday, 26 February 2022 at 22:25:46 UTC, Chris Piker wrote: Anyway if someone can just help me find the source code to listenTCP inside vibe.d I'd be grateful. My dpldocs.info search engine is not great right now but it can sometimes help find these things:

Re: Source code for vibe.d listenTCP()

2022-02-26 Thread max haughton via Digitalmars-d-learn
On Saturday, 26 February 2022 at 22:25:46 UTC, Chris Piker wrote: Hi D I'm trying out the vibe.d framework for the first time and it looks like many of the functions mutate some hidden global state. Take for example `listenTCP`. To help me build a mental picuture of the framework I'd like

Re: Source code for vibe.d listenTCP()

2022-02-26 Thread Chris Piker via Digitalmars-d-learn
On Saturday, 26 February 2022 at 22:25:46 UTC, Chris Piker wrote: Anyway if someone can just help me find the source code to listenTCP inside vibe.d I'd be grateful. Sorry to reply to myself, but I found the function. It was separated out into a separate package:

Source code for vibe.d listenTCP()

2022-02-26 Thread Chris Piker via Digitalmars-d-learn
Hi D I'm trying out the vibe.d framework for the first time and it looks like many of the functions mutate some hidden global state. Take for example `listenTCP`. To help me build a mental picuture of the framework I'd like to see what global state is mutated, but for the life of me I

Re: How to get instance member value from getSymbolsByUDA

2022-02-26 Thread max haughton via Digitalmars-d-learn
On Saturday, 26 February 2022 at 17:06:06 UTC, Remi Thebault wrote: On Saturday, 26 February 2022 at 12:01:14 UTC, max haughton wrote: Getting the UDAs from inside a symbol must be done via a recursive procedure in the same manner one would identify the aforementioned symbol i.e. you have to

Re: How to get instance member value from getSymbolsByUDA

2022-02-26 Thread Remi Thebault via Digitalmars-d-learn
On Saturday, 26 February 2022 at 12:01:14 UTC, max haughton wrote: Getting the UDAs from inside a symbol must be done via a recursive procedure in the same manner one would identify the aforementioned symbol i.e. you have to go through the fields looking for UDAs *then* use getUDAs. This

Re: Detecting ElementType of OutputRange

2022-02-26 Thread Vijay Nayar via Digitalmars-d-learn
On Saturday, 26 February 2022 at 12:39:51 UTC, Stanislav Blinov wrote: Considering that `put` is quite typically implemented as a template, I don't think that would be possible in general. That is what I found as well, for example, the implementation of `put` from `Appender` and

Re: Detecting ElementType of OutputRange

2022-02-26 Thread Stanislav Blinov via Digitalmars-d-learn
On Saturday, 26 February 2022 at 12:26:21 UTC, Vijay Nayar wrote: On Saturday, 26 February 2022 at 11:44:35 UTC, Stanislav Blinov wrote: https://dlang.org/phobos/std_range_primitives.html#isOutputRange This method requires the caller to explicitly declare the output range element type, which

Re: Detecting ElementType of OutputRange

2022-02-26 Thread Vijay Nayar via Digitalmars-d-learn
On Saturday, 26 February 2022 at 11:44:35 UTC, Stanislav Blinov wrote: https://dlang.org/phobos/std_range_primitives.html#isOutputRange This method requires the caller to explicitly declare the output range element type, which I was hoping to have to avoid, if it can be detected using

Re: How to get instance member value from getSymbolsByUDA

2022-02-26 Thread max haughton via Digitalmars-d-learn
On Saturday, 26 February 2022 at 11:38:16 UTC, Remi Thebault wrote: On Saturday, 26 February 2022 at 11:26:54 UTC, max haughton wrote: On Saturday, 26 February 2022 at 10:39:18 UTC, Remi Thebault wrote: Hi all, I'm trying to establish a REST API by using the type system (used in both client

Re: Detecting ElementType of OutputRange

2022-02-26 Thread Stanislav Blinov via Digitalmars-d-learn
https://dlang.org/phobos/std_range_primitives.html#isOutputRange

Detecting ElementType of OutputRange

2022-02-26 Thread Vijay Nayar via Digitalmars-d-learn
I was working on a project where it dealt with output ranges, but these ranges would ultimately sink into a source that would be inefficient if every single `.put(T)` call was made one at a time. Naturally, I could make a custom OutputRange for just this resource, but I also got the idea that

Re: How to get instance member value from getSymbolsByUDA

2022-02-26 Thread Remi Thebault via Digitalmars-d-learn
On Saturday, 26 February 2022 at 11:26:54 UTC, max haughton wrote: On Saturday, 26 February 2022 at 10:39:18 UTC, Remi Thebault wrote: Hi all, I'm trying to establish a REST API by using the type system (used in both client and server code). [...]

Re: How to get instance member value from getSymbolsByUDA

2022-02-26 Thread max haughton via Digitalmars-d-learn
On Saturday, 26 February 2022 at 10:39:18 UTC, Remi Thebault wrote: Hi all, I'm trying to establish a REST API by using the type system (used in both client and server code). [...] https://dlang.org/phobos/std_traits.html#getUDAs

How to get instance member value from getSymbolsByUDA

2022-02-26 Thread Remi Thebault via Digitalmars-d-learn
Hi all, I'm trying to establish a REST API by using the type system (used in both client and server code). Considering the code ```d struct Request { Method method; string url; int apiLevel; } @Request(Method.GET, "/my-resource/%s", 1) struct MyResourceGet { @Param