Re: Comparing slice to an Array in assert

2024-06-11 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 11/06/2024 9:51 PM, madwebness wrote: Ah, my mistake. With the regular expression adjusted to `r"^[A-Z]+(=.*)?$"` it works just fine. Thank you very much for running the code for me. All very simple, I'm just new to the language. All good, happy to help! We also have people on Discord and

Re: Comparing slice to an Array in assert

2024-06-11 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 11/06/2024 9:17 PM, madwebness wrote: On Tuesday, 11 June 2024 at 08:44:25 UTC, Richard (Rikki) Andrew Cattermole wrote: There are two more corrections to make. Both in sliceIt. Note: array is a function not a type and is for ranges, slices are built in language concept. Associate

Re: Comparing slice to an Array in assert

2024-06-11 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
There are two more corrections to make. Both in sliceIt. Note: array is a function not a type and is for ranges, slices are built in language concept. Associate Arrays (map) use the syntax ``Type[Type]``.

Re: Implementation Details

2024-05-27 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 28/05/2024 12:54 PM, Ruby The Roobster wrote: As of late, I have taken up an interest in learning about how the D language is implemented at a compiler level, specifically the GC implementation.  Unfortunately, the source code is poorly documented, and is too large to simply read all of it

Re: Problem with clear on shared associative array?

2024-05-27 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 28/05/2024 12:36 PM, Andy Valencia wrote: On Monday, 27 May 2024 at 04:04:03 UTC, mw wrote: Pls NOTE: it is a   `sharded` (meaning trunk-ed) NON-concurrent map, not `shared` concurrent map. Assuming I put it in shared memory, in what way is it not able to be used concurrently?  It seems

Re: Goto skipping declarations

2024-05-03 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 04/05/2024 8:38 AM, Jonathan M Davis wrote: In any case, I expect that the compiler is just going dumb here because of the label for some reason, and one or more of the checks that it's supposed to be doing is being missed. It is very simple code. A reverse search over the double linked

Re: dynamic linker flags with dub

2024-04-29 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 30/04/2024 10:20 AM, KytoDragon wrote: I want to use dll-style hot-reloading for a windows application which requires a different name for the PDB file for each compilation. (windows locks the pdb file when loading the dll and the compiler can't create a new pdb with the same name). How can

Re: Digger on Windows -- should it work?

2024-04-19 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 20/04/2024 9:28 AM, Ivan Kazmenko wrote: Hi. I'd like to test locally whether a commit (https://github.com/dlang/dmd/pull/16400) fixes an issue (https://issues.dlang.org/show_bug.cgi?id=24440).  The GitHub instructions in the PR tell to use Digger for a quick and easy check, but it fails

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

2024-04-14 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 15/04/2024 10:36 AM, Liam McGillivray wrote: Well, it did work when I tried it (using a string variable, not a literal of course). It displayed as it is supposed to. But from the information I can find on the web it looks like strings are sometimes but not |always| zero-terminated. Not a

Re: How to set include paths of a c source in dub when using importc

2024-04-13 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 14/04/2024 8:59 AM, Ferhat Kurtulmuş wrote: These don't work for me: "dflags": ["-Iinclude"] "importPaths": [     "include" ], The importc docs do not help either. Appears it hasn't been documented in new dub docs. It is ``cSourcePaths`` and ``cImportPaths``.

Re: What I thought was straightforward blew up in my face..

2024-04-10 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
```c void SDL_GetVersion(SDL_version * ver); ``` It doesn't return anything. Its return type is void. See the argument list where it lists the types of the arguments: ``template writeln is not callable using argument types !()(string, void)`` Which aligns with the arguments you passed to

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

2024-04-10 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
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. ```d bool[7] stagesToProcess = false; bool shouldDoInStages(int index) @nogc nothrow @safe { return stagesToProcess[index]; }

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

2024-04-10 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 10/04/2024 2:50 PM, Liam McGillivray wrote: On Tuesday, 9 April 2024 at 23:50:36 UTC, Richard (Rikki) Andrew Cattermole wrote: The string mixin triggers CTFE, if ``EnumPrefixes`` wasn't templated, that would cause codegen and hence error. If you called it in a context that wasn't CTFE only

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

2024-04-09 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
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 function is being used for both, and hence uses GC (appending). Are you sure

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

2024-04-09 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 09/04/2024 12:48 PM, Liam McGillivray wrote: On Tuesday, 9 April 2024 at 00:02:02 UTC, Richard (Rikki) Andrew Cattermole wrote: ```d enum Value = (a, b) { return a + b; }(1, 2); ``` This alone should be a CTFE only function. But if we want template parameters, we'd need to wrap

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

2024-04-08 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 09/04/2024 11:42 AM, Liam McGillivray wrote: On Monday, 8 April 2024 at 08:12:22 UTC, Richard (Rikki) Andrew Cattermole wrote: ```d template Foo(Args) { enum Foo = () {     return Args.init; }(); } ``` Something like that should work instead. I'm sorry, but I can't

Re: Setting up CI for Dub project on Github

2024-04-08 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 09/04/2024 1:20 AM, Dmitry Olshansky wrote: I haven’t done any research on the subject, would be nice if somebody pointed me to good example of how it’s done. — Dmitry Olshansky CEO @ Glowlabs https://olshansky.me In case you haven't already found:

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

2024-04-08 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 08/04/2024 10:45 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. :-( Will this ever be changed? A tad unlikely, it would be a rather large change

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

2024-04-07 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Unfortunately runtime and CTFE are the same target in the compiler. So that function is being used for both, and hence uses GC (appending). ```d template Foo(Args) { enum Foo = () { return Args.init; }(); } ``` Something like that should work instead.

Re: CTFE write message to console

2024-04-04 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Oh hey! https://github.com/dlang/dmd/pull/16250 It was implemented literally 2 weeks ago! Nightly should have it https://github.com/dlang/dmd/releases/tag/nightly

Re: CTFE write message to console

2024-04-04 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 05/04/2024 4:04 AM, Carl Sturtivant wrote: On Thursday, 4 April 2024 at 14:06:19 UTC, Richard (Rikki) Andrew Cattermole wrote: ```d static assert(0, "message"); ``` Or if it is known to be CTFE'd ```d assert(0, "message"); ``` Just a warning, its a one time use only

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

2024-04-04 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 05/04/2024 3:29 AM, 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 https://github.com/BindBC/bindbc-opengl/issues/47

Re: CTFE write message to console

2024-04-04 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 05/04/2024 2:54 AM, Carl Sturtivant wrote: I'm writing CTFE on Windows, latest DMD compiler. How should I write a message to the console (stderr) from a CTFE function call during compilation? ```d static assert(0, "message"); ``` Or if it is known to be CTFE'd ```d assert(0, "message");

Re: Had to reinstall my Raspberry Pi, how do I set up LDC2's environment values permamently?

2024-03-19 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 19/03/2024 10:50 PM, solidstate1991 wrote: Due to a screwup on my part, I had to reinstall my Pi's OS (was quicker than looking up the potential solution), and since I don't need multiple separate versions of D, I want to do away with the `activate`/`deactivate` scripts, especially as this

Re: Challenge: Make a data type for holding one of 8 directions allowing increment and overflow

2024-03-16 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Bit fields are currently going through the DIP process, although because of ImportC having it, its just a matter of turning them on and adding the parser stuff. However there is a major drawback to it and is why you'll still need to use a struct and that is you can't take a pointer to it.

Re: DUB error I can't make sense of

2024-03-16 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 16/03/2024 8:23 PM, Per Nordlöw wrote: https://github.com/nordlow/phobos-next/releases/tag/v0.6.10 fails to build as ``` ../../.dub/cache/phobos-next/0.6.10/code/phobos-next-test-library-unittest-nyN4MEoglVgAJ1A9GyL6uA/dub_test_root.d(11,15): Error: module `nxt.algorithm.comparsion` from

Re: Challenge: Make a data type for holding one of 8 directions allowing increment and overflow

2024-03-14 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 15/03/2024 12:47 PM, Basile B. wrote: On Thursday, 14 March 2024 at 23:39:33 UTC, Liam McGillivray wrote: On Thursday, 14 March 2024 at 01:58:46 UTC, Richard (Rikki) Andrew Cattermole wrote: [...] I tried to rework the functions to use bitwise operations, but it was difficult to figure

Re: Challenge: Make a data type for holding one of 8 directions allowing increment and overflow

2024-03-13 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
There appears to be a few things that you may not be aware of based upon this implementation. The cost of an add + increment then a bitwise and is only 2-4 cycles on a Haswell cpu. Depending upon if its working solely in registers (via inlining) or its operating on ram. The cost of a move

Re: Challenge: Make a data type for holding one of 8 directions allowing increment and overflow

2024-03-12 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 13/03/2024 11:00 AM, Liam McGillivray wrote: I'm not familiar with the syntax of the line |value &= 7;|. Is it equivalent to writing |value = value % 7;|? & is a bitwise and. LSB 123456789 MSB & 7 LSB 12300 MSB Anyway, you used an int, but I used an array of 3 bools. I'm guessing

Re: Disable wrilten buf in docker

2024-03-12 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On D's side you can use ``stdout.flush;`` to force it to flush. I don't think there is a way to force flushing via CLI.

Re: Challenge: Make a data type for holding one of 8 directions allowing increment and overflow

2024-03-12 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
By taking advantage of integer wrapping and a bitwise and, its quite a simple problem to solve! Challenge for the reader: add support for binary operations and toString support. https://dlang.org/spec/operatoroverloading.html ```d struct Direction { private int value; Direction

Re: DMD windows and Clang's llvm-link.exe

2024-03-09 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 10/03/2024 4:46 PM, Carl Sturtivant wrote: suggesting that there's a reason version 9 instead of 17 of lld is being used in the latest DMD installation, that may be relevant what I'd like to try. Any idea what that might be? Yes, nobody has updated it.

Re: DMD windows and Clang's llvm-link.exe

2024-03-09 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 10/03/2024 11:02 AM, Carl Sturtivant wrote: I'd like to see if I can get dmd to work correctly with Clang rather than MS tools. Can anyone share any experience they've had with this or any understanding of the situation? lld is used and distributed with dmd and ldc. That is known to work.

Re: Why am I getting segfaults when doing `foreach` with arrays of references?

2024-03-09 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 09/03/2024 8:49 PM, Liam McGillivray wrote: But that begs the question; why? Don't dynamic arrays always start with a length of 0? If the array was only extended when valid objects were appended using the append operator |~=|, and none of those objects were deleted (as I the destructor was

Re: Why am I getting segfaults when doing `foreach` with arrays of references?

2024-03-08 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Something that I have noticed that you are still doing that was pointed out previously is having a pointer to a class reference. Stuff like ``Tile* currentTile;`` when it should be ``Tile currentTile;`` A class reference is inherently a pointer. So when you checked for nullability in the

Re: Can a D library have some types determined by the client program?

2024-03-07 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 08/03/2024 4:09 PM, Liam McGillivray wrote: On Thursday, 7 March 2024 at 22:18:40 UTC, Richard (Rikki) Andrew Cattermole wrote: There are two ways to do this. 1. Use templates. https://tour.dlang.org/tour/en/basics/templates 2. Use a factory function. https://tour.dlang.org/tour/en

Re: Can a D library have some types determined by the client program?

2024-03-07 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
There are two ways to do this. 1. Use templates. https://tour.dlang.org/tour/en/basics/templates 2. Use a factory function. https://tour.dlang.org/tour/en/basics/delegates ```d class Map(ATile : Tile) { ATile[] tiles; } ``` Or: ```d class Map { Tile[] tiles; Tile

Re: Hidden members of Class objects

2024-03-06 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 07/03/2024 1:28 PM, Carl Sturtivant wrote: On Wednesday, 6 March 2024 at 23:45:00 UTC, H. S. Teoh wrote: In D, there's a pointer to the vtable and another pointer to a Monitor object (used for synchronized methods).  There was talk about getting rid of the Monitor field years ago, but

Re: Question on shared memory concurrency

2024-03-03 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
A way to do this without spawning threads manually: ```d import std.parallelism : TaskPool, parallel, taskPool, defaultPoolThreads; import std.stdio : writeln; import std.range : iota; enum NSWEPT = 1_000_000; enum NCPU = 4; void main() { import core.atomic : atomicLoad, atomicOp;

Re: importC with gc-sections not work on linux

2024-02-26 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 27/02/2024 1:28 AM, Dakota wrote: When I use importC to build a c library, there is a lot unused symbol missing. I try add `-L--gc-sections` to dmd to workaround this issue. This removes symbols, not keeps them. You want the linker flag: ``--no-gc-sections`` "Enable garbage collection

Re: importC error Error: undefined identifier `__builtin_unreachable`

2024-02-26 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 26/02/2024 10:34 PM, Dakota wrote: undefined identifier `__builtin_clz` Done. https://issues.dlang.org/show_bug.cgi?id=24414

Re: importC error Error: undefined identifier `__builtin_unreachable`

2024-02-26 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 26/02/2024 9:04 PM, Dakota wrote: I try one more importC case, get this error: ```sh Error: undefined identifier `__builtin_unreachable` ``` any tips to fix this? Reported: https://issues.dlang.org/show_bug.cgi?id=24413

Re: Error when using `import`.

2024-02-24 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 24/02/2024 11:51 PM, Liam McGillivray wrote: On Saturday, 24 February 2024 at 10:34:25 UTC, Richard (Rikki) Andrew Cattermole wrote: A few things. Module names should be lower case. I capitalised the first letter in the class names so that I can make instances of them in lowercase

Re: Error when using `import`.

2024-02-24 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
A few things. Module names should be lower case. Each file, needs the full module declaration. source/foo/bar.d: ```d module foo.bar; ``` source/app.d: ```d module app; import foo.bar; ``` Directories matter, this allows the import path search (via the use of the -I switch) to

Re: std.uni.CodepointSet from range of pairs of integers

2024-02-18 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 19/02/2024 5:33 PM, Carl Sturtivant wrote: On Monday, 19 February 2024 at 01:42:03 UTC, Richard (Rikki) Andrew Cattermole wrote: I can understand ``pure``. https://github.com/dlang/phobos/blob/master/std/uni/package.d#L2075 It is literally on the constructor. Now @safe I don't know. My

Re: std.uni.CodepointSet from range of pairs of integers

2024-02-18 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
I can understand ``pure``. https://github.com/dlang/phobos/blob/master/std/uni/package.d#L2075 It is literally on the constructor. Now @safe I don't know. My best guess would be for some reason the constructor is getting inferred as it (templates get inferred).

Re: Are exceptions caught in unittests?

2024-02-15 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
This should be working. I don't know what is going on. All I can suggest is to use a debugger to see if it is indeed throwing and then catching.

Re: std.uni CodepointSet toString

2024-02-09 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 09/02/2024 9:04 PM, Danilo wrote: Instead of bug fixing and stabilization, people concentrate on getting new stuff like ˋ:blubˋ into the language. Umm, I take it that you didn't know that one of the reasons we spent the past year focusing on bug fixing and stabilization is because of my

Re: std.uni CodepointSet toString

2024-02-07 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 08/02/2024 6:11 AM, H. S. Teoh wrote: Do we know why the compiler isn't getting it right? Shouldn't we be fixing it instead of just turning off elision completely? Of course we should. It has been reported multiple times, with different examples trigger the switch symbol error.

Re: std.uni CodepointSet toString

2024-02-07 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 08/02/2024 5:36 AM, Carl Sturtivant wrote: On Wednesday, 7 February 2024 at 11:49:20 UTC, Richard (Rikki) Andrew Cattermole wrote: ``` undefined reference to `_D4core9exception__T15__switch_errorTZQsFNaNbNiNeAyamZv' collect2: error: ld returned 1 exit status Error: linker exited

Re: std.uni CodepointSet toString

2024-02-07 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
https://issues.dlang.org/show_bug.cgi?id=20802

Re: std.uni CodepointSet toString

2024-02-07 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 07/02/2024 7:27 PM, Carl Sturtivant wrote: Need help working around a linkage problem. ```d import std.uni, std.conv, std.stdio, std.format; void main() { //auto c1 = unicode.InBasic_latin; auto c1 = CodepointSet('a','z'+1); writeln(c1.to!string); writeln(format("%d",

Re: Branching of a discussion in forums?

2024-01-29 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 30/01/2024 5:06 AM, Alexandru Ermicioi wrote: On Monday, 29 January 2024 at 14:59:23 UTC, Richard (Rikki) Andrew Cattermole wrote: If you are using a NewsGroup reader like ThunderBird it should be possible to branch off and post in a different one. What about web interface? I don't think

Re: Branching of a discussion in forums?

2024-01-29 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
If you are using a NewsGroup reader like ThunderBird it should be possible to branch off and post in a different one. Although nobody does that, normally people rename the subject instead.

Re: Partial function application (Currying)

2024-01-20 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 21/01/2024 9:55 AM, atzensepp wrote: import std.stdio; // Overloads are resolved when the partially applied function is called // with the remaining arguments. struct S { static char fun(int i, string s) { return s[i]; } static int fun(int a, int b) { return a * b; } } void main() { alias

Re: Partial function application (Currying)

2024-01-20 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Not really any other way to do it, create context (i.e. struct, or stack) and have a delegate point to both it and a patch function. It'll be how partial is implemented. https://dlang.org/phobos/std_functional.html#.partial

Re: Understanding the Use of Nested Import and Selective Import in D

2024-01-16 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Yes, I try to place my imports at the most general location that makes sense. Sometimes that is at the module level, other times its in a single function. Or anywhere in between (such as a struct).

Re: Problems using rawWrite in an experiment with WAVs in D

2023-12-27 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Because WaveHeader has no pointers in it, only raw memory, assuming it is all in the cpu endianesss and with ``align(1)`` you can slice that block of stack memory and write from that. ```d file.rawWrite((cast(ubyte*))[0 .. WaveHeader.sizeof]); ``` However I would recommend doing it field by

Re: std.int128 not working with -betterC enabled

2023-12-22 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 23/12/2023 11:41 AM, Matheus Catarino wrote: Would there be any reason not to use |core.int128|? Currently, I used it to make a TigerbeetleDB client (Zig database) in D (betterC).

Re: std.int128 not working with -betterC enabled

2023-12-20 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 21/12/2023 10:51 AM, Renato wrote: On Wednesday, 20 December 2023 at 19:11:15 UTC, Richard (Rikki) Andrew Cattermole wrote: Yes that is to be expected. It is not templated, and hasn't been compiled into your program. How do I compile that into my program? You copy the file from druntime

Re: std.int128 not working with -betterC enabled

2023-12-20 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Yes that is to be expected. It is not templated, and hasn't been compiled into your program.

Re: D is a great language, but I've had a bad experience getting started

2023-12-14 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 15/12/2023 2:02 AM, Renato wrote: How do you tell dub to "build and link in a single step"? This should do it: ``--combined --build-mode=allAtOnce``

Re: D is a great language, but I've had a bad experience getting started

2023-12-14 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Welcome! Regarding the problems with dub on OSX, that'll be due to separate build + link steps. It should work ok if you build and link in a single step with the workaround applied. DC is an environment variable that should point to the D compiler. As a variable this particular one

Re: import issue?

2023-11-22 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 23/11/2023 5:34 AM, DLearner wrote: Is the encapsulation issue resolved if the struct itself is held in another module, and imported from that module into both the 'main' and 'Ex_mod' files? Each module is its own encapsulation unit. As long as you are using the same distinct type in both

Re: import issue?

2023-11-22 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
You have two ``SA`` structs, each in different encapsulations. Each of them are different, even if they have similar members. In D types that look the same do not combine, they are distinct. You can see this by comparing the mangling of each. ``pragma(msg, SA.mangleof);``

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

2023-11-08 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Currently stick to ldc. Dub's defaults will "just work" except: - On *nix where you have to either set/patch the ``RPATH`` or set ``LD_LIBRARY_PATH``. - For executables on Windows in which you need to set the dflag ``-dllimport=all``. From a README of mine (for Posix): To get the loading

Re: Installing DMD on Windows

2023-10-20 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
I've gone ahead and reported it, most likely nobody has used VS2022 professional edition. https://issues.dlang.org/show_bug.cgi?id=24191

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 17/10/2023 4:18 PM, mw wrote: Is string basic types? as I showed one earlier Foo {one string and two ints}, my other struct only has double and long, it also has the same link errors about toHash and opEquals. string is not a basic type, its a slice, which means pointer.

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 17/10/2023 2:17 PM, mw wrote: It's just my own module and type name, nothing special or interesting. Doesn't matter. Because I now can't demangle it and figure out what its trying to find without doing that by hand. Every character in a symbol name is significant, you can't remove some

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 17/10/2023 2:15 PM, mw wrote: On Tuesday, 17 October 2023 at 01:11:13 UTC, Richard (Rikki) Andrew Cattermole wrote: They are for structs as well. Ah?! I use quite a few struts, but I never have provided such two methods. Indeed, they are generated by the compiler, not user provided

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 17/10/2023 1:58 PM, mw wrote: Oh the <_My_struct> part is my simplification, it is mangled as something like : _D6..<_My_struct>..__xtoHashFNbNeKxSQBlQBoQBiZm When dealing with linker errors, please do not simplify, it can make problems unsolvable.

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
They are for structs as well.

Re: strange link error: _My_struct__xtoHashFNbNeKxSQBlQBoQBiZm _My_struct__xopEqualsMxFKxSQBlQBoQBiZb

2023-10-16 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
xtoHash and xopEquals are generated by the compiler automatically. Curiously those two symbol names are not demangling. Given this, I suspect the best thing to do is file a bug report with ldc with the code that generated the linker error.

Re: Forcing my module to be initialized first

2023-10-16 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Okay, after looking at gtkd, I don't think this can be solved with module constructors or swapping out to lazy initialization. One way that might work however is to use a crt_constructor as that runs before the D stuff. However it would now hard code your program to your system. Over all my

Re: Forcing my module to be initialized first

2023-10-15 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 16/10/2023 4:31 PM, dan wrote: I suppose if i could figure out a way to make all other modules depend on my module this would happen, but the module which uses the variable i want to set is in some already-compiled dynamic library that i would prefer not to touch. If its in a shared

Re: allocated object address as high as 46th bit (i.e in the 131072 GB range)

2023-10-09 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
As far as I'm aware, no cpu that you can get ahold of support more than 48bit of address space at the hardware level. There is simply no reason at this time to support more, due to the fact that nobody has implemented anywhere near that maximum. Also worth noting, the address a block of

Re: Is it possible to create a kernel for an operating system in D?

2023-09-25 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Indeed it is. Many people have done projects in this vein, the language isn't the limitation. If you use the -betterC switch, you can fairly quickly get up and going and program a kernel as if you were using C, except with a nicer language. All other considerations like linker scripts ext.

Re: Detect 8-bit alligned type TXY by TX,TY.

2023-09-19 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
I assume what you are wanting is to get the alignment for a given type? https://dlang.org/spec/property.html#alignof If instead you want the offset of a given field that's different. ``T.field.offsetof`` https://dlang.org/spec/struct.html#struct_field_properties Note: alignment cannot be

Re: Which function returns a pair after division ? (integer,frac)

2023-09-18 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
There are no operators for this, not that you need one. ```d void func(int numerator, int denominator, out int quotient, out int remainder) { quotient = numerator / denominator; remainder = numerator % denominator; } ``` This will produce with ldc2 -O3: ``` void example.func(int,

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 08/09/2023 7:59 PM, rempas wrote: |Fatal glibc error: malloc.c:2594 (sysmalloc): assertion failed: (old_top == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >= MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize - 1)) == 0)| I would strongly suggest

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 09/09/2023 2:20 AM, rempas wrote: Do they have automatic symbol order resolution? Which is, testing symbols that other symbol depend on first? Or is it random? No, for this you need ModuleInfo. The order is sequential on what it sees first. Personally I test using full D rather than

Re: malloc error when trying to assign the returned pointer to a struct field

2023-09-08 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
In case you didn't know, all you need to get unittests working in -betterC is: ```d foreach (module_; allModules) { foreach (unitTest; __traits(getUnitTests, module_)) { unitTest();

Re: D DLL crashes if not run on the main thread

2023-09-05 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Assuming it works outside of a DLL, you're probably missing the runtime initialization calls. Mix SimpleDllMain in (or do your own). https://github.com/dlang/dmd/blob/9639d72ea0883808feff7aba71d87c5a78fb7f92/druntime/src/core/sys/windows/dll.d#L577

Re: D DLL crashes if not run on the main thread

2023-09-05 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Whatever is going on, that function you showed would not call into druntime. So I don't think it's related. As of right now I have no tips as I'm tired, but I suspect its on the .net end.

Re: I don't understand betterC

2023-09-01 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
``size_t`` is defined in ``object.d`` which is implicitly imported into all modules. If it cannot be found, one of three things is happening: 1) You have messed with some cli args related to picking druntime/phobos 2) You have defined a module called object. 3) You have a broken compiler

Re: I don't understand betterC

2023-08-31 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
```d extern(C) int main() { import core.stdc.stdio; string hello = "hello"; printf(hello.ptr); return 0; } ``` 1) You forgot to import ``core.stdc.stdio`` 2) String literal is of type string (which is an alias to ``immutable(char)[]``). 3) A slice is a pointer + length, and C

Re: Visual Studio 2022 no longer debugs D program, need an alternative debugger for Windows

2023-08-26 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 27/08/2023 6:47 AM, solidstate1991 wrote: On Saturday, 26 August 2023 at 17:57:22 UTC, jmh530 wrote: You should report this to bugzilla. I'm using it in an unusual way. Since VisualD does not support dub, I have to rely on VSCode as my main editor, then load the executable in an empty

Re: Cool pattern or tragic?

2023-08-25 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
I do something similar with my error types. I have a method called assumeOkay. It'll assert if it isn't ok. There is also unsafeGetLiteral for slice based types. All @system.

Re: std.experimental.allocator

2023-08-13 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 14/08/2023 4:10 AM, ryuukk_ wrote: Also if you want people to use D for games, you want an allocator API that doesn't use RAII, same for exceptions btw After thinking about it a bit, this would suggest to me that you are trying to solve a problem that I would outright recommend against

Re: std.experimental.allocator

2023-08-13 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
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. Memory allocators must be able to store per instance state and that state must not

Re: stb library and importC

2023-08-13 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 14/08/2023 3:23 AM, ryuukk_ wrote: On Sunday, 13 August 2023 at 06:43:10 UTC, Richard (Rikki) Andrew Cattermole wrote: I would argue that this should be done by dmd as it knows where the VS installation is and it'll catch people out who aren't using dub. Oh better, let's try to send a PR

Re: std.experimental.allocator

2023-08-13 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
Mine (-betterC) https://github.com/Project-Sidero/basic_memory/tree/main/source/sidero/base/allocators Similar scope to one in Phobos. On that note I'm still waiting a year+ for Atila to get back to me about talking about where to go for std.experimental.allocators.

Re: stb library and importC

2023-08-13 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
I would argue that this should be done by dmd as it knows where the VS installation is and it'll catch people out who aren't using dub.

Re: What is a dchar ?

2023-07-25 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
The spec says they are unsigned, so if ldc is using sign extension, that is probably a bug.

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

2023-07-24 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 25/07/2023 1:26 AM, devosalain wrote: I could be interesting to also compare the licenses of the 3 compilers. There isn't a huge difference between them. The frontend, druntime and most of phobos (minus zlib and curl) are all Boost regardless of compiler. That just leaves backends,

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

2023-07-24 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 25/07/2023 1:30 AM, 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. compiling with

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

2023-07-24 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
There isn't a huge concern with which one you use. Its quite common to use dmd for development, and ldc for release for example. They all share the same frontend, so they really only differ between them by their glue code to the relevant backend and some modules in druntime that are

Re: array index out of bound may not throw exception?

2023-07-22 Thread Andrew via Digitalmars-d-learn
On Friday, 21 July 2023 at 23:40:44 UTC, mw wrote: Is there a way to let it report on the spot when it happens? The best way is to wrap your thread's main function in a try-catch block and just print whatever error/exception is caught.

Re: Garbage Collectors

2023-07-19 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 19/07/2023 11:13 PM, IchorDev wrote: 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

Re: Garbage Collectors

2023-07-19 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
On 19/07/2023 9:02 PM, IchorDev wrote: 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

  1   2   3   4   5   6   >