Re: Weird RDMD error when trying to import source file from subfolder.

2023-11-01 Thread Julian Fondren via Digitalmars-d-learn
On Wednesday, 1 November 2023 at 16:24:04 UTC, BoQsc wrote: **Error:** ``` rdmd testimport.d testimport.d(2): Error: module `next` from file waffle\next.d must be imported with 'import next;' ``` You import 'waffle.next', but the module is inferred to be 'next'. If put `module

Re: What are the best available D (not C) File input/output options?

2023-11-02 Thread Julian Fondren via Digitalmars-d-learn
On Thursday, 2 November 2023 at 15:46:23 UTC, confuzzled wrote: I've ported a small script from C to D. The original C version takes roughly 6.5 minutes to parse a 12G file while the port originally took about 48 minutes. My naïve attempt to improve the situation pushed it over an hour and 15

Re: surviving wasm

2023-12-13 Thread Julian Fondren via Digitalmars-d-learn
On Wednesday, 13 December 2023 at 20:40:20 UTC, monkyyy wrote: so long term planning on wasm raylib; I want compatibility with the good parts of the std, the std is causal about using libc while ldc-wasm half-baked implication is missing a bunch of basically worthless symbols but given the std

Re: Changing behavior of associative array

2023-12-16 Thread Julian Fondren via Digitalmars-d-learn
On Sunday, 17 December 2023 at 00:10:56 UTC, Kevin Bailey wrote: instead it seems like 'm' is a pointer to a std::map, that is initialized on use if null. (I think it's that latter part that gives the illusion of being already initialized.) Yes:

Re: Changing behavior of associative array

2023-12-16 Thread Julian Fondren via Digitalmars-d-learn
On Saturday, 16 December 2023 at 22:44:16 UTC, Dennis wrote: That's because `m[f] = 1` initializes the associative array to something non-null. If you pass a `null` AA to a function which adds things, the caller will still have a null pointers. I've gotten this error in deployed Perl.

Re: macOS Sonoma Linker Issue

2023-12-21 Thread Julian Fondren via Digitalmars-d-learn
On Thursday, 21 December 2023 at 22:19:07 UTC, Renato wrote: LDC is slow and makes huge multi-MB binaries (is that normal?). DMD seemed much better to me. But at least LDC works :) so will use that for now. On my setup ldc generates small binaries and dmd generates huge ones. The difference

Re: D: Convert/parse uint integer to string. (@nogc)

2023-11-28 Thread Julian Fondren via Digitalmars-d-learn
On Tuesday, 28 November 2023 at 08:51:21 UTC, Mark Davies wrote: I did it this way ... You always print the full array of bytes this way. Output piped to `od -c` is ``` 000 1 2 3 4 5 377 377 377 377 377 \n - 1 2 3 4 020 5 377 377 377 377 \n ``` Those 377s

Re: D: Declaring empty pointer variables that return address inside function calls?

2023-11-23 Thread Julian Fondren via Digitalmars-d-learn
On Thursday, 23 November 2023 at 20:13:59 UTC, BoQsc wrote: Nothing wrong. It would be just a more concise compact way to do the same. Also I mostly wanted to know if something like that is already possible in D language. It's not a huge loss if it is not possible. This is possible in Go:

Re: mixin under -betterC

2023-11-23 Thread Julian Fondren via Digitalmars-d-learn
On Thursday, 23 November 2023 at 17:46:55 UTC, DLearner wrote: I just find it surprising that your suggestion worked, but the (slightly simpler) earlier version did not. The `enum` answer? That also works, but you have to make a change at the callsite as well, to `mixin(mxnTest!("Var_A",

Re: mixin under -betterC

2023-11-23 Thread Julian Fondren via Digitalmars-d-learn
On Thursday, 23 November 2023 at 16:33:52 UTC, DLearner wrote: Why is this so, bearing in mind the concatenations are executed at compile, not run, time? If you compile without -betterC, it'll work, but if you examine the result you'll find that the mxnTest function is still compiled into

Re: Advent of Code 2023

2023-12-03 Thread Julian Fondren via Digitalmars-d-learn
On Saturday, 2 December 2023 at 13:33:33 UTC, Johannes Miesenhardt wrote: I am a bloody beginner so if there are any things that are very wrong with this please point them out. The fact that I need a template for accepting both a string and a char[] is very weird but I went with it. I am also

Re: Advent of Code 2023

2023-12-03 Thread Julian Fondren via Digitalmars-d-learn
On Sunday, 3 December 2023 at 23:44:43 UTC, Julian Fondren wrote: ```d if (str[i..$].startsWith(key)) return value; ``` Corrected. The other doesn't compile, unless you never run it with -version=Part2 ...

Re: Advent of Code 2023

2023-12-03 Thread Julian Fondren via Digitalmars-d-learn
On Monday, 4 December 2023 at 03:50:47 UTC, Siarhei Siamashka wrote: On Monday, 4 December 2023 at 03:07:07 UTC, matheus wrote: import std.stdio; import std.algorithm; import std.array; import std.format; import std.conv; import std.string; ... Why do you do multiple imports instead of one

Re: D: How to check if a function is chained? a().b().c();

2023-11-18 Thread Julian Fondren via Digitalmars-d-learn
On Saturday, 18 November 2023 at 07:47:19 UTC, BoQsc wrote: `program("someProgramName").pipe("someOtherProgramName");` Executes and pipes output to another program. `program();` - Only executes the program. Serious answer: have a function handle this, instead of the semicolon.

Re: What is :-) ?

2023-11-20 Thread Julian Fondren via Digitalmars-d-learn
On Monday, 20 November 2023 at 16:09:33 UTC, Antonio wrote: **Why this is a function and not a delegate?** ```auto createCounter = (int nextValue) => (int dummy) => nextValue++;``` Syntactically I dont see any difference: `createCounter` is a function, and not a delegate, as it doesn't

Re: What parser generator can let me run arbitrary code in its match rules?

2023-11-20 Thread Julian Fondren via Digitalmars-d-learn
On Monday, 20 November 2023 at 23:50:24 UTC, Dmitry Ponyatov wrote: - not abandoned years ago - documentation and commented samples presenets - CTFE the best https://code.dlang.org/packages/pegged

Re: Challenge Tuples

2024-04-27 Thread Julian Fondren via Digitalmars-d-learn
On Friday, 26 April 2024 at 13:25:34 UTC, Salih Dincer wrote: You have a 5-item data tuples as Tuple(1, 2, 3, [1, 3], 5) and implement the sum (total = 15) with the least codes using the sum() function of the language you are coding... Nim: ```nim import std/[math, typetraits, macros] macro

Re: Why is Phobos `Flag` so overthought ?

2024-05-06 Thread Julian Fondren via Digitalmars-d-learn
On Monday, 6 May 2024 at 17:55:49 UTC, user1234 wrote: I think this just works: ```d enum Flag : bool { no, yes } alias AllowVancancy = Flag; // example usage ``` ```d import std.stdio : writeln; enum Flag : bool { no, yes } alias Traditional = Flag; alias Color = Flag; void