Deprecation

2019-01-18 Thread Ali via Digitalmars-d-learn
Hello. I am having an issue with the code below. the out put after compiling is this : Deprecation: foreach: loop index implicitly converted from size_t to uint the code is : auto available = new int[cast(uint) max - min]; foreach (uint i, ref a; available)

Re: depreciated function delete

2019-01-18 Thread Ali via Digitalmars-d-learn
On Friday, 18 January 2019 at 21:37:38 UTC, Steven Schveighoffer wrote: On 1/18/19 4:32 PM, Ali wrote: On Friday, 18 January 2019 at 21:13:34 UTC, Steven Schveighoffer wrote: On 1/18/19 3:48 PM, alik wrote: Hi there. as you know delete function is depreciated. so I tried to use the __delete fu

Re: depreciated function delete

2019-01-18 Thread Ali via Digitalmars-d-learn
On Friday, 18 January 2019 at 21:13:34 UTC, Steven Schveighoffer wrote: On 1/18/19 3:48 PM, alik wrote: Hi there. as you know delete function is depreciated. so I tried to use the __delete function for the code below: if (this.parse_buffer.length > this.parse_size)     {

Re: c2 classes

2018-04-06 Thread Ali via Digitalmars-d-learn
On Friday, 6 April 2018 at 14:31:49 UTC, Alex wrote: On Friday, 6 April 2018 at 13:41:50 UTC, aerto wrote: its possible to make this work ?? import std.stdio; class UUsers { public: int age; } class users { public: int[int] uid; } void main() { users newuser = ne

Re: c2 classes

2018-04-06 Thread Ali via Digitalmars-d-learn
On Friday, 6 April 2018 at 13:41:50 UTC, aerto wrote: its possible to make this work ?? import std.stdio; class UUsers { public: int age; } class users { public: int[int] uid; } void main() { users newuser = new users(); newuser.uid[0].age = 23; wr

Re: Declare and Define Before Use? [rant]

2018-04-04 Thread Ali via Digitalmars-d-learn
On Wednesday, 4 April 2018 at 19:51:27 UTC, kdevel wrote: On Wednesday, 4 April 2018 at 19:19:30 UTC, Ali wrote: BTW: You can't write void main () { x.writeln; int x; } import std.stdio; This is because x is not module scope you can do this void main () {

Re: Declare and Define Before Use? [rant]

2018-04-04 Thread Ali via Digitalmars-d-learn
On Wednesday, 4 April 2018 at 18:57:27 UTC, kdevel wrote: Why are people writing import std.stdio; void main () { } struct S { } but not void main () { } struct S { } import std.stdio; ? Personally i found it weird and inconsistent that y

Re: Learning D - modules packages and the package.d

2018-04-03 Thread Ali via Digitalmars-d-learn
On Wednesday, 4 April 2018 at 04:54:50 UTC, Ali wrote: at first i though package.d is special name, as in i must call the file package.d or this trick or idiom to work the trick was to have one module that public import all the modules you import as group in other modules so instead of impor

Learning D - modules packages and the package.d

2018-04-03 Thread Ali via Digitalmars-d-learn
I am going through the Learning D book by Michael Parker So every now and then I will make post about the book either critics of the book, book content or questions First critic chapter 2 - the special package module this small section, suggest an idiom to create a package which can have any n

Re: Optional parameters?

2018-04-01 Thread Ali via Digitalmars-d-learn
On Sunday, 1 April 2018 at 15:54:16 UTC, Steven Schveighoffer wrote: I currently have a situation where I want to have a function that accepts a parameter optionally. why not simply use function overloading?

Re: The first example in the Learning D book, wont compile

2018-03-25 Thread Ali via Digitalmars-d-learn
On Sunday, 25 March 2018 at 20:52:29 UTC, Ali wrote: On Sunday, 25 March 2018 at 20:45:58 UTC, Ali wrote: I now see my typo, should be retro, not range We need better IDEs, this would have been easily highlighted by a good ide

Re: The first example in the Learning D book, wont compile

2018-03-25 Thread Ali via Digitalmars-d-learn
On Sunday, 25 March 2018 at 20:45:58 UTC, Ali wrote: Hi The first example in the Learning D book import core.thread; import std.stdio; void main() { import std.range: iota, range; write("Greeting in, "); foreach(num; iota(1, 4).range) { writef("%s...", num); stdout.

The first example in the Learning D book, wont compile

2018-03-25 Thread Ali via Digitalmars-d-learn
Hi The first example in the Learning D book import core.thread; import std.stdio; void main() { import std.range: iota, range; write("Greeting in, "); foreach(num; iota(1, 4).range) { writef("%s...", num); stdout.flush(); Thread.sleep(1.seconds); } wr

Re: dmd download sig file, how do I use it

2018-03-25 Thread Ali via Digitalmars-d-learn
On Sunday, 25 March 2018 at 04:01:28 UTC, Seb wrote: gpg --verify --keyring ~/dlang/d-keyring.gpg --no-default-keyring dmd.2.079.0.linux.tar.xz.sig dmd.2.079.0.linux.tar.xz Thanks, I guess this kinda works I am now getting gpg: Signature made Fri 02 Mar 2018 01:47:57 PM EST gpg:

dmd download sig file, how do I use it

2018-03-24 Thread Ali via Digitalmars-d-learn
Hi All, The DMD download is accompanied with a sig file How exactly do I use this sig file I am assuming I can use it in place of checksum to verify the download And to be honest, I have almost zero knowledge for gpg and encryption I googled a little but, didnt exactly find what I was hoping

Re: Testing D database calls code for regression

2018-03-19 Thread Ali via Digitalmars-d-learn
On Friday, 16 March 2018 at 20:17:49 UTC, aberba wrote: How will you test D code which makes calls to database to detect bugs and regression. Unlike where you can inject data like assert (2+1 == 3), database interfacing code will be crazy... Or there's some mocking available for such cases. Es

Re: sort, .array and folding on immutable data (finding most common character in column of matrix)

2016-12-19 Thread Ali via Digitalmars-d-learn
On Monday, 19 December 2016 at 14:09:47 UTC, pineapple wrote: This is a shortcoming of Phobos - here is a package of sorting algorithms including some that do not require their inputs to be mutable, random access, and/or finite: https://github.com/pineapplemachine/mach.d/tree/master/mach/range

Re: sort, .array and folding on immutable data (finding most common character in column of matrix)

2016-12-19 Thread Ali via Digitalmars-d-learn
On Monday, 19 December 2016 at 12:45:48 UTC, Nicholas Wilson wrote: Ah, oh well. It was nice in theory. Indeed. Thank you for trying Nicholas :) auto word = data.map!(reduce!max).array.map!"a[1]".array; you want auto word = data.map!"a[1]".map!(reduce!max).array; Problem max has to pe

Re: sort, .array and folding on immutable data (finding most common character in column of matrix)

2016-12-19 Thread Ali via Digitalmars-d-learn
On Monday, 19 December 2016 at 10:03:34 UTC, Nicholas Wilson wrote: On Monday, 19 December 2016 at 09:24:38 UTC, Ali wrote: On Monday, 19 December 2016 at 00:11:49 UTC, Nicholas Wilson wrote: [...] Ok so laziness stops as soon as sort is required on a range then? No. Because a lazy range i

Re: Pointer to private structure

2016-12-19 Thread Ali via Digitalmars-d-learn
On Monday, 19 December 2016 at 06:42:27 UTC, Nikhil Jacob wrote: On Monday, 19 December 2016 at 06:21:10 UTC, ketmar wrote: i bet that just trying this with D compiler will take less time than writing forum post. I did try but it seems to give compilation failure... Let me try once more and I

Re: sort, .array and folding on immutable data (finding most common character in column of matrix)

2016-12-19 Thread Ali via Digitalmars-d-learn
On Monday, 19 December 2016 at 00:11:49 UTC, Nicholas Wilson wrote: On Sunday, 18 December 2016 at 22:26:50 UTC, Ali wrote: 1. The first line with the splitting, I need to use .array three times. The last one I understand is because on "line 2" I alias T as the type of the data, and if I don'

sort, .array and folding on immutable data (finding most common character in column of matrix)

2016-12-18 Thread Ali via Digitalmars-d-learn
Hey, so I have this data file that has a list of a string of characters separated by new lines. The task is to find the most common letter in each column. Ie if file is: abc axy cxc Then the letters are a (column 1), x and c. I've written the code to do this at compile time. But I have a few

Re: Accessing members through pointers to structs (also, CTFE associative arrays)

2016-12-17 Thread Ali via Digitalmars-d-learn
On Friday, 16 December 2016 at 01:48:59 UTC, Ali Çehreli wrote: On 12/15/2016 05:30 PM, Stefan Koch wrote: On Thursday, 15 December 2016 at 19:30:08 UTC, Ali Çehreli wrote: Yeah, I think the compiler is confused because the function is called in a non-const context during the initialization o

Re: Accessing members through pointers to structs (also, CTFE associative arrays)

2016-12-14 Thread Ali via Digitalmars-d-learn
On Tuesday, 13 December 2016 at 23:29:31 UTC, Ali Çehreli wrote: On 12/13/2016 01:36 PM, Ali wrote: Now about that second part of my problem I'm not entirely sure whether this should work but I think the problem is with mutating the 'frequencies' member of an immutable element of 'room

Re: Accessing members through pointers to structs (also, CTFE associative arrays)

2016-12-13 Thread Ali via Digitalmars-d-learn
On Tuesday, 13 December 2016 at 21:33:11 UTC, Ali Çehreli wrote: On 12/13/2016 12:30 PM, Ali wrote: > foreach (i, room; rooms) { > data[i].room = &room; That is the address of the local variable room. You need to use 'ref' there: foreach (i, ref room; rooms) { > - Ali Ahh

Re: Alias variable from another class

2016-12-13 Thread Ali via Digitalmars-d-learn
I guess it's because you're accessing a member of _1 from inside a scope of _2 where nothing has been constructed yet? Someone more familiar with D would probably have a better answer on this part. I'm quite new :) But a work around would be class _2 { _1 instance;

Re: Accessing members through pointers to structs (also, CTFE associative arrays)

2016-12-13 Thread Ali via Digitalmars-d-learn
On Tuesday, 13 December 2016 at 21:08:31 UTC, drug007 wrote: (*d.room).name Oh yeah, tried that too. That at least compiles but gives a runtime exception (bad address).

Re: reading from file

2016-12-13 Thread Ali via Digitalmars-d-learn
On Tuesday, 13 December 2016 at 16:59:17 UTC, Namal wrote: On Tuesday, 13 December 2016 at 16:57:40 UTC, Namal wrote: Sorry if I wasn't clear. The array should be two demensional and each line in text line should be a row in that 2x2 array. Also, it should be saved as an integer. And extendi

Accessing members through pointers to structs (also, CTFE associative arrays)

2016-12-13 Thread Ali via Digitalmars-d-learn
Hi, Long time watcher and recently started playing with D a bit more. Ran in to a couple of snags that I'll combine in one post. It involves a data set that contains a list of strings. Each string represents a Room name. What I'm trying to do is pluck out the room names and also calculate the f