Re: Dub version
On Friday, 9 August 2019 at 15:41:08 UTC, GreatSam4sure wrote: On Friday, 9 August 2019 at 14:15:36 UTC, Andre Pany wrote: On Friday, 9 August 2019 at 13:59:51 UTC, GreatSam4sure wrote: On Friday, 9 August 2019 at 13:01:51 UTC, Andre Pany wrote: On Friday, 9 August 2019 at 12:10:21 UTC, GreatSam4sure wrote: [...] With recent version of Dub the default architecture changed from x86 to x86_64. You can force the old architecture by using argument -a x86. Does this help? Kind regards Andre No luck sir. I can only run D app by installing dub 1.11.0. Just to be clear, are you saying once DMD is installed I don't need to install dub again or add it as a dependency to app? Pls clarify. The package manager Dub is included within the DMD archive / DMD setup executable. Does you have the problem also for a simple hello world sub project? Please execute: dub init sample1 cd sample1 dub build -a x86 sample1.exe Kind regards Andre Yes, from command prompt Dub init sample1 Click enter Windows 10 says this app can't run on your PC This problem is common with Windows 10 It may be due to their smart screen app. But all packages in dub registering has be updated to: Dub add arsd- official So what is the solution to this problem I misunderstood you, I thought the resulting binary is causing the issue, but actually dub is causing the issue. If I remember correctly, in the blocking dialog is an option to execute Dub anyway. Could you try it? But the dialog should not be shown at all. Kind regards Andre
Re: Dub version
On Friday, 9 August 2019 at 14:15:36 UTC, Andre Pany wrote: On Friday, 9 August 2019 at 13:59:51 UTC, GreatSam4sure wrote: On Friday, 9 August 2019 at 13:01:51 UTC, Andre Pany wrote: On Friday, 9 August 2019 at 12:10:21 UTC, GreatSam4sure wrote: On Friday, 9 August 2019 at 09:01:54 UTC, Andre Pany wrote: [...] I am at lost here. Before I can run my D project using dub.1.11.0 executable install on my system but after uninstalling and install dmd 2.087.1 cannot run my project using dub from the project root folder. In windows 10 it shows this app can't run on your PC. To find a version for your PC, check with the software publisher. The same how's for the com and rdmd What is the way out. With recent version of Dub the default architecture changed from x86 to x86_64. You can force the old architecture by using argument -a x86. Does this help? Kind regards Andre No luck sir. I can only run D app by installing dub 1.11.0. Just to be clear, are you saying once DMD is installed I don't need to install dub again or add it as a dependency to app? Pls clarify. The package manager Dub is included within the DMD archive / DMD setup executable. Does you have the problem also for a simple hello world sub project? Please execute: dub init sample1 cd sample1 dub build -a x86 sample1.exe Kind regards Andre Yes, from command prompt Dub init sample1 Click enter Windows 10 says this app can't run on your PC This problem is common with Windows 10 It may be due to their smart screen app. But all packages in dub registering has be updated to: Dub add arsd- official So what is the solution to this problem
Re: Dub version
On Friday, 9 August 2019 at 13:59:51 UTC, GreatSam4sure wrote: On Friday, 9 August 2019 at 13:01:51 UTC, Andre Pany wrote: On Friday, 9 August 2019 at 12:10:21 UTC, GreatSam4sure wrote: On Friday, 9 August 2019 at 09:01:54 UTC, Andre Pany wrote: [...] I am at lost here. Before I can run my D project using dub.1.11.0 executable install on my system but after uninstalling and install dmd 2.087.1 cannot run my project using dub from the project root folder. In windows 10 it shows this app can't run on your PC. To find a version for your PC, check with the software publisher. The same how's for the com and rdmd What is the way out. With recent version of Dub the default architecture changed from x86 to x86_64. You can force the old architecture by using argument -a x86. Does this help? Kind regards Andre No luck sir. I can only run D app by installing dub 1.11.0. Just to be clear, are you saying once DMD is installed I don't need to install dub again or add it as a dependency to app? Pls clarify. The package manager Dub is included within the DMD archive / DMD setup executable. Does you have the problem also for a simple hello world sub project? Please execute: dub init sample1 cd sample1 dub build -a x86 sample1.exe Kind regards Andre
Re: Dub version
On Friday, 9 August 2019 at 13:01:51 UTC, Andre Pany wrote: On Friday, 9 August 2019 at 12:10:21 UTC, GreatSam4sure wrote: On Friday, 9 August 2019 at 09:01:54 UTC, Andre Pany wrote: [...] I am at lost here. Before I can run my D project using dub.1.11.0 executable install on my system but after uninstalling and install dmd 2.087.1 cannot run my project using dub from the project root folder. In windows 10 it shows this app can't run on your PC. To find a version for your PC, check with the software publisher. The same how's for the com and rdmd What is the way out. With recent version of Dub the default architecture changed from x86 to x86_64. You can force the old architecture by using argument -a x86. Does this help? Kind regards Andre No luck sir. I can only run D app by installing dub 1.11.0. Just to be clear, are you saying once DMD is installed I don't need to install dub again or add it as a dependency to app? Pls clarify.
Re: Abstract classes vs interfaces, casting from void*
On Friday, 9 August 2019 at 12:26:59 UTC, John Colvin wrote: import std.stdio; interface I { void foo(); } class C : I { override void foo() { writeln("hi"); } } abstract class AC { void foo(); } class D : AC { override void foo() { writeln("hi"); } } void main() { auto c = new C(); writeln(0); (cast(I)cast(void*)c).foo(); writeln(1); (cast(C)cast(void*)c).foo(); writeln(2); (cast(I)cast(C)cast(void*)c).foo(); auto d = new D(); writeln(3); (cast(AC)cast(void*)d).foo(); writeln(4); (cast(D)cast(void*)d).foo(); writeln(5); (cast(AC)cast(D)cast(void*)d).foo(); } This produces the output: 0 1 hi 2 hi 3 hi 4 hi 5 hi Why is there no "hi" between 0 and 1? We're getting into somewhat advanced topics now. This is described in the Application Binary Interface page of the documentation[0]. In short: classes and interfaces both use a vtable[1] that holds pointers to each of their methods. When we cast a class instance to an interface, the pointer is adjusted, such that the interface's vtable is the first member. Casting via `void*` bypasses this adjustment. Using `__traits(classInstanceSize)`, we can see that `C` has a size of 12 bytes, while `D` only is 8 bytes (24 and 16 on 64-bit). This corresponds to the extra interface vtable as described above. When we first cast to `void*`, no adjustment happens, because we're not casting to an interface. When we later cast the `void*` to an interface, again no adjustment happens - in this case because the compiler doesn't know what we're casting from. If we use `__traits(allMembers, C)`, we can figure out which methods it actually has, and implement those with some extra debug facilities (printf): class C : I { override void foo() { writeln("hi"); } override string toString() { writeln("toString"); return ""; } override hash_t toHash() { debug printf("toHash"); return 0; } override int opCmp(Object o) { writeln("opCmp"); return 0; } override bool opEquals(Object o) { writeln("opEquals"); return false; } } If we substitute the above in your program, we see that the `toString` method is the one being called. This is simply because it's at the same location in the vtable as `foo` is in `I`'s vtable. When casting from a class to a superclass, no pointer adjustment is needed, as the vtable location is the same for both. We can look closer at the vtable, and see that for a new subclass, additional entries are simply appended at the end: class C { void foo() {} } class D : C { void bar() {} } unittest { import std.stdio; C c = new C(); D d = new D(); writeln("Pointer to foo(): ", ().funcptr); writeln("Pointer to bar(): ", ().funcptr); writeln("Pointer to foo() in C's vtable: ", c.__vptr[5]); writeln("Pointer to foo() in D's vtable: ", d.__vptr[5]); writeln("Pointer to bar() in D's vtable: ", d.__vptr[6]); } As we see, `foo()` has the position in the vtable for both `c` and `d`, while `D`'s new `bar()` method is added as the next entry. -- Simen [0]: https://dlang.org/spec/abi.html [1]: https://en.wikipedia.org/wiki/Virtual_method_table
Re: Abstract classes vs interfaces, casting from void*
On Friday, 9 August 2019 at 13:19:14 UTC, kinke wrote: On Friday, 9 August 2019 at 12:26:59 UTC, John Colvin wrote: Why is there no "hi" between 0 and 1? Because you are treating the unadjusted object pointer as interface pointer and then call the only virtual function of that interface, in the 2nd vtbl slot (after the TypeInfo ptr). Casting a class ref to an interface offsets the pointer, so that the interface ref points to the interface vptr for that object instance. This is missing in that line, and so you are invoking the first virtual function of class C, which is some base function in `Object`. Ok, makes sense, thanks.
Re: Abstract classes vs interfaces, casting from void*
On Friday, 9 August 2019 at 12:26:59 UTC, John Colvin wrote: Why is there no "hi" between 0 and 1? Because you are treating the unadjusted object pointer as interface pointer and then call the only virtual function of that interface, in the 2nd vtbl slot (after the TypeInfo ptr). Casting a class ref to an interface offsets the pointer, so that the interface ref points to the interface vptr for that object instance. This is missing in that line, and so you are invoking the first virtual function of class C, which is some base function in `Object`.
Re: Dub version
On Friday, 9 August 2019 at 12:10:21 UTC, GreatSam4sure wrote: On Friday, 9 August 2019 at 09:01:54 UTC, Andre Pany wrote: On Friday, 9 August 2019 at 08:30:49 UTC, GreatSam4sure wrote: [...] My assumption is, you have several dub executables on your computer. A recent one, bundled with dmd, and an old 1.11.0. Delete the old one, this should solve your problem. Please provide more information what you mean with "rdmd does not work". In general rdmd is superseded by the command "dmd -run". Kind regards Andre I am at lost here. Before I can run my D project using dub.1.11.0 executable install on my system but after uninstalling and install dmd 2.087.1 cannot run my project using dub from the project root folder. In windows 10 it shows this app can't run on your PC. To find a version for your PC, check with the software publisher. The same how's for the com and rdmd What is the way out. With recent version of Dub the default architecture changed from x86 to x86_64. You can force the old architecture by using argument -a x86. Does this help? Kind regards Andre
Abstract classes vs interfaces, casting from void*
import std.stdio; interface I { void foo(); } class C : I { override void foo() { writeln("hi"); } } abstract class AC { void foo(); } class D : AC { override void foo() { writeln("hi"); } } void main() { auto c = new C(); writeln(0); (cast(I)cast(void*)c).foo(); writeln(1); (cast(C)cast(void*)c).foo(); writeln(2); (cast(I)cast(C)cast(void*)c).foo(); auto d = new D(); writeln(3); (cast(AC)cast(void*)d).foo(); writeln(4); (cast(D)cast(void*)d).foo(); writeln(5); (cast(AC)cast(D)cast(void*)d).foo(); } This produces the output: 0 1 hi 2 hi 3 hi 4 hi 5 hi Why is there no "hi" between 0 and 1?
Blog Post #0060: Cairo Filled Arcs, Precision Arcs, and Curves
Today's post covers a lot of ground and answers a few of those burning questions you may have about taming Cairo arcs and curves. Still, it's a quick read because... well, tons of diagrams and screenshots. So, come on over and take a look: https://gtkdcoding.com/2019/08/09/0060-cairo-iv-fill-arc-cartoon-mouth.html
Re: Dub version
On Friday, 9 August 2019 at 09:01:54 UTC, Andre Pany wrote: On Friday, 9 August 2019 at 08:30:49 UTC, GreatSam4sure wrote: On Friday, 9 August 2019 at 03:52:11 UTC, Andre Pany wrote: On Friday, 9 August 2019 at 01:36:43 UTC, greatsam4sure wrote: On Friday, 9 August 2019 at 01:18:12 UTC, Elronnd wrote: [...] dub fetch dub Fetching dub 1.16.0... Please note that you need to use `dub run ` or add it to dependencies of your package to actually use/run it. dub does not do actual installation of packages outside of its own ecosystem. besides in https://code.dlang.org/packages/arsd-official they said use dub add arsd-official Instead if specifying a dub package manually in your project dub.json thr command dub add will edit the dub.json for you. Normally you get dub with the dmd/ldc/gdc package. Just download/install a recent package compiler package if you want to have command dub add. Kind regards Andre I am using dmd 2.087.1 and dub 1.11.0 But the command dub add... Did not work rdmd cannot run on my system. My assumption is, you have several dub executables on your computer. A recent one, bundled with dmd, and an old 1.11.0. Delete the old one, this should solve your problem. Please provide more information what you mean with "rdmd does not work". In general rdmd is superseded by the command "dmd -run". Kind regards Andre I am at lost here. Before I can run my D project using dub.1.11.0 executable install on my system but after uninstalling and install dmd 2.087.1 cannot run my project using dub from the project root folder. In windows 10 it shows this app can't run on your PC. To find a version for your PC, check with the software publisher. The same how's for the com and rdmd What is the way out.
Re: Dub version
On Friday, 9 August 2019 at 08:30:49 UTC, GreatSam4sure wrote: On Friday, 9 August 2019 at 03:52:11 UTC, Andre Pany wrote: On Friday, 9 August 2019 at 01:36:43 UTC, greatsam4sure wrote: On Friday, 9 August 2019 at 01:18:12 UTC, Elronnd wrote: [...] dub fetch dub Fetching dub 1.16.0... Please note that you need to use `dub run ` or add it to dependencies of your package to actually use/run it. dub does not do actual installation of packages outside of its own ecosystem. besides in https://code.dlang.org/packages/arsd-official they said use dub add arsd-official Instead if specifying a dub package manually in your project dub.json thr command dub add will edit the dub.json for you. Normally you get dub with the dmd/ldc/gdc package. Just download/install a recent package compiler package if you want to have command dub add. Kind regards Andre I am using dmd 2.087.1 and dub 1.11.0 But the command dub add... Did not work rdmd cannot run on my system. My assumption is, you have several dub executables on your computer. A recent one, bundled with dmd, and an old 1.11.0. Delete the old one, this should solve your problem. Please provide more information what you mean with "rdmd does not work". In general rdmd is superseded by the command "dmd -run". Kind regards Andre
Re: Dub version
On Friday, 9 August 2019 at 03:52:11 UTC, Andre Pany wrote: On Friday, 9 August 2019 at 01:36:43 UTC, greatsam4sure wrote: On Friday, 9 August 2019 at 01:18:12 UTC, Elronnd wrote: [...] dub fetch dub Fetching dub 1.16.0... Please note that you need to use `dub run ` or add it to dependencies of your package to actually use/run it. dub does not do actual installation of packages outside of its own ecosystem. besides in https://code.dlang.org/packages/arsd-official they said use dub add arsd-official Instead if specifying a dub package manually in your project dub.json thr command dub add will edit the dub.json for you. Normally you get dub with the dmd/ldc/gdc package. Just download/install a recent package compiler package if you want to have command dub add. Kind regards Andre I am using dmd 2.087.1 and dub 1.11.0 But the command dub add... Did not work rdmd cannot run on my system.