Re: dlib 0.19.1 seems to be failing linking with ldc2

2020-08-02 Thread jeff thompson via Digitalmars-d-learn
On Friday, 31 July 2020 at 22:26:26 UTC, jeff thompson wrote: On Friday, 31 July 2020 at 20:07:26 UTC, Dennis wrote: On Friday, 31 July 2020 at 14:17:14 UTC, jeff thompson wrote: dlib.lib(dlib.audio.io.wav.obj) : error LNK2019: unresolved external symbol _D4core8internal7switch___T14__switch_e

Re: Question about UDAs

2020-08-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 3 August 2020 at 03:00:08 UTC, Cecil Ward wrote: When practically speaking would you use UDAs? A real-world use-case? They are useful when you want to attach some kind of metadata to the declarations for a library to read. For example, my script.d looks for `@scriptable` for method

Question about UDAs

2020-08-02 Thread Cecil Ward via Digitalmars-d-learn
When practically speaking would you use UDAs? A real-world use-case? I’ve seen them in use already for core language features instead of keywords like "pure", and I suppose this choice keeps the number of keywords down and the result is perhaps easier to extend. The motivation for these usages

Re: Lack of asm volatile qualifier (explicitly) again.

2020-08-02 Thread Cecil Ward via Digitalmars-d-learn
On Saturday, 1 August 2020 at 19:23:00 UTC, Iain Buclaw wrote: On Saturday, 1 August 2020 at 02:36:41 UTC, Cecil Ward wrote: On Thursday, 30 July 2020 at 07:05:39 UTC, Iain Buclaw wrote: [...] Ah. I wasn’t thinking about pure, although I do use it everywhere I can as a matter of course. The

Re: 2-D array initialization

2020-08-02 Thread jmh530 via Digitalmars-d-learn
On Sunday, 2 August 2020 at 19:19:51 UTC, Andy Balba wrote: I'm not a gitHub fan, but I like the mir functions; and it looks like I have to download mir before using it. mir has quite a few .d files..Is there a quick way to download it ? dub [1] is now packaged with dmd, which is the easies

Rounding Functions in Phobos

2020-08-02 Thread starcanopy via Digitalmars-d-learn
Is there a reason why ceil, floor, round, and friends return floats instead of an integer? There are l' variants for some of these, but I'd imagine template implementations of these operations would be better. Too much bloat? Naively, you'd have for ceil... // Return type would be numeric but

Re: 2-D array initialization

2020-08-02 Thread Andy Balba via Digitalmars-d-learn
On Sunday, 2 August 2020 at 06:37:06 UTC, tastyminerals wrote: You haven't said anything about efficiency because if you care and your arrays are rather big, you better go with https://github.com/libmir/mir-algorithm as mentioned above. It might be a little finicky at the start but this post:

Re: 2-D array initialization

2020-08-02 Thread Ali Çehreli via Digitalmars-d-learn
On 8/1/20 7:00 PM, Andy Balba wrote: >> >> ubyte[3][4] c = [ [5, 5, 5], [15, 15,15], [25, 25,25], [35, >> 35,35] ]; > Although not detailed in my original question, in my actual app > I have array ubyte [1000][3] Big which consists of research data I > obtained, > and from which I want to ran

safety and auto vectorization

2020-08-02 Thread Bruce Carneal via Digitalmars-d-learn
import std; void f0(int[] a, int[] b, int[] dst) @safe { dst[] = a[] + b[]; } void f1(int[] a, int[] b, int[] dst) @trusted { const minLen = min(a.length, b.length, dst.length); dst[0..minLen] = a[0..minLen] + b[0..minLen]; assert(dst.length == minLen); } I was surprised that f0

Re: Equivalent of C++ #__VA_ARGS__

2020-08-02 Thread Ronoroa via Digitalmars-d-learn
On Sunday, 2 August 2020 at 16:31:50 UTC, Adam D. Ruppe wrote: On Sunday, 2 August 2020 at 16:05:07 UTC, Ronoroa wrote: That doesn't seem to stringize the args part like in #__VA_ARGS__ oh yeah i missed that part. D basically can't do that exactly, but if you pass the args as template things

Re: Equivalent of C++ #__VA_ARGS__

2020-08-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 2 August 2020 at 16:05:07 UTC, Ronoroa wrote: That doesn't seem to stringize the args part like in #__VA_ARGS__ oh yeah i missed that part. D basically can't do that exactly, but if you pass the args as template things directly you can do this: --- void main(string[] args) {

Re: Equivalent of C++ #__VA_ARGS__

2020-08-02 Thread Ronoroa via Digitalmars-d-learn
On Sunday, 2 August 2020 at 15:48:34 UTC, Adam D. Ruppe wrote: On Sunday, 2 August 2020 at 15:30:27 UTC, Ronoroa wrote: void dbg(Args...)(Args args, size_t line = __LINE__) { writeln(line, args, " = ", print_func(args)); } That doesn't seem to stringize the args part like in #__VA_ARGS__ I

Re: Equivalent of C++ #__VA_ARGS__

2020-08-02 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 2 August 2020 at 15:30:27 UTC, Ronoroa wrote: How do I achieve equivalent semantics of following C++ code? ``` #define dbg(...) std::cout << __LINE__ << #__VA_ARGS__ << " = " << print_func(__VA_ARGS__) << std::endl; ``` You probably just want void dbg(Args...)(Args args, size_t

Equivalent of C++ #__VA_ARGS__

2020-08-02 Thread Ronoroa via Digitalmars-d-learn
How do I achieve equivalent semantics of following C++ code? ``` #define dbg(...) std::cout << __LINE__ << #__VA_ARGS__ << " = " << print_func(__VA_ARGS__) << std::endl; ```

Re: Lexicographic comparison of arrays (of chars)

2020-08-02 Thread Per Nordlöw via Digitalmars-d-learn
On Wednesday, 22 January 2020 at 15:11:09 UTC, Jacob Carlborg wrote: BTW, why don't you implement `opCmp` with the built-in comparison operators. Those are going to get lower to a call to `__cmp`. Something like this: int opCmp()(const scope typeof(this) that) const @nogc { auto a = this[]

Re: dynamic array .length vs .reserve - what's the difference?

2020-08-02 Thread Christian Köstlin via Digitalmars-d-learn
On 31.07.20 06:28, Ali Çehreli wrote: On 7/30/20 4:42 PM, wjoe wrote: > So .capacity can't be assigned a value like length to reserve the RAM ? Yes, a read-only property... >> auto a = b; >> b = b[0 .. $-1]; >> b ~= someT; >> >> If that last line is done in-place, then it overwrites a[$-