Re: Type constraint

2023-10-08 Thread IchorDev via Digitalmars-d-learn
On Wednesday, 4 October 2023 at 01:46:42 UTC, Joel wrote: I think the if without static is still static, since it's part of the function name part, or so (outside of the curly bracket scope). You can't have regular if-statements inside templates. Regular if-statements are checked at runtime

Re: Define a new custom operator in D Language.

2023-10-08 Thread IchorDev via Digitalmars-d-learn
On Monday, 2 October 2023 at 21:37:56 UTC, bachmeier wrote: On Monday, 2 October 2023 at 19:28:32 UTC, BoQsc wrote: I'm unable to see how the operator overloading would allow to define a new custom operator. And I don't expect that to change. This has come up many times. With a parameter

Re: AA vs __gshared

2023-08-15 Thread IchorDev via Digitalmars-d-learn
On Tuesday, 15 August 2023 at 17:36:13 UTC, Steven Schveighoffer wrote: On 8/12/23 5:55 AM, IchorDev wrote: On Thursday, 10 August 2023 at 15:20:28 UTC, Steven Schveighoffer wrote: That shouldn't matter. Well, it does here. The AA is mutated during the loop, so perhaps this is an

Re: std.experimental.allocator

2023-08-14 Thread IchorDev via Digitalmars-d-learn
On Sunday, 13 August 2023 at 16:00:51 UTC, Richard (Rikki) Andrew Cattermole wrote: Yeah you're right Ternary should probably be replaced, although amazingly it has never caused problems so far. But I cannot agree about RAII. Its a valid tool for managing lifetimes of memory allocators.

BetterC stack traces?

2022-09-04 Thread IchorDev via Digitalmars-d-learn
I'm trying to implement a custom exception system in BetterC. Does anyone know how I'd go about getting a stack trace so that I can print it to stdout? :) I was thinking of utilising UDAs & `__LINE__` but it turns out that UDAs don't let you inject code, which is a shame!

Re: Does D actually support flexible array members?

2022-09-06 Thread IchorDev via Digitalmars-d-learn
On Thursday, 18 August 2022 at 11:25:22 UTC, Paul Backus wrote: I think the closest way to approximate this in D is to use a zero-length static array: ```d struct ArenaChunk { size_t size; ArenaChunk* next; char[0] memory; } ``` Would Nullable be a good option as well?

Re: BetterC stack traces?

2022-09-06 Thread IchorDev via Digitalmars-d-learn
On Monday, 5 September 2022 at 12:35:10 UTC, Paul Backus wrote: Digging in a little deeper, it looks like the druntime implementation ultimately depends on the C++ exception handling ABI, via its platform-independent library interface. Bindings are defined in `core.internal.backtrace.unwind`

Re: BetterC stack traces?

2022-09-05 Thread IchorDev via Digitalmars-d-learn
On Sunday, 4 September 2022 at 18:49:37 UTC, Paul Backus wrote: You can use `libunwind` for this: https://www.nongnu.org/libunwind/ It's a C library, but it should work for D too. Ah, I'm actually trying to create my own implementation of this, so the goal would be to not rely on a

Re: dub.sdl bindbc-glfw is returning a deprecation warming. So what do I do now?

2023-03-08 Thread IchorDev via Digitalmars-d-learn
On Thursday, 9 March 2023 at 00:21:02 UTC, WhatMeWorry wrote: my small dub.sdl project uses: dependency "bindbc-glfw" version="~>1.0.1" versions "GLFW_33" and returns Building bindbc-glfw 1.0.1: building configuration [dynamic]

SO_PRIORITY

2023-04-11 Thread IchorDev via Digitalmars-d-learn
`std.socket` is missing a `SocketOption`-equivalent to `SO_PRIORITY`. Is this an intentional omission (and if so, why?), or should I try to submit a PR to add it?

Re: Returning a reference to be manipulated

2023-04-13 Thread IchorDev via Digitalmars-d-learn
On Thursday, 13 April 2023 at 07:05:10 UTC, Chris Katko wrote: I'm trying to figure out how to return a reference to something that may not be a reference type. ```D struct stats { float[string] data=0; float ref opIndex(string key) { return data[key]; // want a ref to a specific element

`static` on module-level functions

2023-07-06 Thread IchorDev via Digitalmars-d-learn
Can anyone point me to a part of the D spec that says what `static` means when applied to functions that are declared at module scope? (Other than module constructors, obviously) I used to assume the property would do something, so I actually used it in a lot of my code when I was first

Re: `static` on module-level functions

2023-07-07 Thread IchorDev via Digitalmars-d-learn
On Friday, 7 July 2023 at 03:18:53 UTC, Richard (Rikki) Andrew Cattermole wrote: Yes, static on a free-function does not do anything. Good to know. I think the D spec should definitely be amended to explicitly mention that static *can* be applied to them, but doesn't do anything.

Re: `static` on module-level functions

2023-07-07 Thread IchorDev via Digitalmars-d-learn
On Friday, 7 July 2023 at 10:01:41 UTC, Richard (Rikki) Andrew Cattermole wrote: Static does do something on functions when they are not free-functions. https://dlang.org/spec/attribute.html#static Well yes, I even mentioned that in the OP. It's just that I'd expect using `static`

Re: getOverloads order

2023-07-13 Thread IchorDev via Digitalmars-d-learn
On Thursday, 13 July 2023 at 10:53:49 UTC, Dennis wrote: On Thursday, 13 July 2023 at 08:03:02 UTC, IchorDev wrote: I've noticed that `__traits(getOverloads)` always returns the overloads in lexical order across DMD, LDC, and GDC. Is this reliable at all? No. It depends on the order the

getOverloads order

2023-07-13 Thread IchorDev via Digitalmars-d-learn
I've noticed that `__traits(getOverloads)` always returns the overloads in lexical order across DMD, LDC, and GDC. Is this reliable at all?

Re: Garbage Collectors

2023-07-19 Thread IchorDev via Digitalmars-d-learn
On Wednesday, 19 July 2023 at 08:27:18 UTC, Richard (Rikki) Andrew Cattermole wrote: Its not as simple as porting to the API unfortunately. We don't have barriers of any kind, so that removes most GC designs you would want to use today. We are very close to maxing out what we can do as a

Re: Garbage Collectors

2023-07-19 Thread IchorDev via Digitalmars-d-learn
On Wednesday, 19 July 2023 at 11:27:14 UTC, Richard (Rikki) Andrew Cattermole wrote: druntime supports registering of GC's not compiled with druntime. But because some of the machinery isn't available to you, you would have to recreate it. Oh right, so it's more of a matter of making

Re: Weird template instantiation speed?

2023-07-09 Thread IchorDev via Digitalmars-d-learn
On Sunday, 9 July 2023 at 14:49:39 UTC, Steven Schveighoffer wrote: This is probably a bug somewhere, 4 seconds is too much. A reduced test case would be helpful. But I wanted to note, inside a struct template, the template name (by itself) is equivalent to the current instantiation. So

Weird template instantiation speed?

2023-07-09 Thread IchorDev via Digitalmars-d-learn
While working on some new bindings, I've discovered that if `opAssign` in a struct template "`BindingTempl(T)`" has the return type "`BindingTempl!T` then it adds about 4 seconds to the compile time per instantiation of `BindingTempl`. The added compile time is much lower if a function other

Re: `static` on module-level functions

2023-07-09 Thread IchorDev via Digitalmars-d-learn
On Friday, 7 July 2023 at 13:31:59 UTC, Steven Schveighoffer wrote: D allows no-op attributes in many cases because you can possibly apply attributes to a group via `attribute:` or `attribute { ... }`, and you may not want to fine-tune which things can get the attribute to avoid errors.

Re: Warning The package will no longer be detected starting from v1.42.0

2023-07-09 Thread IchorDev via Digitalmars-d-learn
On Monday, 26 June 2023 at 01:35:07 UTC, Soulsbane wrote: Yeah, each folder under libs is a package and it's own git repository. I think I'll just use the add-local approach. Kind of a pain but getting spammed with a page of warnings every compile is getting tiring :). Thanks a lot for the

Re: Pre-expanding alloc cell(s) / reserving space for an associative array

2023-07-10 Thread IchorDev via Digitalmars-d-learn
On Sunday, 9 July 2023 at 20:24:24 UTC, Cecil Ward wrote: Before I posted a question about avoiding unnecessary allocs/reallocs when adding entries to an array like so uint[ dstring ] arr; when I build it up from nothing with successive insertions. The array is accessed by a key that is

Re: Garbage Collectors

2023-07-19 Thread IchorDev via Digitalmars-d-learn
On Wednesday, 19 July 2023 at 10:50:07 UTC, Richard (Rikki) Andrew Cattermole wrote: Copying out the conservative GC, register it under a different name and getting that to compile and link without recompiling druntime would be a good place to begin without having to understand how GC's

Re: Strange behaviour of __traits(allMembers)

2023-07-05 Thread IchorDev via Digitalmars-d-learn
On Wednesday, 28 June 2023 at 10:20:44 UTC, Dennis wrote: It's now fixed: https://github.com/dlang/dmd/pull/15335 Yesss! You're a hero indeed!

Re: Options for Cross-Platform 3D Game Development

2023-07-05 Thread IchorDev via Digitalmars-d-learn
On Wednesday, 5 July 2023 at 22:27:46 UTC, Andrew wrote: So, I've gotten the itch to have a go at game development in D, after doing a bit of it in Java last year. I've previously used LWJGL, which is a java wrapper for OpenGL, OpenAL, GLFW, and some other useful libs. The problem is,

Re: Designated initializers to function argument

2023-07-28 Thread IchorDev via Digitalmars-d-learn
On Friday, 28 July 2023 at 17:04:33 UTC, bachmeier wrote: [The DIP](https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1030.md) was approved long ago. It was waiting for an implementation. No shit, it felt like an eternity. But it's still not in the spec...?

AA vs __gshared

2023-07-27 Thread IchorDev via Digitalmars-d-learn
I've been getting a lot of segfaults from using associative arrays recently. The faults happen seemingly at random, and from pretty mundane stuff like `if(auto x = y in z)` that run very often: ``` Segmentation fault. #0 0x55670f4a in rt.aaA.Impl.findSlotLookup(ulong, scope

Re: Getting __COLUMN__ of source code location.

2023-07-27 Thread IchorDev via Digitalmars-d-learn
I'm not aware of any way to do that exact thing. Measuring what column a line is on would be quite subjective. How wide is a tab space? Technically, it could be any number of columns depending on the display configuration used. On Sunday, 23 July 2023 at 15:01:51 UTC, realhet wrote: Why is

Re: AA vs __gshared

2023-07-27 Thread IchorDev via Digitalmars-d-learn
On Thursday, 27 July 2023 at 21:31:02 UTC, Jonathan M Davis wrote: Now, as to what's happening in your code that's causing segfaults, the most likely culprit would be that you're accessing the AA without actually having done anything to prevent other threads from accessing it at the same

Re: Which D compiler is the most maintained and future-proof? [DMD GDC and LDC]

2023-07-25 Thread IchorDev via Digitalmars-d-learn
On Monday, 24 July 2023 at 13:30:27 UTC, cc wrote: Is there any list of known significant "gotchas" with moving to LDC from DMD? Any unexpected surprises to watch out for or be careful for? I'm thinking of all the "features" of DMD that are now considered verboten by many users (e.g.

Re: AA vs __gshared

2023-07-28 Thread IchorDev via Digitalmars-d-learn
On Friday, 28 July 2023 at 04:13:13 UTC, Kagamin wrote: The difference between them is purely formal if you're not on an old gdc, where shared was synchronized like C# volatile. I'm not sure that's correct. Also I always use the latest compiler versions where possible. start many threads

Re: AA vs __gshared

2023-07-28 Thread IchorDev via Digitalmars-d-learn
On Friday, 28 July 2023 at 11:15:31 UTC, Steven Schveighoffer wrote: All `__gshared` does is give you storage that is accessible from all threads, "All __gshared does is give you [a live bomb, ready to go off at any moment]" !! On Friday, 28 July 2023 at 14:10:16 UTC, Kagamin wrote: Your

Re: Designated initializers to function argument

2023-07-28 Thread IchorDev via Digitalmars-d-learn
On Tuesday, 11 July 2023 at 17:43:43 UTC, Steven Schveighoffer wrote: On 7/11/23 11:22 AM, Ki Rill wrote: On Tuesday, 11 July 2023 at 15:16:54 UTC, Ki Rill wrote: apply(Appearance(color: BLACK, strokeWidth: 4)); // other fields are default initialized: strokeOpacity, fillOpacity, Yes, I was

Re: AA vs __gshared

2023-07-28 Thread IchorDev via Digitalmars-d-learn
On Thursday, 27 July 2023 at 21:31:02 UTC, Jonathan M Davis wrote: What should normally be happening is that you use shared, and then when you've protected the object so that you know that it can only be accessed on the current thread by the section of code that you're in (e.g. by locking a

Re: Strange behaviour of __traits(allMembers)

2023-06-18 Thread IchorDev via Digitalmars-d-learn
On Sunday, 18 June 2023 at 10:04:14 UTC, FeepingCreature wrote: On Sunday, 18 June 2023 at 09:48:40 UTC, IchorDev wrote: Does anyone understand why this happens? Is there any way to subvert this behaviour, or is it actually a bug? Yes, see also my bug report,

Strange behaviour of __traits(allMembers)

2023-06-18 Thread IchorDev via Digitalmars-d-learn
`source/mod/submod.d:` ```d module mod.submod; enum T1{ x } ``` `source/mod/package.d`: ```d module mod; import mod.submod; enum T2{ y } enum T3{ z } static foreach(member; __traits(allMembers, mod)){ pragma(msg, member); } /**Prints: object T1 **/ ``` I get the members of `mod.submod`

std.experimental.allocator

2023-08-13 Thread IchorDev via Digitalmars-d-learn
I feel like I can't possibly be the first to ask, but I couldn't find any prior discussion of this: When is `std.experimental.allocator` going to be moved out of `experimental`? Is there any roadmap for it? Is it just in limbo?

Re: D: How would one make a shared dynamically linked D library?

2023-11-09 Thread IchorDev via Digitalmars-d-learn
On Wednesday, 8 November 2023 at 11:48:58 UTC, BoQsc wrote: I would like to export some functionality as external shared dynamically linked D library. Is it possible to do that in D Language Yes, as long as the symbols you want to use externally are `public`, which is the default. When it

Re: How to resolve two packages requiring different versions of another package?

2024-04-05 Thread IchorDev via Digitalmars-d-learn
On Thursday, 4 April 2024 at 14:29:56 UTC, WhatMeWorry wrote: Error: Unresolvable dependencies to package bindbc-loader: bindbc-opengl 0.13.0 depends on bindbc-loader ~>0.3.0 bindbc-sdl 1.4.7 depends on bindbc-loader ~>1.1.0 Please update `bindbc-opengl` to `1.1.0`. I think it's

Re: How to add a character literal to a string without ~ operator?

2024-04-08 Thread IchorDev via Digitalmars-d-learn
On Thursday, 4 April 2024 at 18:14:54 UTC, BoQsc wrote: I'm looking for more readable standard function to add a **character** literal to a **string**. Concatenate is the verb you're looking for, not add. 'Adding' a `char` to a `string` sounds like you want `myString[] += myChar;`, which