Re: Struct vs. Class

2015-06-26 Thread Chris via Digitalmars-d-learn
On Friday, 26 June 2015 at 11:28:38 UTC, Daniel Kozák wrote: On Fri, 26 Jun 2015 11:11:15 + Chris via Digitalmars-d-learn wrote: I have still some classes lying around in my code. As threading is becoming more and more of an issue, classes and OOP in general turn out to be a nuisance.

Re: Struct vs. Class

2015-06-26 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 26 Jun 2015 11:11:15 + Chris via Digitalmars-d-learn wrote: > I have still some classes lying around in my code. As threading > is becoming more and more of an issue, classes and OOP in general > turn out to be a nuisance. It's not so hard to turn the classes > into structs, a lot

Re: Struct vs. Class

2015-06-26 Thread Daniel Kozák via Digitalmars-d-learn
On Fri, 26 Jun 2015 11:11:15 + Chris via Digitalmars-d-learn wrote: > I have still some classes lying around in my code. As threading > is becoming more and more of an issue, classes and OOP in general > turn out to be a nuisance. It's not so hard to turn the classes > into structs, a lot

Re: struct vs class for a simple token in my d lexer

2012-05-15 Thread Artur Skawina
On 05/14/12 17:10, Roman D. Boiko wrote: > (Subj.) I'm in doubt which to choose for my case, but this is a generic > question. > > http://forum.dlang.org/post/odcrgqxoldrktdtar...@forum.dlang.org > > Cross-posting here. I would appreciate any feedback. (Whether to reply in > this or that thread

Re: struct vs class for a simple token in my d lexer

2012-05-15 Thread Roman D. Boiko
On Tuesday, 15 May 2012 at 06:17:31 UTC, Era Scarecrow wrote: If you don't mind doing some lite informational reading, read up on 'lex and yacc'. ISBN: 1-56592-000-7; Hope I got that right. I'm not telling you to use C (or the other tools mind you), but it does go into handling tokens of multi

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Roman D. Boiko
On Tuesday, 15 May 2012 at 06:17:31 UTC, Era Scarecrow wrote: On Monday, 14 May 2012 at 18:00:42 UTC, Roman D. Boiko wrote: On Monday, 14 May 2012 at 17:37:02 UTC, Dmitry Olshansky wrote: But hopefully you get the idea. See something simillar in std.regex, though pointer in there also serves fo

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Era Scarecrow
On Monday, 14 May 2012 at 18:00:42 UTC, Roman D. Boiko wrote: On Monday, 14 May 2012 at 17:37:02 UTC, Dmitry Olshansky wrote: But hopefully you get the idea. See something simillar in std.regex, though pointer in there also serves for intrusive linked-list. Thanks, most likely I'll go your w

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Era Scarecrow
On Monday, 14 May 2012 at 18:00:42 UTC, Roman D. Boiko wrote: On Monday, 14 May 2012 at 17:37:02 UTC, Dmitry Olshansky wrote: But hopefully you get the idea. See something simillar in std.regex, though pointer in there also serves for intrusive linked-list. Thanks, most likely I'll go your w

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Roman D. Boiko
On Monday, 14 May 2012 at 17:37:02 UTC, Dmitry Olshansky wrote: But hopefully you get the idea. See something simillar in std.regex, though pointer in there also serves for intrusive linked-list. Thanks, most likely I'll go your way.

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Dmitry Olshansky
On 14.05.2012 21:33, Dmitry Olshansky wrote: On 14.05.2012 21:20, Roman D. Boiko wrote: On Monday, 14 May 2012 at 16:41:39 UTC, Jonathan M Davis wrote: On Monday, May 14, 2012 17:10:23 Roman D. Boiko wrote: (Subj.) I'm in doubt which to choose for my case, but this is a generic question. http

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Dmitry Olshansky
On 14.05.2012 21:20, Roman D. Boiko wrote: On Monday, 14 May 2012 at 16:41:39 UTC, Jonathan M Davis wrote: On Monday, May 14, 2012 17:10:23 Roman D. Boiko wrote: (Subj.) I'm in doubt which to choose for my case, but this is a generic question. http://forum.dlang.org/post/odcrgqxoldrktdtar...@f

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Roman D. Boiko
On Monday, 14 May 2012 at 17:05:17 UTC, Dmitry Olshansky wrote: On 14.05.2012 19:10, Roman D. Boiko wrote: (Subj.) I'm in doubt which to choose for my case, but this is a generic question. http://forum.dlang.org/post/odcrgqxoldrktdtar...@forum.dlang.org Cross-posting here. I would appreciate

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Dmitry Olshansky
On 14.05.2012 21:16, Tobias Pankrath wrote: struct Token{ uint col, line; uint flags;//indicated info about token, serves as both type tag and flag set; //indicates proper type once token was cooked (like "31.415926" -> 3.145926e1) i.e. values are calculated union { string chars; float f_val; d

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Roman D. Boiko
On Monday, 14 May 2012 at 16:41:39 UTC, Jonathan M Davis wrote: On Monday, May 14, 2012 17:10:23 Roman D. Boiko wrote: (Subj.) I'm in doubt which to choose for my case, but this is a generic question. http://forum.dlang.org/post/odcrgqxoldrktdtar...@forum.dlang.org Cross-posting here. I would

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Tobias Pankrath
struct Token{ uint col, line; uint flags;//indicated info about token, serves as both type tag and flag set; //indicates proper type once token was cooked (like "31.415926" -> 3.145926e1) i.e. values are calculated union { string chars; float f_val;

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Dmitry Olshansky
On 14.05.2012 19:10, Roman D. Boiko wrote: (Subj.) I'm in doubt which to choose for my case, but this is a generic question. http://forum.dlang.org/post/odcrgqxoldrktdtar...@forum.dlang.org Cross-posting here. I would appreciate any feedback. (Whether to reply in this or that thread is up to yo

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Roman D. Boiko
On Monday, 14 May 2012 at 15:53:34 UTC, Tobias Pankrath wrote: Quoting your post in another thread: On Monday, 14 May 2012 at 15:10:25 UTC, Roman D. Boiko wrote: Making it a class would give several benefits: * allow not to worry about allocating a big array of tokens. E.g., on 64-bit OS the

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Jonathan M Davis
On Monday, May 14, 2012 17:10:23 Roman D. Boiko wrote: > (Subj.) I'm in doubt which to choose for my case, but this is a > generic question. > > http://forum.dlang.org/post/odcrgqxoldrktdtar...@forum.dlang.org > > Cross-posting here. I would appreciate any feedback. (Whether to > reply in this or

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Roman D. Boiko
On Monday, 14 May 2012 at 15:44:54 UTC, Tobias Pankrath wrote: On Monday, 14 May 2012 at 15:10:25 UTC, Roman D. Boiko wrote: (Subj.) I'm in doubt which to choose for my case, but this is a generic question. http://forum.dlang.org/post/odcrgqxoldrktdtar...@forum.dlang.org Cross-posting here. I

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Tobias Pankrath
Quoting your post in another thread: On Monday, 14 May 2012 at 15:10:25 UTC, Roman D. Boiko wrote: Making it a class would give several benefits: * allow not to worry about allocating a big array of tokens. E.g., on 64-bit OS the largest module in Phobos (IIRC, the std.datetime) consumes 13.

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Tobias Pankrath
On Monday, 14 May 2012 at 15:10:25 UTC, Roman D. Boiko wrote: (Subj.) I'm in doubt which to choose for my case, but this is a generic question. http://forum.dlang.org/post/odcrgqxoldrktdtar...@forum.dlang.org Cross-posting here. I would appreciate any feedback. (Whether to reply in this or th

Re: struct vs class

2010-11-14 Thread Lutger Blijdestijn
spir wrote: > On Sun, 14 Nov 2010 12:02:35 + > div0 wrote: > >> > Both of these points may conflict with semantic considerations above: >> > we may want to use structs for fast creation, but if ever they mean >> > "things", we must think at referencing them manually and/or using >> > ref

Re: struct vs class

2010-11-14 Thread Jonathan M Davis
On Sunday 14 November 2010 04:14:29 spir wrote: > On Sun, 14 Nov 2010 03:32:18 -0800 > > Jonathan M Davis wrote: > > On Sunday 14 November 2010 03:08:49 spir wrote: > > > Hello, > > > > > > > > > There seems to be 2 main differences between structs & classes: > > > 1. structs instances are dire

Re: struct vs class

2010-11-14 Thread spir
On Sun, 14 Nov 2010 12:02:35 + div0 wrote: > > Both of these points may conflict with semantic considerations above: > > we may want to use structs for fast creation, but if ever they mean > > "things", we must think at referencing them manually and/or using > > ref parameters. We may want

Re: struct vs class

2010-11-14 Thread spir
On Sun, 14 Nov 2010 03:32:18 -0800 Jonathan M Davis wrote: > On Sunday 14 November 2010 03:08:49 spir wrote: > > Hello, > > > > > > There seems to be 2 main differences between structs & classes: > > 1. structs instances are direct values, implement value semantics; while > > class instances ar

Re: struct vs class

2010-11-14 Thread div0
On 14/11/2010 11:08, spir wrote: Hello, There seems to be 2 main differences between structs& classes: 1. structs instances are direct values, implement value semantics; > while class instances are referenced (actually "pointed") 2. classes can be subtyped/subclassed in a simple way; structs

Re: struct vs class

2010-11-14 Thread bearophile
spir: > a value makes no sense by itself, it is bound to what it describes an aspect > of; referencing a value is meaningless, only copy makes no sense. For > instance, the position & color of a visual form should be values. Structs may have a meaning by themselves, all kind of member functions

Re: struct vs class

2010-11-14 Thread Jonathan M Davis
On Sunday 14 November 2010 03:08:49 spir wrote: > Hello, > > > There seems to be 2 main differences between structs & classes: > 1. structs instances are direct values, implement value semantics; while > class instances are referenced (actually "pointed") 2. classes can be > subtyped/subclassed i