Re: std.conv:to that does not throw?

2025-01-31 Thread Kyle Ingraham via Digitalmars-d-learn
On Friday, 31 January 2025 at 22:42:14 UTC, Kyle Ingraham wrote: On Thursday, 30 January 2025 at 17:19:19 UTC, Lance Bachmeier wrote: Have you looked at [mir.conv](http://mir-core.libmir.org/mir_conv.html) and [mir.parse](http://mir-algorithm.libmir.org/mir_parse.html)? I’ll give those a try

Re: std.conv:to that does not throw?

2025-01-31 Thread Kyle Ingraham via Digitalmars-d-learn
On Thursday, 30 January 2025 at 04:44:02 UTC, Jonathan M Davis wrote: What we really need is something like tryTo that returns a Nullable which has no value when the conversion fails, and then preferably, tryTo would share its implementation with to I like a Nullable return much more than what

Re: std.conv:to that does not throw?

2025-01-31 Thread Kyle Ingraham via Digitalmars-d-learn
On Thursday, 30 January 2025 at 17:19:19 UTC, Lance Bachmeier wrote: Have you looked at [mir.conv](http://mir-core.libmir.org/mir_conv.html) and [mir.parse](http://mir-algorithm.libmir.org/mir_parse.html)? I’ll give those a try tonight. At first glance I see mention of throwing so they may no

Re: std.conv:to that does not throw?

2025-01-29 Thread Kyle Ingraham via Digitalmars-d-learn
On Thursday, 30 January 2025 at 02:52:49 UTC, monkyyy wrote: its on my todo list for opend but isnt realisticly happening any time soon, I can suggest some patterns for setting up a cleaner `to` overloadset if you want to pick it up Much appreciated. I'd love some tips if you've got them.

Re: std.conv:to that does not throw?

2025-01-29 Thread Kyle Ingraham via Digitalmars-d-learn
On Thursday, 30 January 2025 at 02:08:49 UTC, Jonathan M Davis wrote: Unfortunately, there isn't currently a function like std.conv.to which does not throw. It's been suggested before, but it's never been implemented (and would probably require quite a bit of refactoring if we want to avoid cod

std.conv:to that does not throw?

2025-01-29 Thread Kyle Ingraham via Digitalmars-d-learn
Does D have a 'try' `std.conv:to` that does not throw if it fails? Something like: ```D string input = "9"; int output; auto parsed = input.tryTo!int(output); ``` `std.conv:to` is super flexible and does exactly what I need. However, hitting an exception for conversion failures really slows do

Re: NGINX Unit and vibe.d Integration Performance

2024-11-02 Thread Kyle Ingraham via Digitalmars-d-learn
On Monday, 28 October 2024 at 01:06:58 UTC, Kyle Ingraham wrote: I know vibe.d can do better so I'm thinking there's something I'm missing. Sönke Ludwig solved this for me here: https://github.com/vibe-d/vibe.d/issues/2807#issue-2630501194 The solution was to switch to a configuration for ev

Re: NGINX Unit and vibe.d Integration Performance

2024-10-31 Thread Kyle Ingraham via Digitalmars-d-learn
On Thursday, 31 October 2024 at 16:43:09 UTC, Kyle Ingraham wrote: ..I'll see if I can get images here of my profiling... Here are images as promised: - A flame graph - https://blog.kyleingraham.com/wp-content/uploads/2024/10/screenshot-2024-10-30-at-11.47.57e280afpm.png - A call tree - https

Re: NGINX Unit and vibe.d Integration Performance

2024-10-31 Thread Kyle Ingraham via Digitalmars-d-learn
On Thursday, 31 October 2024 at 16:43:09 UTC, Kyle Ingraham wrote: This approach increased requests processed per events emitted/waited from 1:1 to 10:1. This had no impact on event loop overhead however. The entire program still spends ~50% of its runtime in this function: https://github.com/

Re: NGINX Unit and vibe.d Integration Performance

2024-10-31 Thread Kyle Ingraham via Digitalmars-d-learn
On Monday, 28 October 2024 at 20:53:32 UTC, Salih Dincer wrote: On Monday, 28 October 2024 at 19:57:41 UTC, Kyle Ingraham wrote: - Polling too little killed performance and too often wrecked CPU usage. - Using message passing reduced performance quite a bit. - Batching reads was hard because

Re: NGINX Unit and vibe.d Integration Performance

2024-10-28 Thread Kyle Ingraham via Digitalmars-d-learn
On Monday, 28 October 2024 at 18:37:18 UTC, Salih Dincer wrote: Apparently, vibe.d's event loop is not fully compatible with NGINX Unit's loop, causing performance loss. I wonder if it would be wise to use something like an IntrusiveQueue or task pool to make it compatible? For example, somethi

Re: NGINX Unit and vibe.d Integration Performance

2024-10-28 Thread Kyle Ingraham via Digitalmars-d-learn
On Monday, 28 October 2024 at 05:56:32 UTC, ryuukk_ wrote: ImportC is great It really is. Most of my time setting it up was on getting include and linking flags working. Which is exactly what you’d run into using C from C.

NGINX Unit and vibe.d Integration Performance

2024-10-27 Thread Kyle Ingraham via Digitalmars-d-learn
Hi there, I'm looking for help with the performance of an integration I'm trying to write between NGINX Unit and D. Here are two minimal demos I've put together: - https://github.com/kyleingraham/unit-d-hello-world (NGINX Unit/D) - https://github.com/kyleingraham/unit-vibed-hello-world (NGINX

Re: Hipreme's Tip of of the day #09 - Using D shared libraries with dub

2023-09-09 Thread Kyle Ingraham via Digitalmars-d-learn
On Monday, 4 September 2023 at 23:57:03 UTC, Hipreme wrote: Hello again! -- As of some requests in DConf, I'll post here some things related (or not) to dub recipes. Since there is so many ways to build D and dub is quite the main way, I'll try to show other uncommon ways to use it, this is m

Re: dub does not correctly link on Macbook Pro 2019 (intel)

2023-08-19 Thread Kyle Ingraham via Digitalmars-d-learn
On Saturday, 19 August 2023 at 22:53:53 UTC, Sergey wrote: On Saturday, 19 August 2023 at 21:35:25 UTC, Alexander wrote: Completely new to D, and when trying to setup the toolchain, Could you please specify the versions of macOS and DMD? Probably DMD is broken for macOS - could you try to use

Re: dub does not correctly link on Macbook Pro 2019 (intel)

2023-08-19 Thread Kyle Ingraham via Digitalmars-d-learn
On Saturday, 19 August 2023 at 21:35:25 UTC, Alexander wrote: Completely new to D, and when trying to setup the toolchain, DMD seems to work fine, but dub is running into linker issues. On my Intel iMac I have to set `MACOSX_DEPLOYMENT_TARGET`: ``` MACOSX_DEPLOYMENT_TARGET=11 dub run ``` That

Re: Mir-algorithm tutorial?

2023-08-19 Thread Kyle Ingraham via Digitalmars-d-learn
On Saturday, 19 August 2023 at 08:59:40 UTC, Ferhat Kurtulmuş wrote: On Saturday, 19 August 2023 at 01:44:16 UTC, Kyle Ingraham wrote: On Friday, 18 August 2023 at 12:14:45 UTC, Ferhat Kurtulmuş wrote: I think the main problem is the mir libraries won't get updates since Ilya recently said that

Re: Mir-algorithm tutorial?

2023-08-18 Thread Kyle Ingraham via Digitalmars-d-learn
On Friday, 18 August 2023 at 12:14:45 UTC, Ferhat Kurtulmuş wrote: I think the main problem is the mir libraries won't get updates since Ilya recently said that he was not an open source developer anymore. That’s unfortunate for D but hopefully beneficial for Ilya. Was it said somewhere publi

Re: Linker Error with Template Function

2022-10-15 Thread Kyle Ingraham via Digitalmars-d-learn
On Saturday, 1 October 2022 at 21:18:05 UTC, Ali Çehreli wrote: On 10/1/22 11:15, Kyle Ingraham wrote: > storing structs as > `void*` in a wrapper struct with information about their module and > identifier saved elsewhere. Perhaps unrelated but that part reminded me of the following discussio

Re: Linker Error with Template Function

2022-10-01 Thread Kyle Ingraham via Digitalmars-d-learn
On Tuesday, 13 September 2022 at 08:43:45 UTC, Nick Treleaven wrote: On Tuesday, 13 September 2022 at 03:00:17 UTC, Kyle Ingraham wrote: Any suggestions for being able to call one function for any instance given but maintain flexible return types? Not sure if it helps, but you can define final

Re: Linker Error with Template Function

2022-09-12 Thread Kyle Ingraham via Digitalmars-d-learn
On Tuesday, 13 September 2022 at 01:46:14 UTC, Paul Backus wrote: On Tuesday, 13 September 2022 at 00:57:58 UTC, Kyle Ingraham wrote: I am writing a library where I would like to be able to store instances of a type of class to an associative array for later usage. Each class stored has to impl

Linker Error with Template Function

2022-09-12 Thread Kyle Ingraham via Digitalmars-d-learn
I am writing a library where I would like to be able to store instances of a type of class to an associative array for later usage. Each class stored has to implement a function as part of the required interface. The argument given is always the same type but the return value should be flexible

Re: Is there a way to

2022-09-12 Thread Kyle Ingraham via Digitalmars-d-learn
On Sunday, 11 September 2022 at 00:56:39 UTC, Adam D Ruppe wrote: On Sunday, 11 September 2022 at 00:32:18 UTC, Kyle Ingraham wrote: I can't use default parameters because I want to be able to call the delegate with arguments extracted from a URL path at runtime Some kind of wrapper might not

Re: Is there a way to

2022-09-10 Thread Kyle Ingraham via Digitalmars-d-learn
On Sunday, 11 September 2022 at 00:04:55 UTC, Adam D Ruppe wrote: On Saturday, 10 September 2022 at 23:37:30 UTC, Kyle Ingraham wrote: How can I write a type that is strict for the first two parameters but tolerant of any other parameter following those? That's not a type per se, but you can a

Is there a way to

2022-09-10 Thread Kyle Ingraham via Digitalmars-d-learn
Is there a way to write a delegate type as being specific for some parameters and tolerant of anything for others? For example, I can specify this type: ```d alias MyDelegateType = void delegate(string name, int age); ``` It would be compatible with a pointer to this function converted to a d

Re: A look inside "filter" function defintion

2022-08-14 Thread Kyle Ingraham via Digitalmars-d-learn
On Tuesday, 2 August 2022 at 12:39:41 UTC, pascal111 wrote: but I'm still stuck. Do you have a down-to-earth example for beginners to understand this concept? I often go back to this post when writing templates: https://dlang.org/blog/2020/07/31/the-abcs-of-templates-in-d/ It helped me when I

Re: How to make a new dub subpackage? [Answered]

2021-12-01 Thread Kyle Ingraham via Digitalmars-d-learn
Thanks for the writeup. How are you using this functionality?

Re: Payload Details with std.net.curl:post

2021-11-28 Thread Kyle Ingraham via Digitalmars-d-learn
On Sunday, 28 November 2021 at 07:27:35 UTC, ikod wrote: On Sunday, 28 November 2021 at 01:06:45 UTC, Kyle Ingraham wrote: On Saturday, 27 November 2021 at 22:18:48 UTC, ikod wrote: On Saturday, 27 November 2021 at 20:31:16 UTC, Kyle Ingraham Hi Kyle, ``` object.Exception@C:\Users\Kyle I

Re: Payload Details with std.net.curl:post

2021-11-27 Thread Kyle Ingraham via Digitalmars-d-learn
On Saturday, 27 November 2021 at 22:18:48 UTC, ikod wrote: On Saturday, 27 November 2021 at 20:31:16 UTC, Kyle Ingraham wrote: On Saturday, 27 November 2021 at 19:21:28 UTC, frame wrote: On Saturday, 27 November 2021 at 17:41:55 UTC, Kyle Ingraham wrote: I was afraid of that. Thank you for cl

Re: Payload Details with std.net.curl:post

2021-11-27 Thread Kyle Ingraham via Digitalmars-d-learn
On Saturday, 27 November 2021 at 19:21:28 UTC, frame wrote: On Saturday, 27 November 2021 at 17:41:55 UTC, Kyle Ingraham wrote: Is there a way to see that information? Google's API does not seem to provide much more than a status code as to the reason for the failure. No, and it's a shame t

Payload Details with std.net.curl:post

2021-11-27 Thread Kyle Ingraham via Digitalmars-d-learn
Happy Saturday everyone. I am using `std.net.curl:post` to request an OAuth access token from a Google API. Initially I was getting a 400 status code back but could not tell why. I used the `verbose` option on `HTTP()` to get more details: ```D char[] tokenResponse; auto connection = HTTP(); c

Re: regarding what seems (to me) unnecessary casts on integer expressions

2021-06-04 Thread Kyle Ingraham via Digitalmars-d-learn
On Saturday, 5 June 2021 at 00:24:01 UTC, someone wrote: On Saturday, 5 June 2021 at 00:24:01 UTC, someone wrote: ? 0 : cast(ushort)(this.pintBottom1 - 1); } It looks like you’re being caught by D’s arithmetic conversions: https://dlang.org/spec/type.html#usual-arithmetic-conversions “If th

Re: Does is(f == function) work?

2021-03-09 Thread Kyle Ingraham via Digitalmars-d-learn
On Tuesday, 9 March 2021 at 11:58:45 UTC, Andrey Zherikov wrote: On Tuesday, 9 March 2021 at 02:57:46 UTC, Adam D. Ruppe wrote: try is(typeof(f) == function) it is kinda weird but that's the trick Thanks! Should it work for in this case as well? alias f = (){}; writeln(typeof(f).stringof);

Re: Compile-Time Function Parameters That Aren't Types?

2021-02-25 Thread Kyle Ingraham via Digitalmars-d-learn
On Wednesday, 24 February 2021 at 20:15:08 UTC, Ali Çehreli wrote: On 2/23/21 7:52 PM, Kyle Ingraham wrote: Where would one find information on this There are Point and Polygon struct templates on the following page where one can pick e.g. the dimension (e.g. three dimensional space) by a s

Re: Compile-Time Function Parameters That Aren't Types?

2021-02-24 Thread Kyle Ingraham via Digitalmars-d-learn
On Wednesday, 24 February 2021 at 06:18:02 UTC, H. S. Teoh wrote: Usually it's when there's a decision that needs to be made at compile-time (or desirable to be made at compile-time for whatever reason). For example, if there are two very different branches of code that should run depending on

Re: Compile-Time Function Parameters That Aren't Types?

2021-02-23 Thread Kyle Ingraham via Digitalmars-d-learn
On Wednesday, 24 February 2021 at 03:57:37 UTC, Adam D. Ruppe wrote: On Wednesday, 24 February 2021 at 03:52:57 UTC, Kyle Ingraham wrote: The part that got my attention was `bool isBGR`. I was under the impression that compile-time or template parameters were only for types. No, you can pass

Compile-Time Function Parameters That Aren't Types?

2021-02-23 Thread Kyle Ingraham via Digitalmars-d-learn
I was reading the code for the DCV library and came across this function: https://github.com/libmir/dcv/blob/master/source/dcv/imgproc/color.d#L128 Here is a shortened form: [return type] rgbbgr2gray(bool isBGR, V)([run-time parameters]){[implementation]} and an example call: rgbbgr2gray!(tr

Re: Problem Computing Dot Product with mir

2021-02-22 Thread Kyle Ingraham via Digitalmars-d-learn
On Monday, 22 February 2021 at 07:14:26 UTC, 9il wrote: On Sunday, 21 February 2021 at 16:18:05 UTC, Kyle Ingraham wrote: I am trying to convert sRGB pixel values to XYZ with mir using the following guide: http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html [...] mir-glas is de

Problem Computing Dot Product with mir

2021-02-21 Thread Kyle Ingraham via Digitalmars-d-learn
I am trying to convert sRGB pixel values to XYZ with mir using the following guide: http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html My problem is that I cannot figure out how to calculate a dot product using mir. Here is my code: import std.stdio; import mir.glas.l1 : dot;

Re: struct constructor with rvalue param of same struct type

2021-01-18 Thread Kyle Ingraham via Digitalmars-d-learn
I’m sorry that this isn’t a solution to your problem but your code caught my attention. What is your snippet supposed to do?

Re: Simple BeamUI project won't link

2021-01-02 Thread Kyle Ingraham via Digitalmars-d-learn
On Friday, 18 December 2020 at 19:14:25 UTC, Daren Scot Wilson wrote: So maybe beamui isn't ready for the real world. It's a one-off personal tool for image processing, maybe will go up on Github, so I don't need anything super-solid or well established. OTOH, if it's too much on the WIP side

Re: D Bindings for C Opaque Pointers

2020-12-02 Thread Kyle Ingraham via Digitalmars-d-learn
On Thursday, 3 December 2020 at 01:19:05 UTC, bachmeier wrote: On Thursday, 3 December 2020 at 00:30:06 UTC, Kyle Ingraham wrote: What did I do wrong in constructing the bindings? If it helps the library provides a function called EdsRelease for cleaning-up allocated objects. Is the managemen

Re: D Bindings for C Opaque Pointers

2020-12-02 Thread Kyle Ingraham via Digitalmars-d-learn
On Thursday, 3 December 2020 at 00:58:20 UTC, Paul Backus wrote: On Thursday, 3 December 2020 at 00:30:06 UTC, Kyle Ingraham wrote: // EDSDKTypes.h typedef struct __EdsObject* EdsBaseRef; typedef EdsBaseRef EdsCameraListRef; // [...] // edsdk.d struct EdsBaseRef; alias EdsBaseRef EdsCameraL

D Bindings for C Opaque Pointers

2020-12-02 Thread Kyle Ingraham via Digitalmars-d-learn
Hello all. I am new to D and loving the experience so far. I am trying to make use of a C library from Canon that provides a header and a pre-compiled binary containing implementations of declarations found in the header. I used the excellent guide at https://www.gamedev.net/articles/programmi