Re: Need for speed

2021-04-02 Thread Nestor via Digitalmars-d-learn
On Thursday, 1 April 2021 at 19:38:39 UTC, H. S. Teoh wrote: On Thu, Apr 01, 2021 at 04:52:17PM +, Nestor via Digitalmars-d-learn wrote: [...] [...] Since the length of the array is already known beforehand, you could get significant speedups by preallocating the array: [...]

Re: Need for speed

2021-04-02 Thread Ali Çehreli via Digitalmars-d-learn
On 4/1/21 9:01 PM, H. S. Teoh wrote: > 6) (Not described in the thread, but applied later) Reduce GC load even > further by reusing an array that was being allocated per iteration in > an inner loop before. For those who prefer a video description with some accent :) here is how to

Re: Casting lvalues

2021-04-02 Thread z via Digitalmars-d-learn
On Friday, 2 April 2021 at 12:47:35 UTC, z wrote: ```d T processArray(T)(ref T[] p){/*...*/} //function calls .reserve ``` i meant `void` for the function return type.

[OT]

2021-04-02 Thread drug via Digitalmars-d-learn
02.04.2021 15:06, Ali Çehreli пишет: For those who prefer a video description with some accent :) here is how What about accent - I'm curious what would you say about this old Russian sketch about English and its dialects (in English, no facebook account required):

Casting lvalues

2021-04-02 Thread z via Digitalmars-d-learn
```d shared TT[] a; T processArray(T)(ref T[] p){/*...*/} //function calls .reserve on its parameter a.processArray; ``` Template *name* cannot deduce function from argument types !()(shared(T[]))... Even if the function is changed to only accept shared parameters, .reserve does not appear

Re: Casting lvalues

2021-04-02 Thread tsbockman via Digitalmars-d-learn
On Friday, 2 April 2021 at 12:47:35 UTC, z wrote: Even if the function is changed to only accept `shared` parameters, `.reserve` does not appear to support `shared` so the function is impossible to use without somehow changing its type or using `__gshared`. There is no way that `.reserve`

Check attribute against value

2021-04-02 Thread frame via Digitalmars-d-learn
I have an attribute scope: ``` @PublicApi { // ... } ``` Querying with hasUDA! works as expected. Later, I added a property to PublicApi: ``` struct PublicApi { bool exposeDetails; } ``` And want to ask the compiler via getUDAs! about the boolean but this fails with: ```Error: type

Re: Check attribute against value

2021-04-02 Thread frame via Digitalmars-d-learn
On Saturday, 3 April 2021 at 04:03:14 UTC, rikki cattermole wrote: This doesn't explain it well, but you were adding types as attributes on to those symbols. Not struct instances. omg - that's dumb - I was thinking the compiler whould be aware of that. So, I need to check for isType!

Re: Best way to make a template function conditionally @trusted

2021-04-02 Thread ikod via Digitalmars-d-learn
On Thursday, 1 April 2021 at 22:35:01 UTC, tsbockman wrote: Suppose I have a templated struct member function for which I can compute at compile-time when the function is memory safe, and when it is not. But, the compiler cannot correctly determine this automatically. Compiler should be able

Re: Vibe.d tutorial

2021-04-02 Thread Imperatorn via Digitalmars-d-learn
On Thursday, 4 March 2021 at 13:47:11 UTC, Imperatorn wrote: On Monday, 1 March 2021 at 22:25:39 UTC, Rey Valeza wrote: Hi, I wrote a tutorial on Vibe.d while trying to re-learn Vibe.d. I find that most of Kai Nacke's book need updating, so I wrote a tutorial while trying to re-learn it.

Re: Check attribute against value

2021-04-02 Thread rikki cattermole via Digitalmars-d-learn
"Whether the attributes are values or types is up to the user, and whether later attributes accumulate or override earlier ones is also up to how the user interprets them." This doesn't explain it well, but you were adding types as attributes on to those symbols. Not struct instances.

Re: what exactly is string length?

2021-04-02 Thread Paul Backus via Digitalmars-d-learn
On Friday, 2 April 2021 at 05:39:26 UTC, mw wrote: Finally, I'm using: https://run.dlang.io/is/651lT6 string t = text("head-", s[].until('\0').array, "-tail"); FYI, you don't need the call to `.array` there--`text` accepts input ranges.

Re: what exactly is string length?

2021-04-02 Thread mw via Digitalmars-d-learn
On Friday, 2 April 2021 at 05:02:52 UTC, mw wrote: On Friday, 2 April 2021 at 04:54:07 UTC, Computermatronic wrote: On Friday, 2 April 2021 at 04:49:22 UTC, mw wrote: So you mean inside the writeln() call, the 0s are skipped? Well, if I use `string t` as filename, it will try to looking for

Re: what exactly is string length?

2021-04-02 Thread Berni44 via Digitalmars-d-learn
On Friday, 2 April 2021 at 15:01:07 UTC, mw wrote: BTW, shall I log a writeln() improvement bug ? It's really confusing, e.g as debug print or logs. In my opinion this isn't a bug. The nulls are actually printed: ``` $> rdmd test.d | hd 61 62 63 00 00 00 36 0a 68 65 61 64 2d 61 62