What would need to be done to get sdc.lexer to std.lexer quality?

Jakob Ovrum jakobovrum at gmail.com
Thu Aug 2 01:42:52 PDT 2012


On Thursday, 2 August 2012 at 05:36:37 UTC, Walter Bright wrote:
> Using a class implies an extra level of indirection, and the 
> other issue is the only point to using a class is if you're 
> going to derive from it and override its methods. I don't see 
> that for a Token.
>
> Use pass-by-ref for the Token.

You'll always have an extra layer of indirection if you aim not 
to pass by value. By only exposing a pointer/class reference you 
make it impossible to do the wrong thing by implicitly copying 
the struct; and if we have a struct which is only ever meant to 
be used through a pointer, we're better off using a class.

Of course, if we can trim the size of the struct sufficiently I'm 
all for using a value type; then we would also lose the two-word 
overhead all classes have (but really shouldn't have to have; the 
monitor should only be on synchronized classes and we wouldn't 
have to force a vpointer if Object wasn't bloated, but that's an 
argument for another day).


More information about the Digitalmars-d mailing list