Re: any chance to get it working on windows xp?
On Sunday, 17 May 2020 at 22:30:22 UTC, a beginner wrote: I have searched online for some info, indeed I found something, but not being familiar with the tools it hasn't been terribly useful. Only it confirms that windows support is somewhat disappointing in general, xp or not. I've been using D on Windows since I first found it in 2003. From my perspective, Windows support is fairly solid. It seems to me my best chance is to stay with dmd 2.085.1, try fix the cache problem in dub 1.11 myself (or give up on that and build "by hand"), probably wrestle some linking problems (pretty sure I wouldn't succeed with that) and be happy until I can upgrade. After all, these days programming is just a hobby for me. But honestly, all this is quite annoying for a beginner. In my experience, trouble getting the tools to work is often the biggest obstacle in learning a new language (well, unless it's something really weird...), which in many cases means giving up after some cursing. Unfortunately, the minimum Windows version "officially" supported is Windows 7: https://forum.dlang.org/post/ktfgps$2ghh$1...@digitalmars.com With no testing on XP, you are bound to run into difficulties trying to use the tools there. So yeah, your best bet is using a compiler version that works and see if building dub from source makes a difference. If you can't get dub to work, then you'll want to look into using rdmd, which has shipped with dmd for years now, or perhaps makefiles.
undefined reference to 'deflateEnd'
Hi, I have some issues, the get this program working on ubuntu: ``` Dockerfile FROM ubuntu:focal RUN apt-get update && apt-get upgrade -y \ && apt-get install --no-install-recommends -y build-essential ldc dub zlib1g-dev COPY app.d /tmp/ RUN dub build --single /tmp/app.d -v ``` ``` app.d /+ dub.sdl: name "app" lflags "-lz" "-ldl" dflags "-static" +/ import std; void main(){} ``` Linker fails with error messages like these: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libphobos2-ldc.a(zlib.o):function _D3std4zlib8Compress5errorMFiZv: error: undefined reference to 'deflateEnd' /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libphobos2-ldc.a(zlib.o):function _D3std4zlib8Compress6__dtorMFZv: error: undefined reference to 'deflateEnd' The actual link command looks right: /usr/bin/ldc2 -oftmp/.dub/build/application-debug-linux.posix-x86_64-ldc_2090-ED4668B88284A40FA4668246697CB2B5/app tmp/.dub/build/application-debug-linux.posix-x86_64-ldc_2090-ED4668B88284A40FA4668246697CB2B5/app.o -L--no-as-needed -L-lz -L-ldl -static -g Do you have an idea? Kind regards André
Re: any chance to get it working on windows xp?
It isn't just about the OS. Dmd and ldc's codegen haven't stood still for 10 years. They both will be emitting instructions your cpu cannot handle. Hence crashes.
Re: any chance to get it working on windows xp?
On Sunday, 17 May 2020 at 22:30:22 UTC, a beginner wrote: [...] You could try grabbing a newer dub release binary from here: https://github.com/dlang/dub/releases There are two versions (installer + zip archive). It looks like you're better off with the zip archive. Alternatively, if you have a working compiler building dub from scratch isn't hard. You just need to clone the repo and run the build script (build.bat in your case). Good luck!
any chance to get it working on windows xp?
It might seem unbelievable, but windows xp is still widely used (did you know it runs most bank cash machines by the way?). As it happens, in my case I've been away from computing a long while, and my old box with xp-sp2 is all I have available at the moment. I had a very old dmd version which used to work. I tried to use it, only to discover dub doesn't connect online anymore (guess it's some security protocol update, stuff I know next to nothing about). Tried to replace dub with the latest one (1.24 perhaps, not sure), doesn't run. Tried dub 1.11, it runs but fails trying to xcopy the package cache onto itself, and doing so without quoting the obviously space-including pathname ("documents and settings", I wish I could kick in the balls whoever came up with that). I did not check the source yet, but the error message shows an xcopy command line and a "wrong number of arguments" (I'll spare my opinion on this one). Deleted the cache, same problem: it works the first time, the second time it tries to move the cache from where it just created it to... where it is already. Tried the last dmd2 2.092.0, doesn't run. I went backwards until 2.089.1 which seems to work, but calls lld-link which doesn't. This comes as a surprise, because sc.ini has "LINKCMD=%@P%\optlink.exe" in the Environment32 section. Tried to move lld-link out of the way and now it tries to link, only it fails with an "error 4 module corrupt" or something. Went back to 2.085.1 and behold, it links the "hello world" kind of program as generated by "dub init". But dub gives access violation as soon as a dependency is involved. No hint to what the problem is, just "access violation" and good bye. Even a simple "dub init" or "dub add". Tried replacing it with dub from dmd 2.089.1 and... access violation. Now, I am probably doing something wrong, and someone familiar with the tools would likely know what to do, but that is not me. Is there a release working on xp (sp2 at that), dmd2 and dub at least, and if so, which one? if not, is there a way to pick parts here and there and make it work? Is there a technical reason for dropping xp compatibility or did it just happen and who cares in 2020? I have searched online for some info, indeed I found something, but not being familiar with the tools it hasn't been terribly useful. Only it confirms that windows support is somewhat disappointing in general, xp or not. It seems to me my best chance is to stay with dmd 2.085.1, try fix the cache problem in dub 1.11 myself (or give up on that and build "by hand"), probably wrestle some linking problems (pretty sure I wouldn't succeed with that) and be happy until I can upgrade. After all, these days programming is just a hobby for me. But honestly, all this is quite annoying for a beginner. In my experience, trouble getting the tools to work is often the biggest obstacle in learning a new language (well, unless it's something really weird...), which in many cases means giving up after some cursing.
Re: D, Unit_Threaded, and GtkD
On Sunday, 17 May 2020 at 10:19:38 UTC, Russel Winder wrote: I am experimenting with using manual control of the Glib event loop using the pending and iteration methods on the default MainContext within each unit- threaded test. The alternative of running a GTK application and then putting the tests in as an asynchronous sequence only works with Rust and Python since D has no coroutines of any sort. A Fiber can't be used for this ? D Fibers don't have a scheduler. Yielding returns to the caller context. https://dlang.org/phobos/core_thread_fiber.html
Re: How to get rid of "nothrow" ?
17.05.2020 17:35, Vinod K Chandran пишет: It worked. Thanks :) I have one more question. Which is better, to include all the switch cases inside a single try catch or write separate try catch for each switch cases ? all the switch cases inside a single try catch is better
Re: Droutines [was D, Unit_Threaded, and GtkD]
On Sun, 2020-05-17 at 11:19 +0100, Russel Winder wrote: […] > > Of course now there is jin.go which is a synchronous multi-tasking approach > with channels rather than an asynchronous approach available in D. Had I checked I would have seen this was a four years ago package that has been left fallow since. It seems like something that should be resurrected and made a core package for concurrency and parallelism for D. I suspect there is significant overlap of some task, thread, fibre, and scheduling code with std.parallelism, but is it worth trying to share code ir just go with separate code? It might be worth extracting the futures code out of vibe.d so that D has a futures package in the Dub repository so that people can create asynchronous coroutines on top of it. -- Russel. === Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Roadm: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk signature.asc Description: This is a digitally signed message part
Re: How to get rid of "nothrow" ?
On Sunday, 17 May 2020 at 14:21:41 UTC, Vinod K Chandran wrote: On Sunday, 17 May 2020 at 09:50:00 UTC, Olivier Pisano wrote: On Sunday, 17 May 2020 at 09:27:40 UTC, Vinod K Chandran wrote: Hi all, I am trying to create a win32 based gui in dlang. So far so good. I can create and display my window on screen. But for handling messages, i planned to write something like message crackers in c++. But since, my WndProc function is a "nothrow" function, i cannot use any function without "nothorw" in that WndProc. How to solve this problem ? Hi, You need to catch any exceptions inside of your WndProc so they don't propagate: LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) nothrow { try { // your code logic here may call throwing functions } catch (Exception e) { // You should log exceptions here } } Hi, Thanks a lot. Let me try. It worked. Thanks :) I have one more question. Which is better, to include all the switch cases inside a single try catch or write separate try catch for each switch cases ?
Re: How to get rid of "nothrow" ?
On Sunday, 17 May 2020 at 09:50:00 UTC, Olivier Pisano wrote: On Sunday, 17 May 2020 at 09:27:40 UTC, Vinod K Chandran wrote: Hi all, I am trying to create a win32 based gui in dlang. So far so good. I can create and display my window on screen. But for handling messages, i planned to write something like message crackers in c++. But since, my WndProc function is a "nothrow" function, i cannot use any function without "nothorw" in that WndProc. How to solve this problem ? Hi, You need to catch any exceptions inside of your WndProc so they don't propagate: LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) nothrow { try { // your code logic here may call throwing functions } catch (Exception e) { // You should log exceptions here } } Hi, Thanks a lot. Let me try.
Re: Objective C protocols
On 2020-05-17 11:32, John Colvin wrote: On Saturday, 16 May 2020 at 19:14:51 UTC, John Colvin wrote: 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. It's the same these days. It's still not implemented. Based on some experimentation, I'm starting to wonder do protocols actually have any runtime component in Objective C? No, not really. Because if I pass in an extern(Objective-C) class with the right interface to a function expecting a protocol everything just works. Yes, that works fine. You can put the methods from the protocol directly in the class that implements them or in a base class. If you really want to have a specific type for the protocol you can use an abstract class to emulate an interface/protocol and cast your actual class to the abstract class: extern (Objective-C) abstract class Printer // the protocol { void print(int value) @selector("print:"); } extern (Objective-C) class Foo : NSObject { override static Foo alloc() @selector("alloc"); override Foo init() @selector("init"); void print(int value) @selector("print:") { writeln(value); } } extern (Objective-C) void print(Printer); void main() { auto foo = Foo.alloc.init; print(cast(Printer) cast(void*) foo); // need to cast through void* } -- /Jacob Carlborg
Re: Detecting performance pitfall in array access
On Sunday, 17 May 2020 at 11:39:30 UTC, kinke wrote: DMD v2.091: * dmd -m64 -O -release -boundscheck=off -run ..\speed.d aa bbc: ~11 μs I forgot `-inline` for DMD; that reduces the speed, yielding ~16 μs.
Re: Detecting performance pitfall in array access
On Sunday, 17 May 2020 at 03:30:57 UTC, Adnan wrote: In my machine, if you feed "aa" and "bbc" to the function, ldc generated code takes around 400 microseconds. I don't have an access to gdc in my machine. https://imgshare.io/image/NN8Xmp Full code: D : https://run.dlang.io/is/vLj7BC Nim : https://play.nim-lang.org/#ix=2mhH (for reference) Compiler flags: dub : build -b release-nobounds nimble : --d:danger My timings are very different, using LDC v1.21 on Win64: * ldc2 -O -release -run bla.d aa bbc: 8-9 μs * ldc2 -O -release -boundscheck=off -run bla.d aa bbc: 8-9 μs * ldc2 -O -release -boundscheck=off -flto=full -defaultlib=phobos2-ldc-lto,druntime-ldc-lto -run bla.d aa bbc: 4 μs DMD v2.091: * dmd -m64 -O -release -boundscheck=off -run ..\speed.d aa bbc: ~11 μs As a side note, using jagged arrays for multiple dimensions should probably be avoided whenever you can.
Re: Objective C protocols
On Saturday, 16 May 2020 at 19:14:51 UTC, John Colvin wrote: 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. I did it throught the Obj-C runtime a while ago: https://github.com/AuburnSounds/Dplug/blob/dda1f80d69e8bfd4af0271721738ce827c2f0eae/au/dplug/au/cocoaviewfactory.d#L99 and the result is brittle, you need to replicate the protocol declaration, add all methods etc.
Re: D, Unit_Threaded, and GtkD
On Sat, 2020-05-16 at 11:37 +, Cogitri via Digitalmars-d-learn wrote: > 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 I usually just do > integration tests like so: > https://gitlab.alpinelinux.org/Cogitri/apk-polkit/-/blob/1dfbe2b3d959e3c083fcb82419a0a0401c485937/tests/apkd_dbus_server/addAndDelete.d > > Maybe I should look into Unit_Threaded for more fine grained > tests, but I think the effort for all the mocking stuff that I'd > have to implement even for a (relatively) simple GDBus > application would be quite substantial. I am experimenting with using manual control of the Glib event loop using the pending and iteration methods on the default MainContext within each unit- threaded test. The alternative of running a GTK application and then putting the tests in as an asynchronous sequence only works with Rust and Python since D has no coroutines of any sort. Of course now there is jin.go which is a synchronous multi-tasking approach with channels rather than an asynchronous approach available in D. -- Russel. === Dr Russel Winder t: +44 20 7585 2200 41 Buckmaster Roadm: +44 7770 465 077 London SW11 1EN, UK w: www.russel.org.uk signature.asc Description: This is a digitally signed message part
Re: How to get rid of "nothrow" ?
On Sunday, 17 May 2020 at 09:27:40 UTC, Vinod K Chandran wrote: Hi all, I am trying to create a win32 based gui in dlang. So far so good. I can create and display my window on screen. But for handling messages, i planned to write something like message crackers in c++. But since, my WndProc function is a "nothrow" function, i cannot use any function without "nothorw" in that WndProc. How to solve this problem ? Hi, You need to catch any exceptions inside of your WndProc so they don't propagate: LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) nothrow { try { // your code logic here may call throwing functions } catch (Exception e) { // You should log exceptions here } }
Re: Detecting performance pitfall in array access
On Sunday, 17 May 2020 at 03:30:57 UTC, Adnan wrote: 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. https://imgshare.io/image/NN8Xmp Can you add `--force` to the dub commandline to make sure it is rebuilding the executable? -Johan
Re: Objective C protocols
On Saturday, 16 May 2020 at 19:14:51 UTC, John Colvin wrote: 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. Based on some experimentation, I'm starting to wonder do protocols actually have any runtime component in Objective C? Because if I pass in an extern(Objective-C) class with the right interface to a function expecting a protocol everything just works.
How to get rid of "nothrow" ?
Hi all, I am trying to create a win32 based gui in dlang. So far so good. I can create and display my window on screen. But for handling messages, i planned to write something like message crackers in c++. But since, my WndProc function is a "nothrow" function, i cannot use any function without "nothorw" in that WndProc. How to solve this problem ?
link error on Windows
I think is works with older versions of DMD. D:\jpro\dpro2\SpellIt>dub Performing "debug" build using D:\jpro\dmd2\windows\bin\dmd.exe for x86_64. bindbc-loader 0.3.0: target for configuration "noBC" is up to date. bindbc-sdl 0.18.0: target for configuration "dynamic" is up to date. spellit ~master: building configuration "application"... ..\arsdLib\source\arsd\terminal.d(3657,5): Deprecation: variable idx is shadowing variable arsd.terminal.ScrollbackBuffer.drawInto.idx. Rename the foreach variable. Linking... lld-link: error: undefined symbol: _D4core8internal7switch___T14__switch_errorZQrFNaNbNiNfAyamZv referenced by D:\jpro\dmd2\windows\bin\..\..\src\phobos\std\format.d:7088 .dub\build\application-debug-windows-x86_64-dmd_2092-8E7B763C2C746F27EB489566C5B583AE\spellit.obj:(_D3std6format__T10printFloatTfTaZQrFNaNfNkAafSQBsQBr__T10FormatSpecTaZQpEQCtQCs12RoundingModeZQCa) referenced by D:\jpro\dmd2\windows\bin\..\..\src\phobos\std\uni.d:6291 .dub\build\application-debug-windows-x86_64-dmd_2092-8E7B763C2C746F27EB489566C5B583AE\spellit.obj:(_D3std3uni__T16UnicodeSetParserTSQBf5regex8internal6parser__T6ParserTAyaTSQCuQBpQBmQBg7CodeGenZQBiZQDi13parseCharTermMFNfZSQEr8typecons__T5TupleTSQFoQFn__T13InversionListTSQGoQGn8GcPolicyZQBhTEQHjQHi__TQHhTQGsZQHp8OperatorZQDh) referenced by D:\jpro\dpro2\SpellIt\..\JecsdlLib\source\jecsdl\draw.d:47 .dub\build\application-debug-windows-x86_64-dmd_2092-8E7B763C2C746F27EB489566C5B583AE\spellit.obj:(_D6jecsdl4draw10JRectangleQrMFZv) referenced by D:\jpro\dpro2\SpellIt\..\JecsdlLib\source\jecsdl\lettermanager.d:650 .dub\build\application-debug-windows-x86_64-dmd_2092-8E7B763C2C746F27EB489566C5B583AE\spellit.obj:(_D6jecsdl13lettermanager13LetterManager7doInputMFKbZa) referenced by D:\jpro\dpro2\SpellIt\..\arsdLib\source\arsd\dom.d:5988 .dub\build\application-debug-windows-x86_64-dmd_2092-8E7B763C2C746F27EB489566C5B583AE\spellit.obj:(_D4arsd3dom13parseSelectorFAAyabZSQBgQBe17SelectorComponent) referenced by D:\jpro\dpro2\SpellIt\..\arsdLib\source\arsd\terminal.d:1770 .dub\build\application-debug-windows-x86_64-dmd_2092-8E7B763C2C746F27EB489566C5B583AE\spellit.obj:(_D4arsd8terminal20RealTimeConsoleInput11injectEventMFSQCaQBy10InputEventEQCtQCrQCl17InjectionPositionZv) referenced by D:\jpro\dpro2\SpellIt\..\arsdLib\source\arsd\terminal.d:3718 .dub\build\application-debug-windows-x86_64-dmd_2092-8E7B763C2C746F27EB489566C5B583AE\spellit.obj:(_D4arsd8terminal16ScrollbackBuffer11handleEventMFSQBwQBu10InputEventZb) referenced by D:\jpro\dpro2\SpellIt\source\app.d:188 .dub\build\application-debug-windows-x86_64-dmd_2092-8E7B763C2C746F27EB489566C5B583AE\spellit.obj:(_Dmain) referenced by D:\jpro\dpro2\SpellIt\source\app.d:185 .dub\build\application-debug-windows-x86_64-dmd_2092-8E7B763C2C746F27EB489566C5B583AE\spellit.obj:(_Dmain) referenced by D:\jpro\dpro2\SpellIt\source\projectetc.d:307 .dub\build\application-debug-windows-x86_64-dmd_2092-8E7B763C2C746F27EB489566C5B583AE\spellit.obj:(_D10projectetc10ProjectEtc11showTheWordMFZv) referenced 1 more times Error: linker exited with status 1 D:\jpro\dmd2\windows\bin\dmd.exe failed with exit code 1.