Re: How to loop through characters of a string in D language?

2021-12-09 Thread Rumbu via Digitalmars-d-learn
On Wednesday, 8 December 2021 at 11:23:45 UTC, BoQsc wrote: Let's say I want to skip characters and build a new string. The character I want to skip: `;` Expected result: ``` abcdefab ``` Since it seems there is a contest here: ```d "abc;def;ghi".split(';').join(); ``` :)

Re: How to loop through characters of a string in D language?

2021-12-09 Thread forkit via Digitalmars-d-learn
On Thursday, 9 December 2021 at 18:00:42 UTC, kdevel wrote: PRO: - saves two lines of boilerplate code CONS: - raw loop - postinc ++ is only permitted in ++C - inconsistent spacing around "=" - mixing tabs and spaces for indentation - arrow code more PROs: - You become less dependent on

Re: How to use inheritance when interfacing with C++ classes?

2021-12-09 Thread Tim via Digitalmars-d-learn
On Thursday, 9 December 2021 at 19:05:08 UTC, rempas wrote: Anyone has an idea? The referenced methods like Fl_Widget::_clear_fullscreen are implemented directly in the header, so the D code also needs the implementation, because it is not included in the compiled library. Methods, which

Re: Can anyone provide an example of how D templates are overridable by global symbols?

2021-12-09 Thread Siarhei Siamashka via Digitalmars-d-learn
On Thursday, 9 December 2021 at 20:53:52 UTC, Siarhei Siamashka wrote: 2. How would one construct a simple example of a template symbol getting successfully overridden by a global symbol? Here's my unsuccessful attempt: ```D module template_f; T f(T)(T a, T b) { return a + b; } ``` ```D

Can anyone provide an example of how D templates are overridable by global symbols?

2021-12-09 Thread Siarhei Siamashka via Digitalmars-d-learn
A quote of Iain Buclaw from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102765 about GDC behaviour: D semantics for template symbols is that they must be overridable - even by normal global symbols. So in version 11.1, the default linkage for templates was switched over to weak, and with

How to use inheritance when interfacing with C++ classes?

2021-12-09 Thread rempas via Digitalmars-d-learn
I would like to interface with a C++ library called [FLTK](https://www.fltk.org/). I'm trying to implement the binding for the classes based to what I've read [here](https://dlang.org/spec/cpp_interface.html#classes) but it seems that It doesn't work as expected for me. I want to implement

Re: How to loop through characters of a string in D language?

2021-12-09 Thread kdevel via Digitalmars-d-learn
On Wednesday, 8 December 2021 at 14:16:16 UTC, bauss wrote: [...] string b = a.replace(";", ""); 

Re: How to loop through characters of a string in D language?

2021-12-09 Thread kdevel via Digitalmars-d-learn
On Wednesday, 8 December 2021 at 13:01:32 UTC, BoQsc wrote: [...] I'm not getting used to the syntax and that leads to poor readability. It depends on what you expect when you read source code. I don't want to read how seats in the memory are assigned to bits and bytes. Instead I want to

Re: C++ bindings: const(T) dropped in return types of templates ?

2021-12-09 Thread Jan via Digitalmars-d-learn
On Thursday, 9 December 2021 at 07:58:46 UTC, frame wrote: On Thursday, 9 December 2021 at 07:41:32 UTC, frame wrote: On Monday, 6 December 2021 at 20:31:47 UTC, Jan wrote: So am I missing something, or did the compiler somehow forget about the const-ness? Sounds like a bug to me, eg this

Re: T... args!

2021-12-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/8/21 7:36 PM, Salih Dincer wrote: On Wednesday, 8 December 2021 at 23:47:07 UTC, Adam Ruppe wrote: On Wednesday, 8 December 2021 at 23:43:48 UTC, Salih Dincer wrote: I think you meant to say void foo(string[] args...) {} Not exactly... ```d alias str = immutable(char)[]; void

Re: T... args!

2021-12-09 Thread Petar via Digitalmars-d-learn
On Thursday, 9 December 2021 at 00:36:29 UTC, Salih Dincer wrote: On Wednesday, 8 December 2021 at 23:47:07 UTC, Adam Ruppe wrote: On Wednesday, 8 December 2021 at 23:43:48 UTC, Salih Dincer wrote: I think you meant to say void foo(string[] args...) {} Not exactly... ```d alias str =

Re: C++ bindings: const(T) dropped in return types of templates ?

2021-12-09 Thread frame via Digitalmars-d-learn
On Thursday, 9 December 2021 at 07:41:32 UTC, frame wrote: On Monday, 6 December 2021 at 20:31:47 UTC, Jan wrote: So am I missing something, or did the compiler somehow forget about the const-ness? Sounds like a bug to me, eg this one: https://issues.dlang.org/show_bug.cgi?id=20685 But