pigeon icon indicating copy to clipboard operation
pigeon copied to clipboard

Add type safety

Open felipellrocha opened this issue 6 years ago • 4 comments

Dealing with interfaces can be quite burdensome. Why not add type safety to the project?

The data matched by a single character matcher type byte, and if you are matching multiple items it's always an [] of whatever type underlies it. And instead of using simple { } go blocks, have it with a bit more detail, but details that define types. Something like this: [int, error] { } that defines we'll be returning an int, and an error

felipellrocha avatar Jan 04 '18 18:01 felipellrocha

@felipellrocha we are aware of the fact, that dealing with the interface{} everywhere is not funny and therefore, having static typing is on the wishlist. Feel free to move forward with this and write an initial PR.

That being said, I am not yet sure, what the best way to implement this would be.

breml avatar Jan 04 '18 19:01 breml

Does the generics now in 1.18beta1 help makes this more tractable?

delaneyj avatar Feb 01 '22 23:02 delaneyj

Hi @delaneyj Interesting question. I doubt, that generics alone do improve the situation. I assume, that an extension of the PEG grammar would be needed as well. But I have to admit, that I did not think about this at length.

breml avatar Feb 02 '22 17:02 breml