Re: dub build doesn't work
BTW if you prefer using optlink and the digitalmars C runtime, you can instruct dub to do so with: --arch=x86 how can i add --arch=x86 flag to the dub.json so it do it automatically ?
Re: dub build doesn't work
On Wednesday, 23 October 2019 at 22:06:28 UTC, SrMordred wrote: On Tuesday, 22 October 2019 at 22:14:02 UTC, OiseuKodeur wrote: Hello, i am having a problem with dub build with this project https://github.com/OiseauKodeur/cervelet/tree/master/source when i try to compile everything go well but when i click to run the .exe it give my an error missing msvcr100.dll, but with rdmd the program run fine I got into this recently too. I have the latest VS and redistributable packages installed and was unable to find msvcr100.dll too. Which is very odd. Lucky I found it on another software installed on my PC. which software ?
Re: undefined symbol: _D3std7variant...
On Wednesday, 23 October 2019 at 20:45:55 UTC, baz wrote: On Tuesday, 22 October 2019 at 13:07:54 UTC, Andrey wrote: On Tuesday, 22 October 2019 at 12:57:45 UTC, Daniel Kozak wrote: Have you try to clean all caches? Try to remove .dub folder I removed .dub folder but this error appears again. Try the "-allinst" option. It's possibly a bug with speculative template instantiation. "-allinst" deactivates speculation and everything is always instantiated and therefore present in the object files. If `-allinst` works, then please minimize the testcase and put it in our bugtracker. We know there are template culling problems but it only appears in very complex code. I have not been able to reduce it to less than a < 20k line problem across a ton of files... -Johan
Re: dub build doesn't work
On Tuesday, 22 October 2019 at 22:14:02 UTC, OiseuKodeur wrote: Hello, i am having a problem with dub build with this project https://github.com/OiseauKodeur/cervelet/tree/master/source when i try to compile everything go well but when i click to run the .exe it give my an error missing msvcr100.dll, but with rdmd the program run fine I got into this recently too. I have the latest VS and redistributable packages installed and was unable to find msvcr100.dll too. Which is very odd. Lucky I found it on another software installed on my PC.
Re: dub build doesn't work
On Wednesday, 23 October 2019 at 18:37:10 UTC, kinke wrote: On Wednesday, 23 October 2019 at 16:55:37 UTC, OiseuKodeur wrote: On Wednesday, 23 October 2019 at 06:40:47 UTC, Seb wrote: You won't need Visual Studio for this, but something which ships msvcr100.dll. So sth. like this should be enough: https://www.microsoft.com/en-us/download/details.aspx?id= even when i installed the latest vcredist_x86 it doesn't work You don't need the *latest* VC runtime (2019), but 2010, i.e., Seb's link. For DMD that is, LDC should be fine with the latest one. Yes that's the one i downloaded
Re: undefined symbol: _D3std7variant...
On Tuesday, 22 October 2019 at 13:07:54 UTC, Andrey wrote: On Tuesday, 22 October 2019 at 12:57:45 UTC, Daniel Kozak wrote: Have you try to clean all caches? Try to remove .dub folder I removed .dub folder but this error appears again. Try the "-allinst" option. It's possibly a bug with speculative template instantiation. "-allinst" deactivates speculation and everything is always instantiated and therefore present in the object files.
Re: dub build doesn't work
On Wednesday, 23 October 2019 at 16:55:37 UTC, OiseuKodeur wrote: On Wednesday, 23 October 2019 at 06:40:47 UTC, Seb wrote: You won't need Visual Studio for this, but something which ships msvcr100.dll. So sth. like this should be enough: https://www.microsoft.com/en-us/download/details.aspx?id= even when i installed the latest vcredist_x86 it doesn't work You don't need the *latest* VC runtime (2019), but 2010, i.e., Seb's link. For DMD that is, LDC should be fine with the latest one.
Re: ... use of ... is hidden by ...; use alias ... to introduce base class overload set ??
On 10/23/2019 02:43 AM, Robert M. Münch wrote: >> Unfortunately, member function template instances are never virtual >> functions, so you can't override them. > > What I don't understand is: > > 1. The RX lib has a member function template and than an instance of it > using type Oberver!E. > > 2. I'm creating a new type and want to use the same pattern but now with > my type. But it seems that D reduces my own type which leads to the > ambigty of which function now to use. Whereas I would expect that D uses > the most specific type first. That is exactly the case (for D, C++, etc.). However, the function must be virtual. Imagine an object is being accessed by it base interface, only the virtual function calls will be dispatched to the most specific type. Non-virtual functions will be called on the base type. For that reason, even though I've managed to remove your compilation error below, you will not like how it behaves. > The pastbin is the minimal code example. And yes, I'm sure there is a > (simple) way out... Replacing FilterSubject with the following removes the compilation error: static class FilterSubject : SubjectObject!message { SI spitialIndex; this(){ spitialIndex = new SI(); } auto subscribe(T)(T t) if (!is (T == myWidget)) { return typeof(super).subscribe(t); } Disposable subscribe(T)(T observer) if (is (T == myWidget)) { spitialIndex.insert(observer.x, observer.y, cast(long)cast(void*)observer); return NopDisposable.instance; } } However... auto rx_message = new FilterSubject; The type of rx_message is FilterSubject above. When one calls .subscribe() on it, only FilterSubject.subscribe templates will be involved. Perhaps that's exactly what you want. However... :) Accessing rx_message through a base class interface will call a different set of .subscribe() functions (the ones on the base even for myWidget!): SubjectObject!message rx_message = new FilterSubject; Now rx_message is the base type and only now you get "Hit!" printed. Again, maybe this is exactly what you want but beware that different sets of functions will be called depending on what interface of the object you are using. Ali
Re: dub build doesn't work
On Wednesday, 23 October 2019 at 06:40:47 UTC, Seb wrote: On Tuesday, 22 October 2019 at 22:14:02 UTC, OiseuKodeur wrote: Hello, i am having a problem with dub build with this project https://github.com/OiseauKodeur/cervelet/tree/master/source when i try to compile everything go well but when i click to run the .exe it give my an error missing msvcr100.dll, but with rdmd the program run fine Did you try compiling with LDC? Their Windows support is better maintained. Anyhow, so what's happening is that dmd by default uses the digitalmars C runtime (32-bit only) whereas dub will use the llvm linker (64-bit) by default. Now llvm's linker searches for the Microsoft C runtime and can't find it. Hence, the error which you're receiving. You won't need Visual Studio for this, but something which ships msvcr100.dll. So sth. like this should be enough: https://www.microsoft.com/en-us/download/details.aspx?id= BTW if you prefer using optlink and the digitalmars C runtime, you can instruct dub to do so with: --arch=x86 even when i installed the latest vcredist_x86 it doesn't work, but using --arch=x86 it works, but only when i don't include dlangui in the dub.json, it give me another error https://i.imgur.com/f1Rvlg1.png (app.d line 21 "code = stdin.readln();" and line 7 is "void main(string[] arguments)"), so i maybe need to find a new gui library, and thanks now at least i can compile.
[DTrace probe] is there a [portable] way to add section to elf executable?
I'd like to add (and modify) section to ELF executable to implement DTrace probes. DTrace does it in probe assembly: ``` __asm__ __volatile__ ( "990: nop .pushsection .note.stapsdt,\"?\",\"note\" .balign 4 .4byte 992f-991f, 994f-993f, 3 991: .asciz \"stapsdt\" 992: .balign 4 993: .8byte 990b .8byte _.stapsdt.base .8byte 0 .asciz \"myapp\" .asciz \"func_call\" .asciz \"%n[_SDT_S1]@%[_SDT_A1] %n[_SDT_S2]@%[_SDT_A2]\" 994: .balign 4 .popsection" :: [_SDT_S1] "n" (SNIPPED_ONE), [_SDT_A1] "nor" ((a)), [_SDT_S2] "n" (SNIPPED_TWO), [_SDT_A2] "nor" ((b)) ); ``` So I need a way to add no op operation and define some data in `.note.stapsdt` section. This page https://dlang.org/spec/iasm.html does not contain any information about sections
Re: Eliding of slice range checking
On Wednesday, 23 October 2019 at 13:08:34 UTC, Per Nordlöw wrote: Is it possible to remove cluttering? godbolt.org supports D as well and is way more powerful than run.dlang.io, besides offering way more LDC versions to choose from. It can also be used to remove the 'cluttering': https://d.godbolt.org/z/ejEmrK
Re: Eliding of slice range checking
On Wednesday, 23 October 2019 at 13:08:34 UTC, Per Nordlöw wrote: The ASM- and IR-output from the following code is pretty messy for You call this messy?! cmpq%rdi, %rdx jae .LBB0_2 xorl%eax, %eax retq .LBB0_2: movq%rdi, %rax testq %rdi, %rdi je .LBB0_3 pushq %rax .cfi_def_cfa_offset 16 movq%rcx, %rdi movq%rax, %rdx callq memcmp@PLT testl %eax, %eax sete%al addq$8, %rsp .cfi_def_cfa_offset 8 retq .LBB0_3: movb$1, %al retq Anyway, clearly no bounds checks, LLVM's optimizer works as it should.
Re: Eliding of slice range checking
On Wednesday, 23 October 2019 at 11:33:56 UTC, kinke wrote: Simply check the IR or asm, e.g., on run.dlang.io. If there's a call to `_d_arraybounds` in the function of interest, bounds checks are enabled. The ASM- and IR-output from the following code is pretty messy for ldc with flags `-release -O` Is it possible to remove cluttering? https://run.dlang.io/is/mAXOm6
Re: Eliding of slice range checking
On Wednesday, 23 October 2019 at 11:33:56 UTC, kinke wrote: For your example, the template is inferred to be @safe, and `-release` only elides bounds checks in @system functions (corresponding to `-boundscheck=safeonly`). Use `-boundscheck=off` to elide it in all functions. Thanks. But I'm talking about the compiler being able to figure out that the expression haystack[0 .. needle.length] _never_ (regardless of compiler flags) needs any range checking because it is _only_ run when haystack.length >= needle.length . Do you follow?
Re: Error: need this for method of type
On Wednesday, 23 October 2019 at 11:48:29 UTC, Dennis wrote: You can change `method(1)` into `x.method(1)` and it should work. Wait, but that's only because the local alias and member function have the same name 'method'. I think you just have to keep the method name as a string instead of an alias and use ` __traits(getMember, x, member)(3);` the moment you want to call it.
Re: Error: need this for method of type
On Wednesday, 23 October 2019 at 11:40:09 UTC, Márcio Martins wrote: This is a bug, right? If not, why, and how can I get around it and call `method`? An alias refers just to a symbol, in this case a member function of struct X. The fact that you polled it on instance 'x' is not something an alias keeps track of. You can change `method(1)` into `x.method(1)` and it should work.
Error: need this for method of type
Hi! Consider this simplified program: ``` import std.stdio; struct X { void method(int x) { writeln("method called"); } } void main() { X x; foreach (member; __traits(allMembers, X)) { alias method = __traits(getMember, x, member); method(1); } } ``` Output: test.d(15): Error: need this for method of type void(int x) This one as well: ``` import std.stdio; struct X { void method(int x) { writeln("method(int) called"); } } struct Y { void method(ref X x) { foreach (member; __traits(allMembers, X)) { alias method = __traits(getMember, x, member); method(1); } } } void main() { Y y; X x; y.method(x); } ``` Output: ```test.d(14): Error: this for method needs to be type X not type Y``` This is a bug, right? If not, why, and how can I get around it and call `method`?
Re: Eliding of slice range checking
On Wednesday, 23 October 2019 at 11:20:59 UTC, Per Nordlöw wrote: How can I investigate the codegen myself here? Simply check the IR or asm, e.g., on run.dlang.io. If there's a call to `_d_arraybounds` in the function of interest, bounds checks are enabled. For your example, the template is inferred to be @safe, and `-release` only elides bounds checks in @system functions (corresponding to `-boundscheck=safeonly`). Use `-boundscheck=off` to elide it in all functions.
Eliding of slice range checking
Does DMD/LDC avoid range-checking in slice-expressions such as the one in my array-overload of `startsWith` defined as bool startsWith(T)(scope const(T)[] haystack, scope const(T)[] needle) { if (haystack.length >= needle.length) { return haystack[0 .. needle.length] == needle; // is slice range checking avoid here? } return false; } /// @safe pure nothrow @nogc unittest { auto x = "beta version"; assert(x.startsWith("beta")); } when building in release mode? I remember a DMD pull from Ian Buclaw that enabled some eliding but I don't remember if it includes the case above. How can I investigate the codegen myself here?
Re: What do you think about About C++20 Concepts?
On Tuesday, 22 October 2019 at 14:30:32 UTC, lili wrote: Hi: In C++20 Concepts is great idear. but I thinks it is too difficult to write. I like Rust traits simple and elegancy. Andrei Alexandrescou's keynote from CppCon 2018 [1] explains why D's existing template restrictions together with `static if` are superior to C++20 concepts. [1] https://www.youtube.com/watch?v=tcyb1lpEHm0
Re: ... use of ... is hidden by ...; use alias ... to introduce base class overload set ??
On 2019-10-22 20:59:41 +, Ali ehreli said: That says "private paste" for me. Ups, sorry and thanks for letting me know. But I think you have a member function template in the base class. This the lib I use: https://github.com/lempiji/rx/blob/dev/source/rx/subject.d and which gives the error. On lines 72ff it has: Disposable subscribe(T)(T observer) { return subscribe(observerObject!E(observer)); } Disposable subscribe(Observer!E observer) { Which looks exactly like what you mention, if I understand it correctly. Unfortunately, member function template instances are never virtual functions, so you can't override them. What I don't understand is: 1. The RX lib has a member function template and than an instance of it using type Oberver!E. 2. I'm creating a new type and want to use the same pattern but now with my type. But it seems that D reduces my own type which leads to the ambigty of which function now to use. Whereas I would expect that D uses the most specific type first. I'm pretty sure there is a way out. Can you try showing minimal code again please. The pastbin is the minimal code example. And yes, I'm sure there is a (simple) way out... for some advanced guys like you. Still learning a lot here... -- Robert M. Münch http://www.saphirion.com smarter | better | faster