Installing DMD on Windows

2023-10-20 Thread Quirin Schroll via Digitalmars-d-learn
I recently removed Visual Studio 2017 and upgraded to 2022. When I installed the latest DMD, it told me it couldn’t find a Visual Studio installation and offered me to download e.g. Visual Studio 2019 or just VS 2019 Build Tools, etc. Unsure what to do, I thought VS 2019 Build Tools is

Re: to delete the '\0' characters

2022-09-23 Thread Quirin Schroll via Digitalmars-d-learn
On Thursday, 22 September 2022 at 10:53:32 UTC, Salih Dincer wrote: Is there a more accurate way to delete the '\0' characters at the end of the string? Accurate? No. Your code works. Correct is correct, no matter efficiency or style. I tried functions in this module:

Re: How to workaround on this (bug?)

2022-09-23 Thread Quirin Schroll via Digitalmars-d-learn
On Friday, 16 September 2022 at 22:43:43 UTC, frame wrote: ```d import std.variant; // error: destructor `std.variant.VariantN!32LU.VariantN.~this` is not `nothrow` void fun(Variant v) nothrow { } void main() { fun(Variant()); } ``` A reference, pointer or slice works. I could do

How to do alligned allocation?

2022-09-30 Thread Quirin Schroll via Digitalmars-d-learn
When I do `new void[](n)`, is that buffer allocated with an alignment of 1 or what are the guarantees? How can I set an alignment? Also, is the alignment of any type guaranteed to be a power of 2?

Is there a way to get a template’s parameters and constraints?

2023-01-20 Thread Quirin Schroll via Digitalmars-d-learn
Is there a trait (or a combination of traits) that gives me the constraints of a template? Example: ```D void f(T1 : long, T2 : const(char)[])(T x) { } template constraintsOf(alias templ) { /*Magic here*/ } alias constraints = constraintsOf!f; // tuple(long, const(char)[]) ``` At the moment, I

Given an object, how to call an alias to a member function on it?

2023-05-02 Thread Quirin Schroll via Digitalmars-d-learn
How do I invoke the member function in a reliable way? Given `obj` of the type of the object, I used `mixin("obj.", __traits(identifier, memberFunc), "(params)")`, but that has issues, among probably others, definitely with visibility. (The member function alias is a template parameter.)

Re: Given an object, how to call an alias to a member function on it?

2023-05-04 Thread Quirin Schroll via Digitalmars-d-learn
On Wednesday, 3 May 2023 at 11:38:46 UTC, Adam D Ruppe wrote: On Tuesday, 2 May 2023 at 13:57:23 UTC, Steven Schveighoffer wrote: Isn't that what `__traits(child)` is for? https://dlang.org/spec/traits.html#child Yes, `__traits(child, object, method_alias)(args)` is the way to do it. This

Re: How to deal with interdependent dlang PRs?

2023-05-26 Thread Quirin Schroll via Digitalmars-d-learn
On Thursday, 25 May 2023 at 20:18:08 UTC, Dennis wrote: On Thursday, 25 May 2023 at 15:37:00 UTC, Quirin Schroll wrote: Is there a process? I can’t be the first one running into this. Doing it in 3 PRs is the process. Okay. It’s not that bad. This is one of the reasons why druntime was

Re: How to use Dub and Digger to build Pull Requests?

2023-05-24 Thread Quirin Schroll via Digitalmars-d-learn
On Tuesday, 23 May 2023 at 13:52:15 UTC, Vladimir Panteleev wrote: On Tuesday, 23 May 2023 at 13:50:09 UTC, Quirin Schroll wrote: ``` object.Exception@%LOCALAPPDATA%\dub\packages\ae-0.0.3236\ae\sys\d\manager.d(898): Command ["make", "-f", "win32.mak", "MODEL=32",

How to deal with interdependent dlang PRs?

2023-05-25 Thread Quirin Schroll via Digitalmars-d-learn
I have 2 PRs, [one on dlang/dlang.org](https://github.com/dlang/dlang.org/pull/3446) and [one on dlang/dmd](https://github.com/dlang/dmd/pull/15245). The latter fails a test because an example on the (current) dlang.org fails. The dlang.org PR changes the example, and fails likewise it’s

How to use Dub and Digger to build Pull Requests?

2023-05-23 Thread Quirin Schroll via Digitalmars-d-learn
The dlang-bot writes a message to every PR: Testing this PR locally If you don't have a local development environment setup, you can use Digger to test this PR: ```bash dub run digger -- build "master + dmd#<>" ``` I installed the current DMD (version 2.103.1) and executed the above

Re: How to use Dub and Digger to build Pull Requests?

2023-05-23 Thread Quirin Schroll via Digitalmars-d-learn
On Tuesday, 23 May 2023 at 13:50:09 UTC, Quirin Schroll wrote: The dlang-bot writes a message to every PR: Testing this PR locally If you don't have a local development environment setup, you can use Digger to test this PR: ```bash dub run digger -- build "master + dmd#<>" ``` I

Re: How can overloads be distinguished on attributes alone?

2023-08-01 Thread Quirin Schroll via Digitalmars-d-learn
On Monday, 31 July 2023 at 18:15:25 UTC, Jonathan M Davis wrote: On Monday, July 31, 2023 4:55:44 AM MDT Quirin Schroll via Digitalmars-d-learn wrote: Apparently, functions can be overloaded solely distinguished by attributes: ```d void f(ref int x) pure { x = 1; } void f(ref int x) { x

How can overloads be distinguished on attributes alone?

2023-07-31 Thread Quirin Schroll via Digitalmars-d-learn
Apparently, functions can be overloaded solely distinguished by attributes: ```d void f(ref int x) pure { x = 1; } void f(ref int x) { x = 2; static int s; ++s; } ``` I thought that, maybe, a `pure` context calls the `pure` function and an impure context calls the impure function, but no:

How to set linkage?

2023-12-20 Thread Quirin Schroll via Digitalmars-d-learn
In the DMD compiler frontend, the type `TypeFunction` (cf. astbase.d) representing a function type has a `linkage` member. Setting this member when parsing seems to have no effect. How do I set the linkage of a function type? For alias declarations which support setting function type

opApply seems like it can infer delegate types AND parameters!?

2023-12-11 Thread Quirin Schroll via Digitalmars-d-learn
In an attempt to come up with an [answer to a post](https://forum.dlang.org/post/dnsuyvnfcszwefsfz...@forum.dlang.org), I found something odd, but useful, that I nonetheless don’t understand. As far as I know – or rather thought I knew – `foreach` loops can infer the types of the “loop

Re: opApply seems like it can infer delegate types AND parameters!?

2023-12-11 Thread Quirin Schroll via Digitalmars-d-learn
On Monday, 11 December 2023 at 23:21:45 UTC, Quirin Schroll wrote: […] 1. Instead of implementing a function `opApply(scope int delegate(...))`, write a function template `opApplyImpl(DG)(scope int delegate(...))` (or whatever name) and let it take the delegate type as a template type