[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Documenting embedded lua API
- From: "Sam Roberts" <vieuxtech@...>
- Date: Tue, 11 Nov 2008 11:05:44 -0800
On Tue, Nov 11, 2008 at 9:13 AM, John Dunn <John_Dunn@qscaudio.com> wrote:
> How important do you think it is to conform to pure 'lua-isms' in the script
> API? I'm currently playing some tricks to implement object 'fields' using
> __index and __newindex so the user can use Control.Value = 5 instead of
> Control:SetValue(5). I originally did this since we were coming from a C
> background and that syntax was more familiar but I'm wondering if having
> non-standard syntax is a good idea.
My two bits.
You aren't playing "tricks". Index and newindex exist for exactly this
purpose. If you present what appears to be a domain specific extension
language natural to your users, but which is actually just lua, you're
using lua as intended, I'd say.
In terms of luaisms, I'd say the Control:SetValue() is the "least"
luaish. But if a (slightly verbose!) object-oriented API fits well
with your domain, then lua lets you implement one.
A simple property-based API is reasonable, too, and in a sense, the
control.value = 5 is more 'luaish", because it makes control look like
a table, the basic lua data structure.
Cheers,
Sam