First D project, problem with error messages

Steven Schveighoffer schveiguy at gmail.com
Thu Feb 9 19:42:23 UTC 2023


On 2/9/23 2:37 PM, Daniel wrote:

> class Lexer() {

You have made Lexer take compile-time parameters by adding the 
parentheses. And there are no parameters, so the use of this is quite 
narrow.

In essence, your `Lexer` class is a *template*, which means it doesn't 
exist until it's instantiated with appropriate parameters.

The appropriate parameters can only be `Lexer!()`, since it takes none.

So your two options here are to do that (use `Lexer!()` instead of 
`Lexer`), or remove the parentheses, changing it to a regular class 
instead of a template.

If you are not used to templates (like in C++) or generics (like in C# 
or Java or many others), then I would say just remove the template 
parameters. Having no parameters has limited use, mostly to allow it to 
be a mixin template, or to prevent it from being included in the binary 
unless it's used.

-Steve


More information about the Digitalmars-d mailing list