d5 / tengo

A fast script language for Go

Home Page:https://tengolang.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Convert error and immutable to builtin functions

qzb opened this issue · comments

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 #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.