Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generics #12

Closed
verygoodsoftwarenotvirus opened this issue May 9, 2023 · 2 comments
Closed

Generics #12

verygoodsoftwarenotvirus opened this issue May 9, 2023 · 2 comments

Comments

@verygoodsoftwarenotvirus

Hi there! I've been looking at a few embeddable languages in Go and I quite like your project. I was wondering what you think about the use of Generics in the library, and getting rid of the empty Evaluator struct? I've got a branch with the code changes if you'd like to take a gander (I'm not going to bug you with a PR to review).

It breaks having nil be something you can evaluate/return on its own, so I had to delete/exclude some of those tests, and it necessitates a /v2 release of the codebase because it would break backwards compatibility. In exchange for those tradeoffs, though, you get to avoid a lot of the if val, ok := interfaceVar.(string); ok { stuff you might otherwise have to endure

@maja42
Copy link
Owner

maja42 commented May 26, 2023

I'd need to take a closer look at a generic approach, but on first glance, I don't think the advantages outweigh the disadvantages.
It would be a breaking change that requires a v2, only for putting the type assertion inside the evaluator itself.
It would also force everyone to update to go1.18+ (which isn't too bad, but still).

@maja42
Copy link
Owner

maja42 commented Mar 25, 2024

I don't plan on breaking compatibility for adding generics.
Unless it adds additional benefits outside saving a type-cast (which could also be done by a simple wrapper), I don't think it is worth the cost.

@maja42 maja42 closed this as completed Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants