Re: gdc or ldc for faster programs?

2022-01-31 Thread Elronnd via Digitalmars-d-learn
On Monday, 31 January 2022 at 08:54:16 UTC, Patrick Schluter wrote: -O3 often chooses longer code and unrollsmore agressively inducing higher miss rates in the instruction caches. -O2 can beat -O3 in some cases when code size is important. That is generally true. My point is that GCC and

Re: gdc or ldc for faster programs?

2022-01-25 Thread Elronnd via Digitalmars-d-learn
On Tuesday, 25 January 2022 at 22:33:37 UTC, H. S. Teoh wrote: interesting because idivl is known to be one of the slower instructions, but gdc nevertheless considered it not worthwhile to replace it, whereas ldc seems obsessed about avoid idivl at all costs. Interesting indeed. Two

Re: RFC to: my need for 'static switch' and CT 'static variables'

2021-11-25 Thread Elronnd via Digitalmars-d-learn
static if (...) { } else static if (...) { } else { static assert(0); }

Re: Attributes (lexical)

2021-11-25 Thread Elronnd via Digitalmars-d-learn
On Thursday, 25 November 2021 at 08:06:27 UTC, rumbu wrote: Is that ok or it's a lexer bug? @ (12) does exactly what I would expect. @nogc I always assumed was a single token, but the spec says otherwise. I suppose that makes sense. #line is dicier as it is not part of the grammar

Re: Is DMD still not inlining "inline asm"?

2021-11-11 Thread Elronnd via Digitalmars-d-learn
On Thursday, 11 November 2021 at 13:22:15 UTC, Basile B. wrote: As for now, I know no compiler that can do that. GCC can do it. Somewhat notoriously, LTO can lead to bugs from underspecified asm constraints following cross-TU inlining.

Re: abs and minimum values

2021-10-31 Thread Elronnd via Digitalmars-d-learn
On Sunday, 31 October 2021 at 10:32:50 UTC, Imperatorn wrote: What I would like is for it to mirror math. Use bigints.

Re: Does associative array change the location of values?

2021-10-30 Thread Elronnd via Digitalmars-d-learn
On Sunday, 31 October 2021 at 02:56:35 UTC, Ali Çehreli wrote: On 10/30/21 3:47 PM, Elronnd wrote: > If the GC were moving, it would also have to move the pointers you took > to AA elements. I doubt D's GC can ever change pointer values because the values may be hiding inside e.g. ulong

Re: Does associative array change the location of values?

2021-10-30 Thread Elronnd via Digitalmars-d-learn
On Saturday, 30 October 2021 at 21:20:15 UTC, Stanislav Blinov wrote: On Saturday, 30 October 2021 at 20:19:58 UTC, Imperatorn wrote: https://dlang.org/spec/garbage.html#pointers_and_gc What test could be written to verify the behaviour? Assuming the GC was moving? If the GC were moving,

Re: Why do we have Dmain?

2021-10-22 Thread Elronnd via Digitalmars-d-learn
On Friday, 22 October 2021 at 09:01:53 UTC, Kagamin wrote: Actually C runtime is many megabytes in size. A couple of samples: $ wc -c /usr/lib/libc-2.33.so 2150424 /usr/lib/libc-2.33.so % wc -c /lib/libc.so.7 1981952 /lib/libc.so.7 I would hardly call two megabytes 'many'.

Re: How to make a function that accepts optional struct but can accept struct literal too

2021-10-15 Thread Elronnd via Digitalmars-d-learn
On Friday, 15 October 2021 at 21:47:21 UTC, Paul Backus wrote: static global(alias value) = value; I fear there will be issues with reentrancy.

Re: How to test if a string is pointing into read-only memory?

2021-10-12 Thread Elronnd via Digitalmars-d-learn
On Tuesday, 12 October 2021 at 09:20:42 UTC, Elronnd wrote: problematic wrt threading Not to mention signals. Reentrancy's a bitch.

Re: How to test if a string is pointing into read-only memory?

2021-10-12 Thread Elronnd via Digitalmars-d-learn
On Tuesday, 12 October 2021 at 08:19:01 UTC, jfondren wrote: What's a reliable test that could be used in a toStringz that skips allocation when given a string in read-only memory? There is no good way. - You could peek in /proc, but that's not portable - You could poke the data and catch

Re: automatic NaN propogation detection?

2021-09-25 Thread Elronnd via Digitalmars-d-learn
On Saturday, 25 September 2021 at 07:53:11 UTC, Chris Katko wrote: Is that some sort of "NP complete" can't-fix issue or something? The general case is obviously unsolvable. Trivial proof: float x = nan; if (undecidable) use x. I'm sure your imagination can supply more realistic cases (but

Re: Development of the foundation of a programming language

2021-09-13 Thread Elronnd via Digitalmars-d-learn
On Tuesday, 14 September 2021 at 03:24:45 UTC, max haughton wrote: On Tuesday, 14 September 2021 at 03:19:46 UTC, Elronnd wrote: On Monday, 13 September 2021 at 11:40:10 UTC, max haughton wrote: The dragon book barely mentions SSA for example In fairness, dmd doesn't use SSA either That's

Re: Development of the foundation of a programming language

2021-09-13 Thread Elronnd via Digitalmars-d-learn
On Monday, 13 September 2021 at 11:40:10 UTC, max haughton wrote: The dragon book barely mentions SSA for example In fairness, dmd doesn't use SSA either

Re: how to filter associative arrays with foreach ?

2021-06-21 Thread Elronnd via Digitalmars-d-learn
On Monday, 21 June 2021 at 03:59:10 UTC, someone wrote: Is there a way to filter the collection at the foreach-level to avoid the inner if ? Here's how I would do it: foreach (k, v; coll) { if (k == unwanted) continue; ... } You still have an if, but the actual loop body doesn't have

Re: noobie question, dub or meson?

2021-03-18 Thread Elronnd via Digitalmars-d-learn
Meson doesn't track dependencies properly for d, so your dirty builds will be wrong if you go that route. You might consider keeping the c and d code in the same repository, but with separate build systems; using dub to build the d code and and whatever tool you prefer for c. Or try reggae.

Re: Developing and running D GUI app on Android

2021-01-10 Thread Elronnd via Digitalmars-d-learn
On Monday, 11 January 2021 at 06:26:41 UTC, evilrat wrote: Android itself is just linux under the hood, however the launcher starts java process that fires up your activity class (main in native languages) from there you just call your native code and that's it. It turns out that you don't

Re: Surprising behaviour of std.experimental.allocator

2020-12-24 Thread Elronnd via Digitalmars-d-learn
On Thursday, 24 December 2020 at 23:46:58 UTC, Elronnd wrote: reduced version: Further reduction: Alloc1 can just be ‘AllocatorList!(n => Region!Mallocator(MB))’.

Re: Surprising behaviour of std.experimental.allocator

2020-12-24 Thread Elronnd via Digitalmars-d-learn
On Thursday, 24 December 2020 at 16:12:31 UTC, Saurabh Das wrote: This causes a segfault when run with rdmd -gx: *snip* First, here's a reduced version: void main() { import std.experimental.allocator: allocatorObject, expandArray; import

Re: Is garbage detection a thing?

2020-11-29 Thread Elronnd via Digitalmars-d-learn
On Sunday, 29 November 2020 at 16:05:04 UTC, Mark wrote: I have no good understanding why "garbage collection" is a big thing and why "garbage detection" is no thing (I think so). Because it's just as expensive to do garbage detection as automatic garbage collection. So if you're going to go

Re: I need "windowsx.d" Someone can send It to me?

2020-09-28 Thread Elronnd via Digitalmars-d-learn
On Sunday, 27 September 2020 at 18:30:10 UTC, Imperatorn wrote: I converting it using VisualD: https://pastebin.com/jzwKRnKZ Try it, maybe it works Somehow, I don't think this is going to fly: static if(__cplusplus) { extern (C) {/* Assume C declarations for C++ */ } /*

Re: Why is "delete" unsafe?

2020-09-23 Thread Elronnd via Digitalmars-d-learn
On Wednesday, 23 September 2020 at 04:15:51 UTC, mw wrote: What do you mean by saying "it's definitely not safe" here? I mean: if I'm careful and know what I'm doing, e.g. remove all the reference to any part of the `object` before call core.memory.GC.free(object), is there still any inherit

Re: Lambda capture by value

2020-02-24 Thread Elronnd via Digitalmars-d-learn
printers[i] = () { write(i); }; I know it looks silly but if you make that: printers[i] = (int i) { return () { write(i); }; }(i); it will do what you want. Or, the slightly prettier (imo) printers[i] = ((i) => () => write(i))(i); Or, if you need to force it to

Re: Using tasks without GC?

2020-01-03 Thread Elronnd via Digitalmars-d-learn
You can control when the gc runs. So if you know the allocations are small enough that they won't OOM, then you can say GC.disable, and it straight up won't run at all. But you can manually run a collection cycle (during a loading screen or whatever) with GC.collect. See

Re: how to implement a function in a different D source file

2019-11-25 Thread Elronnd via Digitalmars-d-learn
On Tuesday, 26 November 2019 at 03:06:52 UTC, Omar wrote: the page here https://dlang.org/spec/function.html suggests you can implement a function in a different file, and a different tutorial somewhere else mentioned the endeavour of no-bodied-functions as a way of presenting a black-box type

Re: Any 3D Game or Engine with examples/demos which just work (compile) out of the box on linux ?

2019-10-18 Thread Elronnd via Digitalmars-d-learn
Up to now I was able to compile just "First Triangle example" https://www.dropbox.com/sh/myem3g69qjyo58v/AABZuvwuRDpnskhEC4AAK5AVa?dl= Why not start with that, then, and expand it until it has everything you need? If it helps, the basic gl startup code for my engine is at http://ix.io/1Z2X/d

Re: Dub version

2019-08-08 Thread Elronnd via Digitalmars-d-learn
Dub add is not supported in dub 1.11.0 Use 'dub fetch'.

Re: Creating a dynamic library

2017-09-29 Thread Elronnd via Digitalmars-d-learn
dmd bla.d bla2.d -shared -fPIC -oflibbla.so

Re: Is prime missing in photos?

2017-09-29 Thread Elronnd via Digitalmars-d-learn
Well the purpose of the exercise kind of *is* to write a prime number generator. You can look up prime number sieves and algorithms. For REALLY large numbers, that takes an insane amount of time, and you can instead use algorithms such as the ones outlined at

Re: Is it possible to avoid call to destructor for structs?

2017-09-27 Thread Elronnd via Digitalmars-d-learn
Here's a simple solution. Just make Bar a pointer and free it before it can be destructed! import std.stdio; struct Bar { ~this() { writeln("~bar"); } } struct Foo { Bar *bar; this(int why_the_fuck_dont_structs_have_default_constructors) { bar = new Bar;

Re: Is it possible to avoid call to destructor for structs?

2017-09-27 Thread Elronnd via Digitalmars-d-learn
Here's a simple solution. Just make Bar a pointer and free it before it can be destructed! import std.stdio; struct Bar { ~this() { writeln("~bar"); } } struct Foo { Bar *bar; this(int why_the_fuck_dont_structs_have_default_constructors) { bar = new Bar;

Re: General performance tip about possibly using the GC or not

2017-08-28 Thread Elronnd via Digitalmars-d-learn
On Tuesday, 29 August 2017 at 00:52:11 UTC, Cecil Ward wrote: I don't know when the GC actually gets a chance to run. Another alternative that I *think* (maybe someone who knows a bit more about the gc can chime in?) would work is if you manually stopped the gc then ran collections when

Re: Primality test function doesn't work on large numbers?

2017-01-09 Thread Elronnd via Digitalmars-d-learn
Thank you! Would you mind telling me what you changed aside from pow() and powm()? diff isn't giving me readable results, since there was some other stuff I trimmed out of the original file. Also, while this is a *lot* better, I still get some lag generating 1024-bit primes and I can't

Primality test function doesn't work on large numbers?

2017-01-07 Thread Elronnd via Digitalmars-d-learn
I'm working on writing an RSA implementation, but I've run into a roadblock generating primes. With a more than 9 bits, my program either hangs for a long time (utilizing %100 CPU!) or returns a composite number. With 9 or fewer bits, I get primes, but I have to run with a huge number of