Re: Why do we have Dmain?

2021-10-22 Thread Kirill via Digitalmars-d-learn
On Friday, 22 October 2021 at 07:00:25 UTC, Mike Parker wrote: [...] Thank you for such a clear explanation Mike and for a quick reply!

Why do we have Dmain?

2021-10-21 Thread Kirill via Digitalmars-d-learn
I am not a compiler expert, but I genuinely would like to know why we have Dmain. I've been looking at the generated assembly code recently and noticed the _Dmain function. I didn't notice it before. Then there is main, where Dmain is called. Why is that?

Extract base type of any array?

2021-09-18 Thread Kirill via Digitalmars-d-learn
How can I get the base type of any (multidimensional/static/dynamic/associative) array? Example: ``` void main() { int[][] intArr; double[4][] doubleArr; string[string][] strArr; intArr.example; // T = int doubleArr.example; // T = double strArr.example; // T = string }

Re: A way to mixin during runtime?

2021-08-27 Thread Kirill via Digitalmars-d-learn
On Friday, 27 August 2021 at 09:51:46 UTC, Mathias LANG wrote: On Friday, 27 August 2021 at 06:52:10 UTC, Kirill wrote: Is there a way to do mixin or similar during runtime? I'm trying to read a csv file and extract data types. Any ideas on how this should be approached in D are greatly

A way to mixin during runtime?

2021-08-27 Thread Kirill via Digitalmars-d-learn
Is there a way to do mixin or similar during runtime? I'm trying to read a csv file and extract data types. Any ideas on how this should be approached in D are greatly appreciated.

Re: How do I check if a variable is a multidimensional (2D) array?

2021-07-11 Thread Kirill via Digitalmars-d-learn
On Monday, 12 July 2021 at 05:08:29 UTC, jfondren wrote: On Monday, 12 July 2021 at 04:25:00 UTC, Kirill wrote: I know there is isArray!T and similar functionality in std.traits. But I couldn't find the functionality that can help me check if I have a multidimensional array. Is there any? How

How do I check if a variable is a multidimensional (2D) array?

2021-07-11 Thread Kirill via Digitalmars-d-learn
I know there is isArray!T and similar functionality in std.traits. But I couldn't find the functionality that can help me check if I have a multidimensional array. Is there any? How do I create my own? Thanks in advance.

Printing Tuple!(...)[] using for loop?

2021-07-01 Thread Kirill via Digitalmars-d-learn
I have a `Tuple!(string, ..., string)[] data` that I would like to print out: `a b c` `1 2 3` `4 5 6` Furthermore, I want to be able to print any N rows and M columns of that table. For instance: `b c` `2 3` or `1 2 3` `4 5

Re: Parallel foreach iteration with Associative Arrays

2021-04-16 Thread Kirill via Digitalmars-d-learn
On Saturday, 17 April 2021 at 02:14:50 UTC, Paul Backus wrote: `parallel` requires a range [1], and an associative array is not a range. To get a range of an AA's keys and values, you can use the method `.byKeyValue`: foreach (pair; parallel(example.byKeyValue)) {

Parallel foreach iteration with Associative Arrays

2021-04-16 Thread Kirill via Digitalmars-d-learn
I'd like to iterate over an associative array and output it's key and value using parallel from std.parallelism. But I get an error message: ParallelForeach!(int[string]) error instantiating. My code: auto example = ["apples": 100, "orange": 250, "banana": 175]; foreach(key, value;

Re: Tool to measure the time a function takes to execute?

2020-12-27 Thread Kirill via Digitalmars-d-learn
On Monday, 28 December 2020 at 07:00:59 UTC, Ali Çehreli wrote: On 12/27/20 10:24 PM, Kirill wrote: Hello, is there a tool to measure the execution time of a function in D? Can the GC do it? StopWatch and benchmark(): https://dlang.org/phobos/std_datetime.html Ali Thanks Ali! That's

Tool to measure the time a function takes to execute?

2020-12-27 Thread Kirill via Digitalmars-d-learn
Hello, is there a tool to measure the execution time of a function in D? Can the GC do it?

Re: How do I statically build a project using DUB?

2020-08-29 Thread Kirill via Digitalmars-d-learn
On Saturday, 29 August 2020 at 12:06:38 UTC, Andre Pany wrote: On Saturday, 29 August 2020 at 11:27:28 UTC, Kirill wrote: I need a stand-alone executable that does not require the user to install any libraries on their computer. Everything should be packed into the executable. I understand

How do I statically build a project using DUB?

2020-08-29 Thread Kirill via Digitalmars-d-learn
I need a stand-alone executable that does not require the user to install any libraries on their computer. Everything should be packed into the executable. I understand that I need to statically link all of the libraries I use in my project, but how do I do this? What do I need to add to

Re: Translating C headers to D: How do I compile it?

2020-06-28 Thread Kirill via Digitalmars-d-learn
On Sunday, 28 June 2020 at 05:13:32 UTC, Mike Parker wrote: On Sunday, 28 June 2020 at 04:59:12 UTC, Kirill wrote: something.d: module something; int add(int a, int b); This should be extern(C) int add(int a, int b). The extern(C) tells the D compiler to use the standard C calling

Translating C headers to D: How do I compile it?

2020-06-27 Thread Kirill via Digitalmars-d-learn
Hello. I am learning how to translate C headers to D. But how do I compile it? I am stuck with this. I have 4 files in the same directory: main.d, something.d, some.h, some.c some.h: //header guards int add(int a, int b); some.c: #include "some.h" int add(int a, int b) { return a+b; }

Re: Why are class variables public, when marked by the 'private' keyword?

2020-03-20 Thread Kirill via Digitalmars-d-learn
On Saturday, 21 March 2020 at 04:58:32 UTC, Mike Parker wrote: In D, the unit of encapsulation is the module. So private means "private to the module", i.e., private members are accessible within the same module. If ID were in a different module from main, you would see an error. Indeed, I

Why are class variables public, when marked by the 'private' keyword?

2020-03-20 Thread Kirill via Digitalmars-d-learn
I was playing around with visibility attributes in D. I created a class with private variables. Then I tried to access those variables through the class object. It compiled without any errors. However, ... Shouldn't the compiler output an error for trying to access private members of a

Re: practicality of empirical cache optimization in D vs C++

2014-11-10 Thread Kirill via Digitalmars-d-learn
I would also be curious to see projects in D that involved cache optimization.

practicality of empirical cache optimization in D vs C++

2014-11-10 Thread Kirill via Digitalmars-d-learn
Dear D community (and specifically experts on cache optimization), I'm a C++ programmer and was waiting for a while to do a project in D. I'd like to build a cache-optimized decision tree forest library, and I'm debating between D and C++. I'd like to make it similar to atlas, spiral, or