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