Detecting performance pitfall in array access

2020-05-16 Thread Adnan via Digitalmars-d-learn
Hello, I am trying to examine what causes my similar D solution to lag behind performance. In the link, they don't have ldc or gdc but according to my machine, the dmd generated code isn't really far behind ldc generated code. So here is the actual code: ulong levenshteinEditDistance(T)(in

Re: betterC mode and std.stdio File

2020-05-16 Thread Paul Backus via Digitalmars-d-learn
On Saturday, 16 May 2020 at 23:00:46 UTC, samrose wrote: I was writing some D with the -betterC option, which is quite nice. I was wondering if it is possible to use std.stdio File reading with the -betterC option. It is working with -debug mode build but I get an error when building with

betterC mode and std.stdio File

2020-05-16 Thread samrose via Digitalmars-d-learn
I was writing some D with the -betterC option, which is quite nice. I was wondering if it is possible to use std.stdio File reading with the -betterC option. It is working with -debug mode build but I get an error when building with release: ```

Objective C protocols

2020-05-16 Thread John Colvin via Digitalmars-d-learn
What's the best way to implement an Objective C protocol in D? I see mention here https://dlang.org/changelog/2.085.0.html#4_deprecated_objc_interfaces but it's not clear where things are these days.

How to move from Unique(someClass) to Unique(someInterface)?

2020-05-16 Thread Konstantin via Digitalmars-d-learn
import std.stdio; import automem; import std.experimental.allocator.mallocator : Mallocator; interface IGetInt { @nogc int GetInt(); } class Foo : IGetInt { @nogc int GetInt() { return 42; } } @nogc void main() { auto foo = Unique!(Foo, Mallocator).construct;

Re: D, Unit_Threaded, and GtkD

2020-05-16 Thread Cogitri via Digitalmars-d-learn
On Saturday, 16 May 2020 at 10:51:07 UTC, Russel Winder wrote: Has anyone got any D code using the Glib event loop, usually GtkD code I'd guess, that is well tested using Unit_Threaded? I always had a hard time doing unittests for things with as many moving parts as glib based software, so

D, Unit_Threaded, and GtkD

2020-05-16 Thread Russel Winder via Digitalmars-d-learn
Has anyone got any D code using the Glib event loop, usually GtkD code I'd guess, that is well tested using Unit_Threaded? -- Russel. === Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Roadm: +44 7770 465 077 London SW11 1EN, UK w:

Re: Fighting the DList

2020-05-16 Thread Jan Hönig via Digitalmars-d-learn
On Saturday, 16 May 2020 at 08:11:20 UTC, Jan Hönig wrote: I am convinced that this works. I have another implementation, which should work: https://run.dlang.io/is/tfBgD0 It is not pretty. It is probably not fast, if the `ignore` is too large. I guess it is in O(n^2) if not O(mn^2), where m

Re: Testing template parameter has given API

2020-05-16 Thread NaN via Digitalmars-d-learn
On Saturday, 16 May 2020 at 02:02:47 UTC, Paul Backus wrote: On Saturday, 16 May 2020 at 01:11:54 UTC, NaN wrote: Rather than trying to inspect the function itself, it's easier to check that the result of *calling* the function is what you expect it to be. So, for example:

Fighting the DList

2020-05-16 Thread Jan Hönig via Digitalmars-d-learn
I want a simple algorithm. Given DList (or a Range, Array... I am not constrained by the container type), I want to combine certain elements depending on some condition. In the toy example, the struct and condition are simpler then in my real scenario, but i think it covers my problem:

Re: Type sniffing at runtime

2020-05-16 Thread Ali Çehreli via Digitalmars-d-learn
On 5/15/20 11:12 PM, Alex wrote:     static if(__traits(compiles, T.min))     writeln("Minimum value  : ", T.min); A little improvement: static if(__traits(isFloating, T)) { writeln("Minimum value : ", -T.max); } else { writeln("Minimum value : ", T.min); }

Re: Type sniffing at runtime

2020-05-16 Thread Alex via Digitalmars-d-learn
On Saturday, 16 May 2020 at 05:22:49 UTC, n0den1te wrote: [...] For example, like this: ´´´ import std; alias types = AliasSeq!( bool, byte, ubyte, short, ushort, int, uint, long, ulong, float, double, real, char, wchar, dchar ); void main() { static foreach(type; types) {