Re: Some questions about strings

2020-06-21 Thread Denis via Digitalmars-d-learn
On Monday, 22 June 2020 at 04:32:32 UTC, Mike Parker wrote: On Monday, 22 June 2020 at 04:08:10 UTC, Denis wrote: On Monday, 22 June 2020 at 03:31:17 UTC, Ali Çehreli wrote: : string is char[] wstring is wchar[] dstring is dchar[] Got it now. This is the critical piece I missed: I understand

Re: Some questions about strings

2020-06-21 Thread Mike Parker via Digitalmars-d-learn
On Monday, 22 June 2020 at 04:08:10 UTC, Denis wrote: On Monday, 22 June 2020 at 03:31:17 UTC, Ali Çehreli wrote: : string is char[] wstring is wchar[] dstring is dchar[] Got it now. This is the critical piece I missed: I understand the relations between the char types and the UTF encodings

Re: Some questions about strings

2020-06-21 Thread Denis via Digitalmars-d-learn
On Monday, 22 June 2020 at 03:31:17 UTC, Ali Çehreli wrote: : string is char[] wstring is wchar[] dstring is dchar[] Got it now. This is the critical piece I missed: I understand the relations between the char types and the UTF encodings (thanks to your book). But I mistakenly thought that

Re: Some questions about strings

2020-06-21 Thread Denis via Digitalmars-d-learn
On Monday, 22 June 2020 at 03:49:01 UTC, Adam D. Ruppe wrote: On Monday, 22 June 2020 at 03:43:58 UTC, Denis wrote: My code reads a UTF-8 encoded file into a buffer and validates, byte by byte, the UTF-8 encoding along with some additional validation. If I simply return the UTF-8 encoded

Re: Some questions about strings

2020-06-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 22 June 2020 at 03:43:58 UTC, Denis wrote: My code reads a UTF-8 encoded file into a buffer and validates, byte by byte, the UTF-8 encoding along with some additional validation. If I simply return the UTF-8 encoded string, there won't be another decoding/encoding done -- correct?

Re: Some questions about strings

2020-06-21 Thread Denis via Digitalmars-d-learn
On Monday, 22 June 2020 at 03:24:37 UTC, Adam D. Ruppe wrote: On Monday, 22 June 2020 at 03:17:54 UTC, Denis wrote: - First, is there any difference between string, wstring and dstring? Yes, they encode the same content differently in the bytes. If you cast it to ubyte[] and print that out

Re: Some questions about strings

2020-06-21 Thread Ali Çehreli via Digitalmars-d-learn
On 6/21/20 8:17 PM, Denis wrote:> I have a few questions about how strings are stored. > > - First, is there any difference between string, wstring and dstring? string is char[] wstring is wchar[] dstring is dchar[] char is 1 byte: UTF-8 code unit wchar is 2 bytes: UTF-16 code unit dchar is 4

Re: Some questions about strings

2020-06-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 22 June 2020 at 03:17:54 UTC, Denis wrote: - First, is there any difference between string, wstring and dstring? Yes, they encode the same content differently in the bytes. If you cast it to ubyte[] and print that out you can see the difference. - Are the characters of a string

Some questions about strings

2020-06-21 Thread Denis via Digitalmars-d-learn
I have a few questions about how strings are stored. - First, is there any difference between string, wstring and dstring? For example, a 3-byte Unicode character literal can be assigned to a variable of any of these types, then printed, etc, without errors. - Are the characters of a string

Re: Rules for Symbol Name Lookup seem contradictory

2020-06-21 Thread user1234 via Digitalmars-d-learn
On Monday, 22 June 2020 at 01:38:41 UTC, Manfred Nowak wrote: https://dlang.org/spec/module.html#name_lookup contains under 4.3.4 only two sentences. While the first sentence explains, that the search ends "as soon as a matching symbol is found", the second sentence implies that the search

Re: Passing a variable number of slices into a function

2020-06-21 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 22 June 2020 at 02:04:06 UTC, user1234 wrote: Maybe each slice has different type ? in some cases T[][]... will work better too. depends on the details here

Re: Passing a variable number of slices into a function

2020-06-21 Thread user1234 via Digitalmars-d-learn
On Monday, 22 June 2020 at 01:47:49 UTC, repr-man wrote: Is there any way to pass an unknown number of slices into a function? I'm trying to do something along the lines of: void func(T)(T[] args...) { //... } That wasn't working, [...] Thanks for the help! Can you provide more

Passing a variable number of slices into a function

2020-06-21 Thread repr-man via Digitalmars-d-learn
Is there any way to pass an unknown number of slices into a function? I'm trying to do something along the lines of: void func(T)(T[] args...) { //... } That wasn't working, so I tried using another generic type where T was already defined: void func(U)(U args...) if(is(U == T[]) {

Rules for Symbol Name Lookup seem contradictory

2020-06-21 Thread Manfred Nowak via Digitalmars-d-learn
https://dlang.org/spec/module.html#name_lookup contains under 4.3.4 only two sentences. While the first sentence explains, that the search ends "as soon as a matching symbol is found", the second sentence implies that the search may continue until it is sure, that no other symbol "with

Re: called copy constructor in foreach with ref on Range

2020-06-21 Thread kinke via Digitalmars-d-learn
A foreach over a custom range makes an initial copy, so that the original range is still usable after the foreach (not empty).

called copy constructor in foreach with ref on Range

2020-06-21 Thread Rogni via Digitalmars-d-learn
https://pastebin.com/BYcRN8T2 why called copy constructor for ref Range struct type in foreach ? ``` struct MyRange { private int current_row = 0; private int rows_count = 5; @disable this(this); // <=== bool empty () { return current_row == rows_count; } int front() {

Re: Why infinite loops are faster than finite loops?

2020-06-21 Thread Johan via Digitalmars-d-learn
On Saturday, 20 June 2020 at 21:11:57 UTC, tastyminerals wrote: I am not sure that this is a question about D or a more general one. I have watched this nice presentation "Speed Is Found In The Minds of People" by Andrei: https://www.youtube.com/watch?v=FJJTYQYB1JQ=youtu.be?t=2596 and on 43:20

Re: GtkD code review - How to update a progressbar using data sharing concurrency

2020-06-21 Thread adnan338 via Digitalmars-d-learn
On Sunday, 21 June 2020 at 12:43:32 UTC, adnan338 wrote: On Sunday, 21 June 2020 at 09:16:06 UTC, Ali Çehreli wrote: On 6/20/20 9:30 AM, adnan338 wrote: > Hello, I need a code review on my strategy I don't know gtkd so I did not compile the code and I did not review the code very carefully.

Re: GtkD code review - How to update a progressbar using data sharing concurrency

2020-06-21 Thread adnan338 via Digitalmars-d-learn
On Sunday, 21 June 2020 at 09:16:06 UTC, Ali Çehreli wrote: On 6/20/20 9:30 AM, adnan338 wrote: > Hello, I need a code review on my strategy I don't know gtkd so I did not compile the code and I did not review the code very carefully. However, I don't think you need to 'synchronized' the

Re: GtkD code review - How to update a progressbar using data sharing concurrency

2020-06-21 Thread Kagamin via Digitalmars-d-learn
Not sure how much synchronization do you want to do. import gio.Application : GioApplication = Application; import gtk.Application : Application; import gtk.ApplicationWindow : ApplicationWindow; import gtk.ProgressBar : ProgressBar; import glib.Timeout : Timeout; import gtkc.gtktypes :

Re: Does std.net.curl: download have support for callbacks?

2020-06-21 Thread IGotD- via Digitalmars-d-learn
On Thursday, 18 June 2020 at 01:15:00 UTC, dangbinghoo wrote: Don't worry, almost ALL GUI FRAMEWORK in the world IS NOT THREAD SAFE, the wellknow Qt and Gtk, and even morden Android and the java Swing. binghoo dang You can certainly download in another thread in Qt. However, you

Re: GtkD code review - How to update a progressbar using data sharing concurrency

2020-06-21 Thread Ali Çehreli via Digitalmars-d-learn
On 6/20/20 9:30 AM, adnan338 wrote: > Hello, I need a code review on my strategy I don't know gtkd so I did not compile the code and I did not review the code very carefully. However, I don't think you need to 'synchronized' the whole parallel loop. Since there is only one thread that

Re: Why infinite loops are faster than finite loops?

2020-06-21 Thread Виталий Фадеев via Digitalmars-d-learn
On Saturday, 20 June 2020 at 21:11:57 UTC, tastyminerals wrote: I am not sure that this is a question about D or a more general one. I have watched this nice presentation "Speed Is Found In The Minds of People" by Andrei: https://www.youtube.com/watch?v=FJJTYQYB1JQ=youtu.be?t=2596 and on 43:20