Re: How can one close issues fransferred from Bugzilla

2025-07-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thursday, 24 July 2025 at 18:31:58 UTC, Quirin Schroll wrote: For example, I originally filed [DMD#19271](https://github.com/dlang/dmd/issues/19271), but as far as GitHub is concerned, I’m not the author of that issue so I can’t close it. What’s the process for that? I can comment on that

Re: stdInputRange

2025-07-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sunday, 20 July 2025 at 20:26:02 UTC, Salih Dincer wrote: On Sunday, 20 July 2025 at 12:32:17 UTC, user1234 wrote: No problem here either. Where are you running the program from (embedded terminal in an editor ? a terminal emulator ?). Are you on Windows or Linux ? I want the program to en

Re: Is there some kind of Blocking Queue for D?

2025-07-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 12 July 2025 at 23:55:39 UTC, Ali Çehreli wrote: On 7/11/25 11:36 PM, Bienlein wrote: > Unhappily class MessageBox is private and therefore cannot be reused. Ah! :) That's one more data point against 'private', that little feature that helps with nothing. I don't know what langua

Re: Exception when creating a Thread with Windows

2025-07-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 5 July 2025 at 10:39:13 UTC, stef wrote: Hello, I'm totally new using D. I'm trying to create a thread using this code: ```d … extern (Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) … ``` I'm testing this program using

Re: How can I signal a master object that a resource handle is no longer used, from within the resource class's destructor?

2025-06-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 24 June 2025 at 08:48:16 UTC, realhet wrote: This is working in a normal use case: I create a Texture class insance, I store it's pointer and later when I press a key, I release the class pointer. But when I do not store the class pointer: `new Texture(...);` It just enters into

Re: Pointer vs Ref

2025-06-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 9 June 2025 at 07:24:41 UTC, confuzzled wrote: Hello community, Is it possible to accomplish the following using ref instead of pointers? If so, please share an example. ```d // Represents our Backtester engine struct Engine { // It STORES a pointer to its data source. This is

Re: Mixin template parameter overloading bug?

2025-06-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 14 June 2025 at 00:02:32 UTC, Andrey Zherikov wrote: The simplest code that shows the issue: ```d struct S{} template f(void function(S) F) {} template f(int function(S) F) {} mixin f!((_) {}); mixin f!((_) => 0); // Error: cannot return non-void from `void` function

Re: undefined reference to

2025-06-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 14 June 2025 at 00:25:13 UTC, mitgedanken wrote: I use ``dmd package.d -verrors=3 -debug -I"../.."``. I get ```sh Error: undefined reference to `std.container.array.Array!(minimal.token.token.Token).Array.empty() const` referenced from `const bool std.container.array.Array!

Re: Sanity check: pithiest test for static if: "is an array of ubyte"

2025-05-24 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 24 May 2025 at 20:29:52 UTC, Andy Valencia wrote: The best I"ve come up with for a "static if" to see if something's an array of ubyte: ```d (isArray!(typeof(arg))) && is(typeof(arg).init[0] == ubyte) ``` Which doesn't seem to work, but it's the closest I've come by poring over t

Re: Why is my image not rendering in a simple HTML page served with D?

2025-05-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sunday, 18 May 2025 at 21:40:17 UTC, Damjan wrote: Do I need to explicitly configure vibe.d to serve static files from the public folder? Yes https://vibed.org/api/vibe.http.fileserver/serveStaticFiles -Steve

Re: CTFE and RTFE results differ (aliasing)

2025-05-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 5 May 2025 at 17:15:57 UTC, kdevel wrote: ```d // // bs3.d // 2025-05-05 stvo // // $ dmd -g -checkaction=context -unittest -main -run bs3.d // bs3.d(25): [unittest] [4, 3, 3, 4] != [4, 3, 2, 1] ``` This is a bug, please report it. -Steve

Re: Subclass TcpSocket?

2025-03-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 18 March 2025 at 07:42:37 UTC, Jonathan M Davis wrote: The base class constructors are not nothrow, so WrappedTCP's constructor cannot be nothrow. There really isn't a way out of that, because if a constructor throws, the object's state is destroyed. So, catching and handling the Ex

Re: Noob ImportC questions

2025-02-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thursday, 27 February 2025 at 08:16:33 UTC, John C. wrote: On Thursday, 27 February 2025 at 08:10:04 UTC, John C. wrote: would removing some "hard to parse" constructs in header file help this situation? I tried to change ``` #define LIGHTGRAY CLITERAL(Color){ 200, 200, 200, 255 }

Re: What does a cast really do?

2025-02-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On Friday, 21 February 2025 at 13:07:38 UTC, Paul Backus wrote: On Friday, 21 February 2025 at 07:44:54 UTC, Jonathan M Davis wrote: I think that what it basically comes down to is that because -1 fits in int, and int implicitly converts to uint, VRP is fine with converting the long with a valu

Re: template struct question

2025-02-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On Wednesday, 12 February 2025 at 20:55:14 UTC, WhatMeWorry wrote: ```d void main() { struct HexBoard(F,I) { this(F d, I r, I c) {} //void displayHexBoard(HexBoard!(F,I) h) {} // this compiles fine! } void displayHexBoard(HexBoard!(F,I) h) {} // error undefined identifier F and I

Re: core.simd and dynamic arrays

2025-01-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sunday, 26 January 2025 at 12:56:55 UTC, ryuukk_ wrote: common sense would be to make sure you are up to date before wondering why it's broken This is the learn forum. People are learning here. Try to be nicer, there is no need for this. -Steve

Re: Obtaining an address given a (run time) variable name

2025-01-23 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 20 January 2025 at 19:03:09 UTC, DLearner wrote: // In the code below, what fn needs to go in the commented-out line, // to make the program print 7, 11 rather than 7, 7? You can't I don't think get a list of local variables at this point, but you can get a list of struct member n

Re: Template declaration of std.typecons.isTuple in -X JSON file.

2025-01-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On Wednesday, 15 January 2025 at 12:01:21 UTC, realhet wrote: Hello, I'm working on understanding and automating the contents of an X Json file generated by LDC2. I'm testing it by processing the whole Phobos lib. The weirdest thing that I've found is this: X Json: ``` ``` Is there somethi

Re: Selective import seems to be importing more than just specified symbol

2025-01-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On Wednesday, 8 January 2025 at 02:07:46 UTC, WhatMeWorry wrote: I thought that the line import honeycomb : Location; would only import the symbol struct Location? So imagine a `honeycomb.d` file that looks like this: ```d module honeycomb; import std.stdio; struct Location { int r;

Re: Why 'in' works only for assoc arrays?

2024-12-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On Friday, 27 December 2024 at 19:17:13 UTC, JN wrote: Why not make 'in' work for arrays (and strings also)? ``` int[string] phonebook; if ("John" in phonebook) // works int[] numbers; if (3 in numbers) // doesn't work, compiler recommends std.algorithm.find string buildLog; if ("build error

Re: Cross Compilation Guide for New Users

2024-12-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On Friday, 20 December 2024 at 09:03:22 UTC, Dan wrote: Hi Dlang forums. I ran into some problems when trying to cross compile. Hope this clarifies the set-up for anyone with the same problems. Additionally, perhaps these more explicit instructions / pitfalls could be put into the official [

Re: Virtual opBinary in interface

2024-12-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thursday, 19 December 2024 at 18:49:28 UTC, sfp wrote: Subject lines says it all, I think... The choice to make binary operators implementable only via this `opBinary` template means it's unclear how to get virtual operators on an interface. I am very new to D, and my goal is to learn how

Re: raylib-d how to program a simple moving circle.

2024-11-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 30 November 2024 at 02:16:35 UTC, Alain De Vos wrote: After installing raylib library on Debian , https://github.com/raysan5/raylib/releases Running "dub run" i get now the error : ``` dub run Fetching raylib-d 5.5.1 (getting selected version)... Performing "debug" build using /us

Re: raylib-d how to program a simple moving circle.

2024-11-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 30 November 2024 at 01:28:44 UTC, Alain De Vos wrote: vscode no longer complains. But "dub run" gives, ``` dub run Starting Performing "debug" build using /usr/bin/dmd for x86_64. Up-to-date raylib-d 5.5.1: target for configuration [library] is up to date. Building my

Re: raylib-d how to program a simple moving circle.

2024-11-29 Thread Steven Schveighoffer via Digitalmars-d-learn
On Friday, 29 November 2024 at 22:02:23 UTC, Alain De Vos wrote: On Friday, 29 November 2024 at 21:37:48 UTC, Alain De Vos wrote: I can do "dub add raylib-d" but i have no clue to program a simple moving circle. Following program has an import error ```d import std.stdio: writeln; import ra

Re: only parameters or stack-based variables can be `inout`

2024-11-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 25 November 2024 at 14:24:44 UTC, Bastiaan Veelo wrote: // Fishy: inout(E) gun(inout(E) e) { //writeln(e.to!string); // only parameters or stack-based variables can be `inout` writeln((cast(Unqual!E)e).to!string); // OK return e; } Longstanding issue. When inout was fi

Re: Is there a way to make a struct without a distinction between constant, immutable, and mutable?

2024-11-20 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 18 November 2024 at 23:43:46 UTC, Liam McGillivray wrote: Is there a way to make it so that this struct has only one qualifier? No distinction? Can you give an example of a problem and list the error messages? -Steve

Re: Capturing by value in the thread

2024-10-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On Friday, 18 October 2024 at 12:07:24 UTC, Kadir Erdem Demir wrote: It seems [=] functionality C++ does not exist in D. No, D does not have this functionality. By using a helper function I made that example work. ```d import std.stdio; auto localFoo(int x) { return (){ return x;}; }

Re: Why is this not allowed?

2024-10-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 8 October 2024 at 15:10:54 UTC, ryuukk_ wrote: Nonono, you overthink it Store last anonamous struct When you see a field without a type, you assign it with that anonymous struct It doesn't work this way. The parser would have to lookahead to see if the next 2 tokens are an iden

Re: Why is this not allowed?

2024-10-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sunday, 6 October 2024 at 05:41:10 UTC, ryuukk_ wrote: There is no new syntax to invent instead of writing this error: ``` onlineapp.d(8): Error: no identifier for declarator `stats` ``` you generate a random identifier and assign it ```D extern(D) static Identifier generateAnonymousId

Re: Why is this not allowed?

2024-10-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 5 October 2024 at 06:35:57 UTC, ryuukk_ wrote: Why is this allowed ```D struct EntityDef { struct { int hp; } } ``` But not this fucking thing? ```D struct EntityDef { struct { int hp; } stats; } ``` Let me name my shit No, i don't wan

Re: vibe-d linker error: undefined reference to deimos openssl

2024-09-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 10 September 2024 at 20:41:12 UTC, Curtis Spencer wrote: I'm attempting to upgrade the vibe-d dependencies of a project. The project compiles fine using `dub`, but the linker fails with: … I'm at a loss for how to fix this linker error. Any help would be appreciated. You may

Re: How to Humanize Numerical Input|Output

2024-09-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 9 September 2024 at 20:02:48 UTC, Jabari Zakiya wrote: Also for output, I do this: ``` writeln("total twins = ", twinscnt, "; last twin = ", last_twin - 1, "+/-1"); ``` I'd also like to output data as: 123,987 or 123_987 You can use separators using writefln: ```d writefln("%,

Re: How to Humanize Numerical Input|Output

2024-09-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 9 September 2024 at 20:02:48 UTC, Jabari Zakiya wrote: I have this code to input integer values: ``` ulong[] x; foreach (_; 0 .. 2) { ulong a; readf!" %d"(a); x ~= a; } end_num = max(x[0], 3); start_num = max(x[1], 3); if (start_num > end_num) swap(start_num, end_num); sta

Re: Associative Array, get value instead of poiter using `if (auto ..)`, possible?

2024-08-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 31 August 2024 at 12:47:25 UTC, ryuukk_ wrote: ```D void main() { int[string] test; test["hello"] = 42; if (auto it = "hello" in test) { } } ``` Is there a way to get the value instead of a pointer? while keeping the conciseness (one line) Maybe if(auto it

Re: importC error: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/mach/vm_types.h(168): Error: variable `lib_test.mach_vm_range_recipe_v1_

2024-08-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thursday, 8 August 2024 at 06:34:43 UTC, Dakota wrote: ```sh /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/mach/vm_types.h(168): Error: variable `lib_test.mach_vm_range_recipe_v1_t.range` - no definition of struct `mach_vm_range` /

Re: How to find the right function in the Phobos library?

2024-08-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 17 August 2024 at 05:28:37 UTC, Bruce wrote: What is the best way to search for a function in the Phobos library? Go to dlang.org, select dicumentation, then library reference. Pick any module, click on it In the upper right, switch the docs from stable to ddox Now you can use

Re: Performance O(??) for associative array lookup

2024-08-16 Thread Steven Schveighoffer via Digitalmars-d-learn
On Wednesday, 14 August 2024 at 07:48:58 UTC, Cecil Ward wrote: Does D give any guarantees for performance order-something ? What’s the current lib implementation like? It is amortized O(1), like most hash implementations. -Steve

Re: Get compile time string of dmd command line options "-os" & "-target"

2024-08-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 3 August 2024 at 12:15:46 UTC, Dennis wrote: On Thursday, 1 August 2024 at 04:00:08 UTC, An Pham wrote: pragma(msg, os.stringof...?); pragma(msg, target.stringof...?); There's no built-in way, but you can define it yourself in a helper module: ```D version(Windows) enum os

Re: importC error: can not find the #define ERR_INVALID -1

2024-08-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 3 August 2024 at 05:07:55 UTC, Dakota wrote: ```c #define ERR_SUCCESS 0 #define ERR_INVALID -1 // invalid argument ``` If the number >=0, it work. < 0 will not work. DMD64 D Compiler v2.110.0-beta.1 https://issues.dlang.org/show_bug.cgi?id=24639 -Steve

Re: std.container.rbtree has no search method?! e.g. `contains`, `canFind`

2024-07-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 13 July 2024 at 17:41:42 UTC, mw wrote: Hi, on doc: https://dlang.org/phobos/std_container_rbtree.html#.RedBlackTree I cannot find any search method?! e.g. `contains`, `canFind`. Is this a over look? Or there are such functions else where? The functions are called `equalRange`

Re: Wrapper around a recursive data type

2024-07-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 8 July 2024 at 08:56:51 UTC, drug007 wrote: How can I "break" this recursion or some other work around to fix it? A few ideas: 1. If it's immediately recursive (that is, contains a pointer to itself), just use the type itself somehow. You may not be able to do this with recursive

Re: Wrapper around a recursive data type

2024-07-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 8 July 2024 at 13:29:05 UTC, user1234 wrote: On Monday, 8 July 2024 at 08:56:51 UTC, drug007 wrote: I need to generate some meta info of my data types. I do it this [...] How can I "break" this recursion or some other work around to fix it? Use `Node*[]` for the children type. That

Re: Wrapper around a recursive data type

2024-07-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 9 July 2024 at 03:04:50 UTC, Steven Schveighoffer wrote: Can you post the error and the exact code that fails? I tried building this (with the children uncommented out) and it works fine. Ignore this, I didn't really read the whole message. -Steve

Re: Wrapper around a recursive data type

2024-07-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 8 July 2024 at 08:56:51 UTC, drug007 wrote: I need to generate some meta info of my data types. I do it this [way](https://gist.github.com/drug007/b0a00dada6c6ecbf46b4f6988401d4e2): ```D import std.range, std.format, std.stdio, std.traits; struct NestedType { string s; doubl

Re: Vibe.d v0.9.0, v0.10.0: ` dub init hello -t vibe.d` fails to build on MacOS

2024-07-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sunday, 7 July 2024 at 14:15:02 UTC, Ki Rill wrote: On Sunday, 7 July 2024 at 11:33:47 UTC, Sergey wrote: On Sunday, 7 July 2024 at 10:55:21 UTC, Ki Rill wrote: Machine: ``` MacBook Pro (Retina, 15-inch, Late 2013), macOS Big Sur version 11.7.10 ``` How should I solve this? It mentions un

Re: Why does this mixin fail to compile?

2024-07-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On Wednesday, 3 July 2024 at 11:57:58 UTC, Lance Bachmeier wrote: On Wednesday, 3 July 2024 at 03:52:41 UTC, Steven Schveighoffer wrote: And yes, it is faster to do this than appending. But you have to do a *lot* of it to make a huge difference. What about creating an array of strings and th

Re: Why does this mixin fail to compile?

2024-07-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 2 July 2024 at 07:23:42 UTC, ryuukk_ wrote: I said it 2 times already, i don't want string concatenation, i'll benchmark later, but not right now, right now i'm looking for a functioning code without string concatenation Your buffer solution works, but you need to put it inside a

Re: Default struct constructors if a struct member is a union

2024-07-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 29 June 2024 at 23:33:41 UTC, solidstate1991 wrote: My usecase scenario doesn't really allow constructors for the struct, since it's a binding to an external library via C API. BTW, this is not true. A constructor does not change the struct layout or anything about it from the C

Re: Default struct constructors if a struct member is a union

2024-07-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 29 June 2024 at 23:33:41 UTC, solidstate1991 wrote: ```d union U { int i32; long i64; float f32; double f64; } struct S { TypeEnum type; U data; } S foo0 = S(TypeEnum.Integer32, S(20)); //Ugly, but works S foo1 = S(TypeEnum.Integer64, S(20L)); //Error: cann

Re: aligned struct field weirdness

2024-06-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 18 June 2024 at 09:10:28 UTC, realhet wrote: I tried to narrow the problem, but I wasn't able, but I guess I've found another solution: There is a part in my framework which works with LDC2 1.28, but that's 'illegal' with later versions. Oh yeah. That is many versions ago! Release

Re: aligned struct field weirdness

2024-06-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 17 June 2024 at 19:45:18 UTC, realhet wrote: Hello, I'm having a weird case of access violation. Often times, you are focused on something that isn't the problem, but *triggers* the problem. Not saying it's not a compiler error, it could be. But chances are pretty low. If you c

Re: How to assign and compare arrays to SumType?

2024-06-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 11 June 2024 at 22:54:50 UTC, Steven Schveighoffer wrote: Let's see how it works if you want to both check that the value is a `double[]` and that it matches your value: ```d SumType!(double[], int) s = [1.7, 2.7, 3.7, 4.7, 5.7]; assert(s.data.match!( ``` This should be `s.match

Re: How to assign and compare arrays to SumType?

2024-06-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 11 June 2024 at 16:41:46 UTC, confuzzled wrote: Comparison between a Variant and an array is straightforward. How does one accomplish the same between a SumType and an array? ```d import std.variant; import std.sumtype; import std.stdio; struct S { SumType!(double[]) data; //

Re: How to use D without the GC ?

2024-06-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 11 June 2024 at 13:00:50 UTC, Vinod K Chandran wrote: Hi all, I am planning to write some D code without GC. But I have no prior experience with it. I have experience using manual memory management languages. But D has so far been used with GC. So I want to know what pitfalls it ha

Re: How to generate a random number from system clock as seed

2024-06-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 8 June 2024 at 13:19:30 UTC, Eric P626 wrote: I managed to create a random number generator using the following code: ~~~ auto rng = Random(42); // uniform(0,10,rng); ~~~ Now I want to seed the generator using system time. I looked at Date & time functions/classes and systime

Re: Trying to call some C code using Extern(C) but got unexpected linker error

2024-06-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 8 June 2024 at 02:22:00 UTC, Xiaochao Yan wrote: Hi, I am new to D and is experimenting with game development using D and C. I had some problem when trying to recreate the https://dlang.org/spec/importc.html Environment: Windows 11 gcc.exe (i686-posix-dwarf-rev0, Built by MinGW-W6

Re: bool passed by ref, safe or not ?

2024-06-04 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 4 June 2024 at 16:58:50 UTC, Basile B. wrote: question in the header, code in the body, execute on a X86 or X86_64 CPU ```d module test; void setIt(ref bool b) @safe { b = false; } void main(string[] args) { ushort a = 0b; bool* b = cast(bool*)&a; s

Re: Get milliseconds from time and construct time based on milliseconds

2024-05-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 28 May 2024 at 18:41:02 UTC, bauss wrote: On Tuesday, 28 May 2024 at 18:29:17 UTC, Ferhat Kurtulmuş wrote: On Tuesday, 28 May 2024 at 17:37:42 UTC, bauss wrote: I have two questions that I can't seem to find a solution to after looking at std.datetime. First question is how do I g

Re: Hide console on Windows with app running SDL2

2024-05-28 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 28 May 2024 at 12:35:42 UTC, bauss wrote: Running into a couple of problems trying to hide the console that opens when running an app that uses sdl2. First of all I am trying to compile with this using dub: ``` "lflags": ["/SUBSYSTEM:windows"] ``` However that gives me the followi

Re: __gshared is "somewhat" transitive, isn't it ?

2024-05-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thursday, 16 May 2024 at 17:04:09 UTC, user1234 wrote: Given ```d struct S { int member; } __gshared S s; ``` It's clear that `s.member` is `__gshared` too, right ? What does happen for ```d struct S { int member; static int globalMember; } __gshared S s; ``` Is then `S.globa

Re: D doesn't have weak references. So how can I make a associative array of objects without preventing their destruction?

2024-05-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On Friday, 10 May 2024 at 11:05:28 UTC, Dukc wrote: This also gets inferred as `pure` - meaning that if you use it twice for the same `WeakRef`, the compiler may reuse the result of the first dereference for the second call, without checking whether the referred value has changed! This wou

Re: "in" operator gives a pointer result from a test against an Associative Array?

2024-05-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On Friday, 10 May 2024 at 01:00:09 UTC, Andy Valencia wrote: On Friday, 10 May 2024 at 00:40:01 UTC, Meta wrote: Yes. The reason for this is that it avoids having to essentially do the same check twice. If `in` returned a bool instead of a pointer, after checking for whether the element exists

Re: TIL: statically initializing an Associative Array

2024-05-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 7 May 2024 at 00:10:27 UTC, Andy Valencia wrote: I had a set of default error messages to go with error code numbers, and did something along the lines of: string[uint] error_text = [ 400: "A message", 401: "A different message" ]; and got "expression is not a constant

Re: How can I put the current value of a variable into a delegate?

2024-05-06 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 6 May 2024 at 06:29:49 UTC, Liam McGillivray wrote: Delegates can be a pain, as they often have results different from what one would intuitively expect. This can easily result in bugs. Here's a line that caused a bug that took me awhile to find: ``` foreach(card; unitCards) card.su

Re: Show dialog box for uncaught exception (Windows, lld-link)

2024-05-05 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sunday, 5 May 2024 at 14:55:20 UTC, SimonN wrote: My application is a graphical game. I close stdout and stderr by passing `-subsystem:windows` to `lld-link` to suppress the extra console window. For a few fatal errors (missing required resources, can't open display, ...), I throw exceptions

Re: Phobos function to remove all occurances from dynamic array?

2024-05-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On Wednesday, 1 May 2024 at 01:09:33 UTC, Liam McGillivray wrote: This is presumably such a common task that I'm surprised it isn't easy to find the answer by searching; Is there a standard library function that removes all elements from a dynamic array that matches an input argument? In `st

Re: Adapting foreign iterators to D ranges

2024-04-22 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 22 April 2024 at 11:36:43 UTC, Chloé wrote: The first implementation has the advantage is being simpler and empty being const, but has the downside that next is called even if the range ends up not being used. Is either approach used consistently across the D ecosystem? I always g

Re: Statically compiled binary with C interop crashes.

2024-04-18 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thursday, 18 April 2024 at 11:05:07 UTC, yabobay wrote: On Wednesday, 17 April 2024 at 15:24:07 UTC, Ferhat Kurtulmuş wrote: On Wednesday, 17 April 2024 at 11:03:22 UTC, yabobay wrote: I'm using [dray](https://code.dlang.org/packages/dray) in my project with dub, here's the relevant parts of

Re: "Error: `TypeInfo` cannot be used with -betterC" on a CTFE function

2024-04-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sunday, 14 April 2024 at 22:36:18 UTC, Liam McGillivray wrote: On Friday, 12 April 2024 at 15:24:38 UTC, Steven Schveighoffer wrote: ```d void InitWindow(int width, int height, ref string title) { InitWindow(width, height, cast(const(char)*)title); } ``` This is invalid, a string may no

Re: "Error: `TypeInfo` cannot be used with -betterC" on a CTFE function

2024-04-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On Friday, 12 April 2024 at 00:04:48 UTC, Liam McGillivray wrote: Here's what I wanted to do. In the library I'm working on, there are various declarations for functions defined in an external C library following the line `extern (C) @nogc nothrow:`. Here are some examples of such declaration

Re: How can I tell D that function args are @nogc etc.

2024-04-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On Friday, 12 April 2024 at 03:57:40 UTC, John Dougan wrote: What is the procedure for bug reporting? I'm looking at the issues tracker and have no clue how to drive the search to see if this is already there. https://issues.dlang.org While entering the bug title, it does a fuzzy search fo

Re: How can I tell D that function args are @nogc etc.

2024-04-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thursday, 11 April 2024 at 03:17:36 UTC, John Dougan wrote: Interesting. Thank you to both of you. On Wednesday, 10 April 2024 at 17:38:21 UTC, Steven Schveighoffer wrote: On Wednesday, 10 April 2024 at 11:34:06 UTC, Richard (Rikki) Andrew Cattermole wrote: Place your attributes on the righ

Re: mmap file performance

2024-04-11 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thursday, 11 April 2024 at 00:24:44 UTC, Andy Valencia wrote: I wrote a "count newlines" based on mapped files. It used about twice the CPU of the version which just read 1 meg at a time. I thought something was amiss (needless slice indirection or something), so I wrote the code in C. It

Re: "Error: `TypeInfo` cannot be used with -betterC" on a CTFE function

2024-04-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 9 April 2024 at 23:50:36 UTC, Richard (Rikki) Andrew Cattermole wrote: On 10/04/2024 11:21 AM, Liam McGillivray wrote: On Sunday, 7 April 2024 at 08:59:55 UTC, Richard (Rikki) Andrew Cattermole wrote: Unfortunately runtime and CTFE are the same target in the compiler. So that func

Re: How can I tell D that function args are @nogc etc.

2024-04-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On Wednesday, 10 April 2024 at 11:34:06 UTC, Richard (Rikki) Andrew Cattermole wrote: Place your attributes on the right hand side of the function, not the left side. Use the left side for attributes/type qualifiers that go on the return type. Just a word of warning, this explanation suggest

Re: Boneheaded question regarding compilation...

2024-04-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 1 April 2024 at 21:23:50 UTC, WhatMeWorry wrote: Huge fan of Mike Shah's YouTube videos regarding D and his latest for D conference: https://mshah.io/conf/24/DConf%20%20Online%202024%20_%20The%20Case%20for%20Graphics%20Programming%20in%20Dlang.pdf So I installed github desktop app

Re: Limits of implicit conversion of class arrays

2024-03-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 25 March 2024 at 07:16:35 UTC, Per Nordlöw wrote: On Saturday, 23 March 2024 at 11:04:04 UTC, Dmitry Olshansky wrote: The first and second is unsound (infamously allowed in Java). In the general case, yes. But, do you see any errors with the code ```d class Base {} class Derived

Re: Unittests pass, and then an invalid memory operation happens after?

2024-03-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On Wednesday, 27 March 2024 at 21:43:48 UTC, Liam McGillivray wrote: In my current [game project](https://github.com/LiamM32/Open_Emblem), [something strange](https://github.com/LiamM32/Open_Emblem/issues/20) has happened as of a recent commit. When running `dub test`, all the unittests appear

Re: Reworking the control flow for my tactical role-playing game

2024-03-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sunday, 17 March 2024 at 00:14:55 UTC, Liam McGillivray wrote: As many of you know, I have been trying to write a tactical role-playing game (a mix of turn-based stategy & RPG) in D. This is the furthest I have ever gotten in making an interactive program from the main function up. Right now

Re: Disable wrilten buf in docker

2024-03-12 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 12 March 2024 at 06:36:09 UTC, zoujiaqing wrote: Hi, my application use writeln in docker don't display. Python add -u disable it. https://stackoverflow.com/questions/29663459/why-doesnt-python-app-print-anything-when-run-in-a-detached-docker-container Use setvbuf to switch to li

Re: New update fix

2024-03-03 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 2 March 2024 at 09:18:58 UTC, user1234 wrote: On Saturday, 2 March 2024 at 08:41:40 UTC, Salih Dincer wrote: SLM, What exactly did this patch with the new update fix? Nothing, it looks like what happened is that the issue was wrongly referenced by a dlang.org PR (https://github

Re: Error when using `import`.

2024-02-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 26 February 2024 at 23:27:49 UTC, Liam McGillivray wrote: I don't know whether I should continue this topic or start a new one now that the problem mentioned in the title is fixed. I have now uploaded some of the code to [a GitHub repository](https://github.com/LiamM32/Open_Emblem).

Re: Error when using `import`.

2024-02-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 26 February 2024 at 22:40:49 UTC, Liam McGillivray wrote: On Sunday, 25 February 2024 at 03:23:03 UTC, Paul Backus wrote: You can't give a class the same name as the file it's in. If you do, then when you try to use it from another file, the compiler will get confused and think you'r

Re: The difference between the dates in years

2024-02-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 10 February 2024 at 15:53:09 UTC, Alexander Zhirov wrote: Is it possible to calculate the difference between dates in years using regular means? Something like that ``` writeln(Date(1999, 3, 1).diffMonths(Date(1999, 1, 1))); ``` At the same time, keep in mind that the month and d

Re: The difference between the dates in years

2024-02-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 10 February 2024 at 23:48:56 UTC, Jonathan M Davis wrote: If I understand correctly, he cares about how far into the month the dates are, whereas diffMonths ignores the smaller units, meaning that you get the same result no matter when in the month the dates are. So, 2000-05-10 -

Re: The difference between the dates in years

2024-02-10 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 10 February 2024 at 15:53:09 UTC, Alexander Zhirov wrote: Is it possible to calculate the difference between dates in years using regular means? Something like that ``` writeln(Date(1999, 3, 1).diffMonths(Date(1999, 1, 1))); ``` At the same time, keep in mind that the month and d

Re: How to get the client's MAC address in Vibe

2024-02-08 Thread Steven Schveighoffer via Digitalmars-d-learn
On Wednesday, 7 February 2024 at 22:16:54 UTC, Alexander Zhirov wrote: Is there a way to identify a client by MAC address when using the Vibe library? The `NetworkAddress` [structure](https://vibed.org/api/vibe.core.net/NetworkAddress) does not provide such features. Or did I miss something?

Re: Scripting with Variant from std.variant: parameter passing

2024-02-02 Thread Steven Schveighoffer via Digitalmars-d-learn
On Friday, 2 February 2024 at 08:22:42 UTC, Carl Sturtivant wrote: It seems I cannot pass e.g. an int argument to a Variant function parameter. What's the simplest way to work around this restriction? You'd have to implement the function that accepts the parameters and wraps in a Variant. T

Re: import locality with function parameters

2024-02-01 Thread Steven Schveighoffer via Digitalmars-d-learn
On Friday, 2 February 2024 at 00:29:51 UTC, Carl Sturtivant wrote: Hello, I seem to recall that there is surprising template to import a module and get a type from it inside the declaration of the type of a parameter to a function, so that the module need not be imported outside of the functi

Re: Effective String to Date conversion?

2024-01-31 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 22 January 2024 at 10:56:04 UTC, atzensepp wrote: Dear D-gurus, being new to D I am trying my first steps and the language is quite intuitive and appealing. When reading a file and creating a hash for the reocrds I want to get only the most recent ones. For this I need to convert D

Re: Safety is not what you think

2024-01-30 Thread Steven Schveighoffer via Digitalmars-d-learn
On Tuesday, 30 January 2024 at 15:38:26 UTC, Paul Backus wrote: This definitely isn't allowed in C or C++. I wonder what the rationale is for having this behavior in D? It isn't allowed in C, but allowed in C++ https://godbolt.org/z/9xTPhsb5G As for rationale... I don't know why it wouldn't b

Re: Accessing array elements with a pointer-to-array

2024-01-27 Thread Steven Schveighoffer via Digitalmars-d-learn
On Friday, 26 January 2024 at 11:38:39 UTC, Stephen Tashiro wrote: On Thursday, 25 January 2024 at 20:36:49 UTC, Kagamin wrote: On Thursday, 25 January 2024 at 20:11:05 UTC, Stephen Tashiro wrote: void main() { ulong [3][2] static_array = [ [0,1,2],[3,4,5] ]; static_array[

Re: Providing implicit conversion of

2024-01-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sunday, 21 January 2024 at 16:05:40 UTC, Gavin Gray wrote: The following code: ulong charlie = 11; long johnstone = std.algorithm.comparison.max(0, -charlie); writeln(format!"johnstone %s"(johnstone)); Results in (without any warning(s)): johnstone -11 However you choose to look at it

Re: Delegates and values captured inside loops

2024-01-21 Thread Steven Schveighoffer via Digitalmars-d-learn
On Sunday, 21 January 2024 at 14:52:45 UTC, Renato wrote: On Saturday, 20 January 2024 at 16:53:12 UTC, ryuukk_ wrote: This is the workaround according to: https://issues.dlang.org/show_bug.cgi?id=21929#c9 Go used to have the same issue [but they fixed it](https://go.dev/blog/loopvar-previe

Re: vector crash

2024-01-17 Thread Steven Schveighoffer via Digitalmars-d-learn
On Thursday, 18 January 2024 at 03:07:13 UTC, zjh wrote: ```d import dparse.ast; import dparse.lexer; import dparse.parser : parseModule; import dparse.rollback_allocator : RollbackAllocator; import core.stdcpp.vector; import core.stdcpp.string; ... ``` I have no experience with using cpp from

Re: `static` function ... cannot access variable in frame of ...

2024-01-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 15 January 2024 at 22:23:27 UTC, Bastiaan Veelo wrote: On Monday, 15 January 2024 at 18:43:43 UTC, user1234 wrote: The two calls are not equivalent. so what is passed as alias need to be static too. Thanks all. I thought a static member function just isn't able to access the ins

Re: Socket handle leak and active handle warning with Vibe-D

2024-01-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 15 January 2024 at 18:40:00 UTC, bomat wrote: Sorry, I probably should have mentioned I was on Windows. For testing it under Linux I commented out the call to `connectMongoDB`, since I don't have it installed there - and the warning went away. Interesting, I did not suspect that as

Re: Socket handle leak and active handle warning with Vibe-D

2024-01-15 Thread Steven Schveighoffer via Digitalmars-d-learn
On Monday, 15 January 2024 at 17:24:40 UTC, bomat wrote: On Sunday, 14 January 2024 at 20:36:44 UTC, Steven Schveighoffer wrote: There should be a version you can enable that tells you where that socket handle was allocated. That might give you a further clue as to why it's not closed when the

Re: Socket handle leak and active handle warning with Vibe-D

2024-01-14 Thread Steven Schveighoffer via Digitalmars-d-learn
On Saturday, 13 January 2024 at 20:49:54 UTC, bomat wrote: I am still getting this in 2024 and vibe.d 0.9.7: ``` Warning: 1 socket handles leaked at driver shutdown. ``` I was wondering if maybe someone has new info on this... There should be a version you can enable that tells you where that

  1   2   3   4   5   6   7   8   9   10   >