aarzilli / golua

Go bindings for Lua C API - in progress

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing PushFString?

Ambrevar opened this issue · comments

lua_pushfstring seems to be missing: http://www.lua.org/manual/5.1/manual.html#lua_pushfstring.
Any reason for that?

Seems pretty limited compared to fmt.Sprintf and it has the added complexity of having a variable argument list. I think this is the reason.

What's the rational in general? "Keep it simple" or "stick to the Lua API"?
(Here it would obviously be the former.)

The API was designed by @Aftiz during the high middle ages, before go 1.0 and indoor plumbing.

I meant the available set of functions in golua: Do you think it should

  • stick to a minimum of API functions, keeping it simple,

  • or to be as faithful as possible to the Lua API?

Note that in this case adding a function will not break the API.

The original idea was to be faithful to the Lua API, the State object didn't even have methods. I think that lua_pushfstring was excluded because of its poor cost/benefits analysis: supporting varargs is a lot of trouble and lua_pushfstring doesn't do much compared to calling lua_pushstring + fmt.Sprintf.

Making a PushFString that just calls PushString on the result of fmt.Sprintf would be deceptive, since the language defined by lua format strings isn't the same as Go format strings.

Is this about compatibility with other lua libraries for go?

No, just about curiosity.
Thanks for the explanation, it seems pretty fair.