Re: Trying to get current function name results in compiler error with __traits

2018-12-07 Thread Sepheus via Digitalmars-d-learn
On Friday, 7 December 2018 at 02:37:34 UTC, Arun Chandrasekaran wrote: I'm trying to get the current function name and apparently the commented line errors out. What am I doing wrong? https://run.dlang.io/is/EGsRU2 ``` #!/usr/bin/rdmd void main() { import std.experimental.all; void

Re: Imports and Subfolders and Links (Oh, My!)

2018-12-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 7 December 2018 at 16:39:34 UTC, Ron Tarrant wrote: import subfolder.ModuleName; And in the module files, the first statement is: module ModuleName; That's wrong: the import name and the module name should always match, in full, including all the dot parts. So if you "import

Imports and Subfolders and Links (Oh, My!)

2018-12-07 Thread Ron Tarrant via Digitalmars-d-learn
Trying to wrap my brain around imports, etc. In various places around the Internet, I've read that if I have modules in a subfolder/subdirectory, my import statement would look like this: import subfolder.ModuleName; And in the module files, the first statement is: module ModuleName;

Re: Imports and Subfolders and Links (Oh, My!)

2018-12-07 Thread rikki cattermole via Digitalmars-d-learn
On 08/12/2018 6:41 AM, Ron Tarrant wrote: Does D have the concept of makefiles? I haven't run across any reference to such things so far. Make isn't a D specification application (it doesn't really specialize in any language) dmd, druntime and Phobos are all built using it. Though for user

Code review - disjoint sets

2018-12-07 Thread Adnan via Digitalmars-d-learn
Hello. Is code-review requests welcome in this forum? If so I would like some criticisms and feedback for my disjoint sets implementation. The code is as follows: module dsets; /// dsets is an implementation of disjoint sets. It is implemented /// with a simple class. To construct it, you

Re: Imports and Subfolders and Links (Oh, My!)

2018-12-07 Thread Ron Tarrant via Digitalmars-d-learn
On Friday, 7 December 2018 at 16:43:02 UTC, Adam D. Ruppe wrote: That's wrong: the import name and the module name should always match, in full, including all the dot parts. So if you "import app.modulename;", the other file must have "module app.modulename;" Okay. I guess the instructions

Re: std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Friday, 7 December 2018 at 19:12:31 UTC, Seb wrote: On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: I'm trying to find the needle in the hay that's an array of strings. So the second assert fails for some reason. Is this expected? https://run.dlang.io/is/7OrZTA ```

Re: Imports and Subfolders and Links (Oh, My!)

2018-12-07 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Dec 08, 2018 at 06:48:46AM +1300, rikki cattermole via Digitalmars-d-learn wrote: > On 08/12/2018 6:41 AM, Ron Tarrant wrote: > > Does D have the concept of makefiles? I haven't run across any > > reference to such things so far. > > Make isn't a D specification application (it doesn't

Re: std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/7/18 1:57 PM, Dennis wrote: On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: Why is there a difference in the behavior? Your first assert expression is looking for a string in a larger string, your second expression looks for hay which is not a string but a

Re: std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Steven Schveighoffer via Digitalmars-d-learn
On 12/7/18 2:38 PM, Arun Chandrasekaran wrote: On Friday, 7 December 2018 at 19:12:31 UTC, Seb wrote: On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: I'm trying to find the needle in the hay that's an array of strings. So the second assert fails for some reason. Is this

Re: std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Dennis via Digitalmars-d-learn
On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: Why is there a difference in the behavior? Your first assert expression is looking for a string in a larger string, your second expression looks for hay which is not a string but a string[]. To flatten the array, use:

Re: std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Seb via Digitalmars-d-learn
On Friday, 7 December 2018 at 19:38:29 UTC, Arun Chandrasekaran wrote: On Friday, 7 December 2018 at 19:12:31 UTC, Seb wrote: On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: [...] Alternatively to the answers above you can also use a custom lambda for canFind:

Re: Imports and Subfolders and Links (Oh, My!)

2018-12-07 Thread Ron Tarrant via Digitalmars-d-learn
So, the upshot of it all seems to be that the -i's have it.

Re: Writing Program Without main Function

2018-12-07 Thread rikki cattermole via Digitalmars-d-learn
There is always a main function. It doesn't matter in which module its in or language. It just has to exist.

Re: std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Friday, 7 December 2018 at 19:12:31 UTC, Seb wrote: On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: I'm trying to find the needle in the hay that's an array of strings. So the second assert fails for some reason. Is this expected? https://run.dlang.io/is/7OrZTA ```

Re: std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Seb via Digitalmars-d-learn
On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: I'm trying to find the needle in the hay that's an array of strings. So the second assert fails for some reason. Is this expected? https://run.dlang.io/is/7OrZTA ``` #!/usr/bin/rdmd void main() { import

Re: std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Friday, 7 December 2018 at 19:08:05 UTC, Arun Chandrasekaran wrote: On Friday, 7 December 2018 at 18:57:48 UTC, Dennis wrote: On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: Why is there a difference in the behavior? Your first assert expression is looking for a

Re: Imports and Subfolders and Links (Oh, My!)

2018-12-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 7 December 2018 at 17:41:47 UTC, Ron Tarrant wrote: Are you talking about a list of import statements here or is there another way/place I would list them? On the dmd command line. So say your program has a.d and b.d, you would compile with `dmd a.d b.d`. Or as you had some

Re: Imports and Subfolders and Links (Oh, My!)

2018-12-07 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Dec 07, 2018 at 07:01:18PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Friday, 7 December 2018 at 17:41:47 UTC, Ron Tarrant wrote: [...] > > when I compile rather than compiling modules over and over > > needlessly. > > Oh, lots of us compile everything at once. It works

Writing Program Without main Function

2018-12-07 Thread Samir via Digitalmars-d-learn
Is it possible to write and execute a D program without a main function? Most of my programs will start with some `import` statements, followed by any functions and then ending with the `main` function (e.g. `void main() {`). As I am just a beginner to programming and still new to D, I have

std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Arun Chandrasekaran via Digitalmars-d-learn
I'm trying to find the needle in the hay that's an array of strings. So the second assert fails for some reason. Is this expected? https://run.dlang.io/is/7OrZTA ``` #!/usr/bin/rdmd void main() { import std.experimental.all; string s1 = "aaa111aaa"; string s2 = "aaa222aaa";

Re: std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Friday, 7 December 2018 at 18:57:48 UTC, Dennis wrote: On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: Why is there a difference in the behavior? Your first assert expression is looking for a string in a larger string, your second expression looks for hay which is

Re: Writing Program Without main Function

2018-12-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, December 7, 2018 2:02:59 PM MST Samir via Digitalmars-d-learn wrote: > Is it possible to write and execute a D program without a main > function? > > Most of my programs will start with some `import` statements, > followed by any functions and then ending with the `main` > function

Re: Writing Program Without main Function

2018-12-07 Thread Samir via Digitalmars-d-learn
Ok. Upon further investigation, I think I see what is going on. Most of the repos I am skimming are for this year's Advent of Code. They structure their repo with an `app.d` file which does contain a `main` function but this program is structured such that it imports the files I was looking

Re: Writing Program Without main Function

2018-12-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, December 7, 2018 2:42:33 PM MST Samir via Digitalmars-d-learn wrote: > Ok. Upon further investigation, I think I see what is going on. > Most of the repos I am skimming are for this year's Advent of > Code. They structure their repo with an `app.d` file which does > contain a `main`

Re: Working with ranges

2018-12-07 Thread Murilo via Digitalmars-d-learn
On Saturday, 8 December 2018 at 03:46:11 UTC, Adam D. Ruppe wrote: On Saturday, 8 December 2018 at 03:37:56 UTC, Murilo wrote: Hi guys, I have created an array of strings with "string[12] ps string[12] isn't a range, but string[] is. Try passing `ps[]` to the function instead of plain `ps`

Re: Working with ranges

2018-12-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 8 December 2018 at 03:37:56 UTC, Murilo wrote: Hi guys, I have created an array of strings with "string[12] ps string[12] isn't a range, but string[] is. Try passing `ps[]` to the function instead of plain `ps` and see what happens.

Re: Working with ranges

2018-12-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 8 December 2018 at 03:48:10 UTC, Murilo wrote: Try passing `ps[]` to the function instead of plain `ps` and see what happens. How do I transform an array into a range? With the slicing operator, [].

Re: Working with ranges

2018-12-07 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, December 7, 2018 8:46:11 PM MST Adam D. Ruppe via Digitalmars-d- learn wrote: > On Saturday, 8 December 2018 at 03:37:56 UTC, Murilo wrote: > > Hi guys, I have created an array of strings with "string[12] ps > > string[12] isn't a range, but string[] is. > > Try passing `ps[]` to the

Re: Working with ranges

2018-12-07 Thread Murilo via Digitalmars-d-learn
On Saturday, 8 December 2018 at 03:51:02 UTC, Adam D. Ruppe wrote: On Saturday, 8 December 2018 at 03:48:10 UTC, Murilo wrote: Try passing `ps[]` to the function instead of plain `ps` and see what happens. How do I transform an array into a range? With the slicing operator, []. Thank you

Re: Working with ranges

2018-12-07 Thread Murilo via Digitalmars-d-learn
On Saturday, 8 December 2018 at 04:16:25 UTC, Adam D. Ruppe wrote: On Saturday, 8 December 2018 at 04:11:03 UTC, Murilo wrote: What is the difference between declaring "int[3] a = [1,2,3];" and declaring "int[] a = [1,2,3];"? Is the first an array and the second a range? They are both

Re: std.algorithm.canFind behavior difference between arrays and elements

2018-12-07 Thread Arun Chandrasekaran via Digitalmars-d-learn
On Friday, 7 December 2018 at 20:28:37 UTC, Seb wrote: On Friday, 7 December 2018 at 19:38:29 UTC, Arun Chandrasekaran wrote: On Friday, 7 December 2018 at 19:12:31 UTC, Seb wrote: On Friday, 7 December 2018 at 18:51:27 UTC, Arun Chandrasekaran wrote: [...] Alternatively to the answers

Re: Working with ranges

2018-12-07 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 8 December 2018 at 04:11:03 UTC, Murilo wrote: What is the difference between declaring "int[3] a = [1,2,3];" and declaring "int[] a = [1,2,3];"? Is the first an array and the second a range? They are both arrays, just the former one has a fixed size and the latter does not.

Working with ranges

2018-12-07 Thread Murilo via Digitalmars-d-learn
Hi guys, I have created an array of strings with "string[12] ps = ["cat", "dog", "lion", "wolf", "coin", "chest", "money", "gold", "A", "B", "C", "D"];". I want to use the array as a range and I want to randomize it, like I want to transform that into several other ranges with the same

Re: could someone test support for Asian languages in nanogui port?

2018-12-07 Thread dangbinghoo via Digitalmars-d-learn
On Sunday, 6 May 2018 at 11:18:17 UTC, drug wrote: On 06.05.2018 06:10, Binghoo Dang wrote: hi, I'm a Chinese, and I just have done the test. I also copied some Japanese text from Dlang twitter channel and added some Chinese wide punctuation Char. And It's all seems displayed correctly.