Re: dChar Error

2022-12-30 Thread matheus via Digitalmars-d-learn
On Friday, 30 December 2022 at 10:03:20 UTC, Salih Dincer wrote: On Friday, 30 December 2022 at 09:29:16 UTC, novice2 wrote: On Friday, 30 December 2022 at 04:43:48 UTC, Salih Dincer wrote:  ...  // example one:  char[] str1 = "cur:€_".dup;  ...  // example two: dchar[] str2 =

Re: dChar Error

2022-12-30 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 30 December 2022 at 11:05:07 UTC, matheus wrote: Are you sure about that? Thank you for your answer. You contributed to the project I was working on. In this case, std.conv.to can be used for mutable dchars, right? For example, is this solution the right approach? ```d auto

Re: dChar Error

2022-12-30 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 30 December 2022 at 22:02:41 UTC, Ali Çehreli wrote: > But I couldn't find if the target will be mutable, but I think it will > be, The target will always be the type the programmer specifies explicitly. (dchar[] in this case.) I have one more little question! Is it possible to

Re: Handling CheckBox state changes in DLangUI

2022-12-30 Thread brianush1 via Digitalmars-d-learn
On Saturday, 31 December 2022 at 02:40:49 UTC, Daren Scot Wilson wrote: The compiler errors I get are, for no '&' and with '&': Error: function `app.checkbox_b_clicked(Widget source, bool checked)` is not callable using argument types `()` Error: none of the overloads of `opAssign` are

Re: dChar Error

2022-12-30 Thread matheus via Digitalmars-d-learn
On Friday, 30 December 2022 at 15:28:05 UTC, Salih Dincer wrote: ... In this case, std.conv.to can be used for mutable dchars, right? For example, is this solution the right approach? ```d auto toDchar(S)(inout S str) { import std.conv : to; return str.to!(dchar[]); } void main() { auto

Re: dChar Error

2022-12-30 Thread Ali Çehreli via Digitalmars-d-learn
On 12/30/22 13:54, matheus wrote: > But yes I think it will generate a copy (mutable) based on this test: In this case it does copy but in the case of dchar[] to dchar[], there will be no copy. Similarly, there is no copy from immutable to immutable. > the address is different Good test. :)

Re: dChar Error

2022-12-30 Thread Ali Çehreli via Digitalmars-d-learn
On 12/30/22 17:22, Salih Dincer wrote: > I guess there is no other way but to overload. Since the bodies of all three overloads are the same except some types, they can easily be templatized. > This is both the safest and the fastest. I didn't think Values is fast with string copies that it

Re: dChar Error

2022-12-30 Thread matheus via Digitalmars-d-learn
On Friday, 30 December 2022 at 22:02:41 UTC, Ali Çehreli wrote: On 12/30/22 13:54, matheus wrote: > But yes I think it will generate a copy (mutable) based on this test: In this case it does copy but in the case of dchar[] to dchar[], there will be no copy. Similarly, there is no copy from

Re: dChar Error

2022-12-30 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 31 December 2022 at 00:42:50 UTC, Salih Dincer wrote: ... it possible to infer Let me save you the torment of code duplication  Thanks everyone. Yes, I guess there is no other way but to overload. This is both the safest and the fastest. It's also short enough like this:

Handling CheckBox state changes in DLangUI

2022-12-30 Thread Daren Scot Wilson via Digitalmars-d-learn
I'm writing a GUI program using dlangui. It has some checkboxes. I'm trying to figure out how to invoke a callback function when the user clicks the box. What are the valid ways of doing that? I can copy from dlangide's source, where a delegate is defined in-line and assigned. That seems to

Re: Handling CheckBox state changes in DLangUI

2022-12-30 Thread Daren Scot Wilson via Digitalmars-d-learn
On Saturday, 31 December 2022 at 03:05:45 UTC, brianush1 wrote: On Saturday, 31 December 2022 at 02:40:49 UTC, Daren Scot Wilson wrote: The compiler errors I get are, for no '&' and with '&': Error: function `app.checkbox_b_clicked(Widget source, bool checked)` is not callable using argument

Re: dChar Error

2022-12-30 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 31 December 2022 at 02:15:56 UTC, Ali Çehreli wrote: On 12/30/22 17:22, Salih Dincer wrote: > I guess there is no other way but to overload. Since the bodies of all three overloads are the same except some types, they can easily be templatized. You took the trouble, thanks, but

Re: Float rounding (in JSON)

2022-12-30 Thread Sergey via Digitalmars-d-learn
On Thursday, 13 October 2022 at 19:00:30 UTC, Sergey wrote: I'm not a professional of IEEE 754, but just found this behavior at rounding in comparison with other languages. I supose it happened because in D float numbers parsed as double and have a full length of double while rounding. But

Re: dChar Error

2022-12-30 Thread Salih Dincer via Digitalmars-d-learn
On Friday, 30 December 2022 at 09:29:16 UTC, novice2 wrote: On Friday, 30 December 2022 at 04:43:48 UTC, Salih Dincer wrote:  ...  // example one:  char[] str1 = "cur:€_".dup;  ...  // example two: dchar[] str2 = cast(dchar[])"cur:€_"d;  ... SDB@79 why you use .dup it example one, but

Re: dChar Error

2022-12-30 Thread novice2 via Digitalmars-d-learn
On Friday, 30 December 2022 at 04:43:48 UTC, Salih Dincer wrote:  ...  // example one:  char[] str1 = "cur:€_".dup;  ...  // example two: dchar[] str2 = cast(dchar[])"cur:€_"d;  ... SDB@79 why you use .dup it example one, but not use in example two? dchar[] str2 =