struct vs class for a simple token in my d lexer

Tobias Pankrath tobias at pankrath.net
Mon May 14 08:44:53 PDT 2012


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/odcrgqxoldrktdtarskf@forum.dlang.org
>
> Cross-posting here. I would appreciate any feedback. (Whether 
> to reply in this or that thread is up to you.) Thanks


struct Token
{
     TokenType type;
     string content; // type may as well be template parameter
     Area loc;   // basically: ((x1, y1), (x2, y2))
}

That's how my Token look like. The 2 or 3 times every token get's 
copied isn't worth a heap allocation with small type like this.


More information about the Digitalmars-d-learn mailing list