Re: CMake and D

2022-08-07 Thread rempas via Digitalmars-d-learn
On Saturday, 6 August 2022 at 18:22:45 UTC, Jan Allersma wrote: I figured out a strategy to solve te problem: 1) Create a C++ function which will be called in D. 2) Build a static C++ library with CMake and add dependencies (In my case: SDL libraries) 3) Create a new project (`dub init`). 4)

How do I initialize a templated constructor?

2022-08-07 Thread rempas via Digitalmars-d-learn
In the following struct (as an example, not real code): ``` struct TestArray(ulong element_n) { int[element_n] elements; this(string type)(ulong number) { pragma(msg, "The type is: " ~ typeof(type).stringof); } } ``` I want to create it and be able to successfully initialize the

Re: Verbosity in D

2022-08-07 Thread Siemargl via Digitalmars-d-learn
On Sunday, 7 August 2022 at 16:01:08 UTC, pascal111 wrote: It's clear by working with D that it has the same bad point like Pascal language; the "verbosity". Is there any plans in future to make some shorthanded techniques that clean verbosity from D? In most cases this is a false

Re: Main foreach loop fails when another foreach is added

2022-08-07 Thread ikelaiah via Digitalmars-d-learn
On Monday, 8 August 2022 at 02:45:54 UTC, Steven Schveighoffer wrote: And now, you tried to read it again! Which means you are trying to read more data from an empty stream. You need to either a) reopen the file, or b) do both in the same loop. -Steve Steve! You are Legend! **Thank

Re: Acess variable that was set by thread

2022-08-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/7/22 9:36 PM, vc wrote: Hello, i have the following code, the flora contains a boolean zeus in the DerivedThread the boolean zeus was set to true; but when i'm trying to access it outside the thread in main it returns me false; any thoughts ? is zeus declared just as: ```d bool zeus;

Re: Main foreach loop fails when another foreach is added

2022-08-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 8/7/22 10:11 PM, ikelaiah wrote: Hi, I'm writing a program that reads a text file and launch my work URLs in it. It worked fine, and very happy. Then I added another `foreach` loop to count total number of lines. After this, the main `foreach` won't work. Does anyone know as to why this

Re: Acess variable that was set by thread

2022-08-07 Thread Emanuele Torre via Digitalmars-d-learn
On Monday, 8 August 2022 at 01:36:45 UTC, vc wrote: Hello, i have the following code, the flora contains a boolean zeus in the DerivedThread the boolean zeus was set to true; but when i'm trying to access it outside the thread in main it returns me false; any thoughts ? import flora; class

Main foreach loop fails when another foreach is added

2022-08-07 Thread ikelaiah via Digitalmars-d-learn
Hi, I'm writing a program that reads a text file and launch my work URLs in it. It worked fine, and very happy. Then I added another `foreach` loop to count total number of lines. After this, the main `foreach` won't work. Does anyone know as to why this happens? I might have missed

Acess variable that was set by thread

2022-08-07 Thread vc via Digitalmars-d-learn
Hello, i have the following code, the flora contains a boolean zeus in the DerivedThread the boolean zeus was set to true; but when i'm trying to access it outside the thread in main it returns me false; any thoughts ? import flora; class DerivedThread : Thread { this() {

Re: Verbosity in D

2022-08-07 Thread Dom Disc via Digitalmars-d-learn
On Monday, 8 August 2022 at 00:40:11 UTC, TTK Ciar wrote: On the other hand, I've noticed that D's idiomatic brevity can be diluted by the extremely verbose function names used in the standard library. For long function names you can define short aliases, for syntax you can't. So having

Re: "chain" vs "~"

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Sunday, 7 August 2022 at 03:55:50 UTC, Emanuele Torre wrote: On Sunday, 7 August 2022 at 01:22:18 UTC, pascal111 wrote: [...] They are quite different: * `chain` gives you "range" (iterator) that starts from the first element of `x` and ends at the last element of `y` (like e.g. `zip` in

Re: Verbosity in D

2022-08-07 Thread TTK Ciar via Digitalmars-d-learn
On Monday, 8 August 2022 at 00:11:33 UTC, pascal111 wrote: I don't have specific code but it was a general notice. Take Python as in example, the same program in Python doesn't cost much code as D code, and of course by putting in accounts that that I assume that there are some special tasks D

Re: Verbosity in D

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Monday, 8 August 2022 at 00:18:12 UTC, Emanuele Torre wrote: On Monday, 8 August 2022 at 00:11:33 UTC, pascal111 wrote: [...] You are just sounding like a troll now... "troll" :) I like it! That makes no sense: "I assume that there are some special tasks D can do, while Python can't

Re: Verbosity in D

2022-08-07 Thread Emanuele Torre via Digitalmars-d-learn
On Monday, 8 August 2022 at 00:15:48 UTC, pascal111 wrote: On Sunday, 7 August 2022 at 23:44:26 UTC, Emanuele Torre wrote: On Sunday, 7 August 2022 at 23:31:45 UTC, pascal111 wrote: On Sunday, 7 August 2022 at 22:16:55 UTC, Emanuele Torre wrote: [...] It seems complex, I didn't get it yet,

Re: Supporting Arabic in GUI

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Monday, 8 August 2022 at 00:20:53 UTC, pascal111 wrote: On Monday, 8 August 2022 at 00:12:07 UTC, Emanuele Torre wrote: On Sunday, 7 August 2022 at 23:48:22 UTC, pascal111 wrote: [...] I am very confused by this question. That has nothing to do with the programming language: it has all

Re: Supporting Arabic in GUI

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Monday, 8 August 2022 at 00:12:07 UTC, Emanuele Torre wrote: On Sunday, 7 August 2022 at 23:48:22 UTC, pascal111 wrote: I have no idea about GUI or Rad programming in D; it's not its time, but I'm curious to know if D is fine supporting for Arabic language in the GUI applications or we will

Re: Verbosity in D

2022-08-07 Thread Emanuele Torre via Digitalmars-d-learn
On Monday, 8 August 2022 at 00:11:33 UTC, pascal111 wrote: On Sunday, 7 August 2022 at 23:53:36 UTC, Emanuele Torre wrote: On Sunday, 7 August 2022 at 16:01:08 UTC, pascal111 wrote: It's clear by working with D that it has the same bad point like Pascal language; the "verbosity". Is there any

Re: Verbosity in D

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Sunday, 7 August 2022 at 23:44:26 UTC, Emanuele Torre wrote: On Sunday, 7 August 2022 at 23:31:45 UTC, pascal111 wrote: On Sunday, 7 August 2022 at 22:16:55 UTC, Emanuele Torre wrote: [...] It seems complex, I didn't get it yet, I wished I didn't ask about it :) It's really trivial.

Re: Supporting Arabic in GUI

2022-08-07 Thread Emanuele Torre via Digitalmars-d-learn
On Sunday, 7 August 2022 at 23:48:22 UTC, pascal111 wrote: I have no idea about GUI or Rad programming in D; it's not its time, but I'm curious to know if D is fine supporting for Arabic language in the GUI applications or we will have some issues like I met - in my experience - in Free

Re: Verbosity in D

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Sunday, 7 August 2022 at 23:53:36 UTC, Emanuele Torre wrote: On Sunday, 7 August 2022 at 16:01:08 UTC, pascal111 wrote: It's clear by working with D that it has the same bad point like Pascal language; the "verbosity". Is there any plans in future to make some shorthanded techniques that

Re: Verbosity in D

2022-08-07 Thread Emanuele Torre via Digitalmars-d-learn
On Sunday, 7 August 2022 at 16:01:08 UTC, pascal111 wrote: It's clear by working with D that it has the same bad point like Pascal language; the "verbosity". Is there any plans in future to make some shorthanded techniques that clean verbosity from D? Quote: "In terms of functionality,

Re: Verbosity in D

2022-08-07 Thread Emanuele Torre via Digitalmars-d-learn
On Sunday, 7 August 2022 at 23:44:26 UTC, Emanuele Torre wrote: int[] arr = { 10, 12, 14 }; Oops, this is C++, not D: `int arr[] = { 10, 12, 14 };` =)

Supporting Arabic in GUI

2022-08-07 Thread pascal111 via Digitalmars-d-learn
I have no idea about GUI or Rad programming in D; it's not its time, but I'm curious to know if D is fine supporting for Arabic language in the GUI applications or we will have some issues like I met - in my experience - in Free Pascal. This is a topic where we trying to make a custom message

Re: Verbosity in D

2022-08-07 Thread Emanuele Torre via Digitalmars-d-learn
On Sunday, 7 August 2022 at 23:31:45 UTC, pascal111 wrote: On Sunday, 7 August 2022 at 22:16:55 UTC, Emanuele Torre wrote: On Sunday, 7 August 2022 at 20:15:05 UTC, pascal111 wrote: What destructuring binds? I didn't hear about that before. ```C++ #include struct Point { int x, y; };

Re: Verbosity in D

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Sunday, 7 August 2022 at 22:16:55 UTC, Emanuele Torre wrote: On Sunday, 7 August 2022 at 20:15:05 UTC, pascal111 wrote: What destructuring binds? I didn't hear about that before. ```C++ #include struct Point { int x, y; }; Point add_points(const Point& a, const Point& b) {

Re: Ranges

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Sunday, 7 August 2022 at 21:57:50 UTC, Ali Çehreli wrote: On 8/7/22 08:34, pascal111 wrote: > but after that in advanced level in programming, we should > use pointers to do same tasks we were doing with slices (the easy way of > beginners). That is an old thought. Today, we see that no

Re: Verbosity in D

2022-08-07 Thread Emanuele Torre via Digitalmars-d-learn
On Sunday, 7 August 2022 at 20:15:05 UTC, pascal111 wrote: What destructuring binds? I didn't hear about that before. ```C++ #include struct Point { int x, y; }; Point add_points(const Point& a, const Point& b) { return { a.x + b.x, a.y + b.y }; } int main() { const auto [x, y]

Re: Ranges

2022-08-07 Thread Ali Çehreli via Digitalmars-d-learn
On 8/6/22 22:58, Salih Dincer wrote: > Ranges are not like that, all they do is > generate. You may be right. I've never seen it that way. I've been under the following impression: - C++'s iterators are based on an existing concept: pointers. Pointers are iterators. - D's ranges are based

Re: Ranges

2022-08-07 Thread Ali Çehreli via Digitalmars-d-learn
On 8/7/22 08:34, pascal111 wrote: > Everyone knows that slices are not pointers D's slices are "fat pointers": In D's case, that translates to a pointer plus length. > that pointers are real work, Agreed. Pointers are fundamental features of CPUs. > but slices are like a simple un-deep

Re: Ranges

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Sunday, 7 August 2022 at 19:53:06 UTC, ag0aep6g wrote: On Sunday, 7 August 2022 at 15:34:19 UTC, pascal111 wrote: Everyone knows that slices are not pointers that pointers are real work, but slices are like a simple un-deep technique that is appropriate for beginners, but after that in

Re: Verbosity in D

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Sunday, 7 August 2022 at 16:45:15 UTC, jfondren wrote: On Sunday, 7 August 2022 at 16:01:08 UTC, pascal111 wrote: It's clear by working with D that it has the same bad point like Pascal language; the "verbosity". Is there any plans in future to make some shorthanded techniques that clean

Re: Ranges

2022-08-07 Thread Emanuele Torre via Digitalmars-d-learn
On Saturday, 6 August 2022 at 15:37:32 UTC, pascal111 wrote: On Friday, 5 August 2022 at 04:05:08 UTC, Salih Dincer wrote: On Thursday, 4 August 2022 at 22:54:42 UTC, pascal111 wrote: I didn't notice that all what we needs to pop a range forward is just a slice, yes, we don't need variable

Re: Ranges

2022-08-07 Thread ag0aep6g via Digitalmars-d-learn
On Sunday, 7 August 2022 at 15:34:19 UTC, pascal111 wrote: Everyone knows that slices are not pointers that pointers are real work, but slices are like a simple un-deep technique that is appropriate for beginners, but after that in advanced level in programming, we should use pointers to do

Re: Ranges

2022-08-07 Thread Salih Dincer via Digitalmars-d-learn
On Sunday, 7 August 2022 at 15:34:19 UTC, pascal111 wrote: Everyone knows that slices are not pointers that pointers are real work, but slices are like a simple un-deep technique that is appropriate for beginners, but after that in advanced level in programming, we should use pointers to do

Re: Verbosity in D

2022-08-07 Thread jfondren via Digitalmars-d-learn
On Sunday, 7 August 2022 at 16:01:08 UTC, pascal111 wrote: It's clear by working with D that it has the same bad point like Pascal language; the "verbosity". Is there any plans in future to make some shorthanded techniques that clean verbosity from D? That's not clear to me at all, and your

Verbosity in D

2022-08-07 Thread pascal111 via Digitalmars-d-learn
It's clear by working with D that it has the same bad point like Pascal language; the "verbosity". Is there any plans in future to make some shorthanded techniques that clean verbosity from D? Quote: "In terms of functionality, Pascal is pretty much exactly the same as C, except with some

Re: Ranges

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Sunday, 7 August 2022 at 05:12:38 UTC, Ali Çehreli wrote: On 8/6/22 14:10, pascal111 wrote: > a powerful point in the account of C. I missed how you made that connection. Everyone knows that slices are not pointers that pointers are real work, but slices are like a simple un-deep

Re: "chain" vs "~"

2022-08-07 Thread pascal111 via Digitalmars-d-learn
On Sunday, 7 August 2022 at 03:55:50 UTC, Emanuele Torre wrote: On Sunday, 7 August 2022 at 01:22:18 UTC, pascal111 wrote: [...] They are quite different: * `chain` gives you "range" (iterator) that starts from the first element of `x` and ends at the last element of `y` (like e.g. `zip` in

Re: Ranges

2022-08-07 Thread Salih Dincer via Digitalmars-d-learn
On Saturday, 6 August 2022 at 17:29:30 UTC, Ali Çehreli wrote: On 8/6/22 09:33, Salih Dincer wrote: > the slices feel like ranges, don't they? Yes because they are ranges. :) (Maybe you meant they don't have range member functions, which is true.) Slices use pointers. Do I need to tell you