Re: Object arrays in D

2012-04-11 Thread Steven Schveighoffer
On Wed, 11 Apr 2012 13:07:54 -0400, Johannes Pfau wrote: Am Tue, 10 Apr 2012 20:28:28 +0200 schrieb Marco Leise : Am Tue, 10 Apr 2012 07:35:31 -0400 schrieb "Steven Schveighoffer" : > Destructors are strictly for cleaning up resources that *AREN'T* > allocated by the GC. For example anyth

Re: Object arrays in D

2012-04-11 Thread H. S. Teoh
On Wed, Apr 11, 2012 at 07:07:54PM +0200, Johannes Pfau wrote: > Am Tue, 10 Apr 2012 20:28:28 +0200 > schrieb Marco Leise : > > > Am Tue, 10 Apr 2012 07:35:31 -0400 > > schrieb "Steven Schveighoffer" : > > > > > Destructors are strictly for cleaning up resources that *AREN'T* > > > allocated by t

Re: Object arrays in D

2012-04-11 Thread Johannes Pfau
Am Tue, 10 Apr 2012 20:28:28 +0200 schrieb Marco Leise : > Am Tue, 10 Apr 2012 07:35:31 -0400 > schrieb "Steven Schveighoffer" : > > > Destructors are strictly for cleaning up resources that *AREN'T* > > allocated by the GC. For example anything created with C's malloc, > > or an open file descr

Re: Object arrays in D

2012-04-11 Thread CrudOMatic
On Tuesday, 10 April 2012 at 18:28:39 UTC, Marco Leise wrote: Am Tue, 10 Apr 2012 07:35:31 -0400 schrieb "Steven Schveighoffer" : Destructors are strictly for cleaning up resources that *AREN'T* allocated by the GC. For example anything created with C's malloc, or an open file descriptor, e

Re: Object arrays in D

2012-04-10 Thread Marco Leise
Am Tue, 10 Apr 2012 07:35:31 -0400 schrieb "Steven Schveighoffer" : > Destructors are strictly for cleaning up resources that *AREN'T* allocated > by the GC. For example anything created with C's malloc, or an open file > descriptor, etc. This I think is a very good advice to beginners. Shor

Re: Object arrays in D

2012-04-10 Thread Jesse Phillips
class Deck { Card popBack() { auto card = cards.popBack(); // get last card. cards.length Note that popBack() is void: http://dlang.org/phobos/std_array.html#popBack use auto card = cards.back(); cards.popBack();

Re: Object arrays in D

2012-04-10 Thread CrudOMatic
Thanks, works fine now.

Re: Object arrays in D

2012-04-10 Thread simendsjo
On Tue, 10 Apr 2012 13:58:44 +0200, CrudOMatic wrote: Sorry, but a small issue. the line: auto card = cards.popBack(); throws the errors: error: variable xxx.card voids have no value error: expression popBack(this.cards) is void and has no value I tried reserving the space, I even tried c

Re: Object arrays in D

2012-04-10 Thread CrudOMatic
Sorry, but a small issue. the line: auto card = cards.popBack(); throws the errors: error: variable xxx.card voids have no value error: expression popBack(this.cards) is void and has no value I tried reserving the space, I even tried cards = new Card[no_cards];

Re: Object arrays in D

2012-04-10 Thread Steven Schveighoffer
On Tue, 10 Apr 2012 03:41:28 -0400, CrudOMatic wrote: The D documentation is a little lacking in a lot of areas. I'm needing to know an exact way of making arrays of objects. For example: /* Deck class */ // Will be adjusted with the proper cards for each game type class D

Re: Object arrays in D

2012-04-10 Thread CrudOMatic
Thanks much.

Re: Object arrays in D

2012-04-10 Thread simendsjo
On Tue, 10 Apr 2012 12:01:10 +0200, CrudOMatic wrote: Awesome. One last question, does popFront() have the same effect of decreasing length - or should I avoid popFront()? popFront will also reduce the length, but it will slice away the first item. Read the article I linked earlier. This

Re: Object arrays in D

2012-04-10 Thread CrudOMatic
On Tuesday, 10 April 2012 at 09:52:45 UTC, simendsjo wrote: On Tue, 10 Apr 2012 11:27:19 +0200, CrudOMatic wrote: h... so no need for a generic object reference counter. Nice. I was trying to approach it from a literal sense (e.g. card moves from deck to player's hand) - when you do the p

Re: Object arrays in D

2012-04-10 Thread simendsjo
On Tue, 10 Apr 2012 11:27:19 +0200, CrudOMatic wrote: h... so no need for a generic object reference counter. Nice. I was trying to approach it from a literal sense (e.g. card moves from deck to player's hand) - when you do the popBack() is that object returned and deleted from the ori

Re: Object arrays in D

2012-04-10 Thread CrudOMatic
On Tuesday, 10 April 2012 at 09:15:13 UTC, simendsjo wrote: On Tue, 10 Apr 2012 10:53:58 +0200, CrudOMatic wrote: On Tuesday, 10 April 2012 at 08:05:33 UTC, simendsjo wrote: On Tue, 10 Apr 2012 09:41:28 +0200, CrudOMatic wrote: The D documentation is a little lacking in a lot of areas. I

Re: Object arrays in D

2012-04-10 Thread simendsjo
On Tue, 10 Apr 2012 10:53:58 +0200, CrudOMatic wrote: On Tuesday, 10 April 2012 at 08:05:33 UTC, simendsjo wrote: On Tue, 10 Apr 2012 09:41:28 +0200, CrudOMatic wrote: The D documentation is a little lacking in a lot of areas. I'm needing to know an exact way of making arrays of object

Re: Object arrays in D

2012-04-10 Thread CrudOMatic
On Tuesday, 10 April 2012 at 08:05:33 UTC, simendsjo wrote: On Tue, 10 Apr 2012 09:41:28 +0200, CrudOMatic wrote: The D documentation is a little lacking in a lot of areas. I'm needing to know an exact way of making arrays of objects. For example: /* Deck class */ // Will be adjust

Re: Object arrays in D

2012-04-10 Thread simendsjo
On Tue, 10 Apr 2012 09:41:28 +0200, CrudOMatic wrote: The D documentation is a little lacking in a lot of areas. I'm needing to know an exact way of making arrays of objects. For example: /* Deck class */ // Will be adjusted with the proper cards for each game type class D

Object arrays in D

2012-04-10 Thread CrudOMatic
The D documentation is a little lacking in a lot of areas. I'm needing to know an exact way of making arrays of objects. For example: /* Deck class */ // Will be adjusted with the proper cards for each game type class Deck { /* Card count - used to keep track of how many cards