Re: Replacing tango.text.Ascii.isearch

2022-10-24 Thread rikki cattermole via Digitalmars-d-learn
On 25/10/2022 5:17 PM, Siarhei Siamashka wrote: Wow, I didn't expect anything like this and just thought that the nightmares of handling 8-bit codepages for non-English languages ceased to exist nowadays. Too bad. What are the best practices to deal with Turkish text in D language? std.uni do

Re: Replacing tango.text.Ascii.isearch

2022-10-24 Thread Siarhei Siamashka via Digitalmars-d-learn
On Thursday, 13 October 2022 at 08:27:17 UTC, bauss wrote: ```d bool isearch(S1, S2)(S1 haystack, S2 needle) { import std.uni; import std.algorithm; return haystack.asLowerCase.canFind(needle.asLowerCase); } ``` untested. -Steve This doesn't actually work properly in all languages

Re: Supporting foreach (k, v; T.init) for a user-defined (container) type

2022-10-24 Thread Ali Çehreli via Digitalmars-d-learn
On 10/24/22 14:26, Per Nordlöw wrote: What property of a container (type) `T` enables iteration as ```d foreach (k, v; T.init) {     ... } ``` ? I thought it sufficed to define `T.byKeyValue` but its presence seem to have no effect. Another option is to use range functions where front() ret

Re: Supporting foreach (k, v; T.init) for a user-defined (container) type

2022-10-24 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Oct 24, 2022 at 09:26:14PM +, Per Nordlöw via Digitalmars-d-learn wrote: > What property of a container (type) `T` enables iteration as > > ```d > foreach (k, v; T.init) > { > ... > } > ``` > > ? I thought it sufficed to define `T.byKeyValue` but its presence seem > to have no ef

Supporting foreach (k, v; T.init) for a user-defined (container) type

2022-10-24 Thread Per Nordlöw via Digitalmars-d-learn
What property of a container (type) `T` enables iteration as ```d foreach (k, v; T.init) { ... } ``` ? I thought it sufficed to define `T.byKeyValue` but its presence seem to have no effect.

Re: Supporting foreach (k, v; T.init) for a user-defined (container) type

2022-10-24 Thread rikki cattermole via Digitalmars-d-learn
From there down: https://dlang.org/spec/statement.html#foreach_over_struct_and_classes

Re: Disabling All Inlining in DMD Debug Builds

2022-10-24 Thread ryuukk_ via Digitalmars-d-learn
On Monday, 24 October 2022 at 19:28:34 UTC, Jack Stouffer wrote: I use ``` pragma(inline, true) function definition ``` all over my code. And by default, DMD inlines these functions even in debug builds, which normally is great. I have a custom dynamic array container and if the indexing oper

Re: Disabling All Inlining in DMD Debug Builds

2022-10-24 Thread Imperatorn via Digitalmars-d-learn
On Monday, 24 October 2022 at 19:28:34 UTC, Jack Stouffer wrote: I use ``` pragma(inline, true) function definition ``` all over my code. And by default, DMD inlines these functions even in debug builds, which normally is great. I have a custom dynamic array container and if the indexing oper

Disabling All Inlining in DMD Debug Builds

2022-10-24 Thread Jack Stouffer via Digitalmars-d-learn
I use ``` pragma(inline, true) function definition ``` all over my code. And by default, DMD inlines these functions even in debug builds, which normally is great. I have a custom dynamic array container and if the indexing operator overload function wasn't inlined the debug build would have

Re: Hipreme's #2 Tip of the day - Reducing .di files dependency

2022-10-24 Thread Imperatorn via Digitalmars-d-learn
On Monday, 24 October 2022 at 12:10:19 UTC, Nick Treleaven wrote: On Sunday, 23 October 2022 at 20:12:46 UTC, Hipreme wrote: For reducing a D Interface file dependency when generating it with the `-H` flag for DMD, you can't import a module on the top level. Take a look at that example: This

Re: Hipreme's #2 Tip of the day - Reducing .di files dependency

2022-10-24 Thread Nick Treleaven via Digitalmars-d-learn
On Sunday, 23 October 2022 at 20:12:46 UTC, Hipreme wrote: For reducing a D Interface file dependency when generating it with the `-H` flag for DMD, you can't import a module on the top level. Take a look at that example: This would make a nice blog post if you have one ;-)

Re: Remove elements without losing capacity

2022-10-24 Thread Nick Treleaven via Digitalmars-d-learn
On Tuesday, 4 October 2022 at 18:18:41 UTC, Ali Çehreli wrote: A related topic is how the "end slice" never loses that capacity: void main() { auto a = [ 1, 2 ]; auto b = a; assert(a.capacity != 0); assert(b.capacity != 0); b.length--; assert(b.capacity == 0); asse