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

Convert error and immutable to builtin functions #368

Open
qzb opened this issue Feb 11, 2022 · 0 comments
Open

Convert error and immutable to builtin functions #368

qzb opened this issue Feb 11, 2022 · 0 comments

Comments

@qzb
Copy link
Contributor

qzb commented Feb 11, 2022

I'm trying to understand why error and immutable and are keywords. It's quite easy to convert them to builtins, and there are a few reasons to do so:

  • Those two and import are the only keywords which behave like functions.
  • Casting to other types utilises builtin functions, not keywords.
  • error isn't a keyword in golang.
  • error is a method name in some popular libraries (e.g.: by resty, logrus), and since tengo doesn't allow using keywords as selectors keywords as selectors #301, it makes using them difficult.

The only downside I see is a negligible performance hit, since those function calls are made in a run time.

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

1 participant