I looked at the possibility to support some basic namespaces for built-in functions, for example math for mathematical functions (math.Round, math.Trunc, math.Abs), or str for string operations (str.Title, str.ToLower), and so on... However, I realized there is a bug with the current implementation which is somehow related to what looked at, i.e. IDENT '.' IDENT ( … ) or postfix_expression '.' postfix_expression (…).
The issue is that every function name is registered in the "names" map of the declarations, and the Decls.UseIdent function registers it as an identifier as well, always with a nil value because no value is ever assigned to this identifier, which is in fact just a function name…
This confusion between names, identifiers, and functions also leads to variety of strange situations:
I looked at the possibility to support some basic namespaces for built-in functions, for example
math
for mathematical functions (math.Round
,math.Trunc
,math.Abs
), orstr
for string operations (str.Title
,str.ToLower
), and so on... However, I realized there is a bug with the current implementation which is somehow related to what looked at, i.e.IDENT '.' IDENT ( … )
orpostfix_expression '.' postfix_expression (…)
.The issue is that every function name is registered in the "names" map of the declarations, and the
Decls.UseIdent
function registers it as an identifier as well, always with a nil value because no value is ever assigned to this identifier, which is in fact just a function name…This confusion between names, identifiers, and functions also leads to variety of strange situations: