|
From: John L. <jla...@gm...> - 2006-12-11 23:49:02
|
First off, I'm going to rename some rather unfortunately named functions. These are mostly internal to wxLua, but you may have to rebuild your bindings using genwxbind.lua. More importantly, do we want stricter function parameter type checking. Lua itself is very generous and will convert numbers to strings, nil to number, etc... BUT, this means that without some checking you can spend a lot of time debugging a small typo since vars can be created on the fly with the value nil. Lua has nice functions, tostring(X), tonumber(X), and nil can be avoided using "nil or value". Below is what we currently accept for different variable types and what I propose I marked with a * See here http://wxlua.cvs.sourceforge.net/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp?view=markup wxLua_lua_isstringtype case LUA_TNIL: * MAKE INVALID can use [str or ""] case LUA_TSTRING: case LUA_TNUMBER: // can convert easily wxLua_lua_isbooleantype case LUA_TNIL: case LUA_TNUMBER: case LUA_TBOOLEAN: wxLua_lua_isenumerationtype case LUA_TNUMBER * check to see if it's an INT? probably not wxLua_lua_isnumbertype case LUA_TNIL: * MAKE INVALID can use [num or 0] //case LUA_TSTRING: // will be 0 unless really a number "2" case LUA_TNUMBER: case LUA_TBOOLEAN: Thoughts? John Labenski |
|
From: Hakki D. <dog...@tr...> - 2006-12-12 08:52:26
|
Hi, John Labenski wrote: > First off, I'm going to rename some rather unfortunately named > functions. These are mostly internal to wxLua, but you may have to > rebuild your bindings using genwxbind.lua. > > More importantly, do we want stricter function parameter type > checking. Lua itself is very generous and will convert numbers to > strings, nil to number, etc... BUT, this means that without some > checking you can spend a lot of time debugging a small typo since vars > can be created on the fly with the value nil. > > Lua has nice functions, tostring(X), tonumber(X), and nil can be > avoided using "nil or value". > > Below is what we currently accept for different variable types and > what I propose I marked with a * > > See here > http://wxlua.cvs.sourceforge.net/wxlua/wxLua/modules/wxlua/src/wxlstate.cpp?view=markup > > wxLua_lua_isstringtype > case LUA_TNIL: * MAKE INVALID can use [str or ""] Ok. > case LUA_TSTRING: > case LUA_TNUMBER: // can convert easily > > wxLua_lua_isbooleantype > case LUA_TNIL: > case LUA_TNUMBER: > case LUA_TBOOLEAN: > > wxLua_lua_isenumerationtype > case LUA_TNUMBER * check to see if it's an INT? probably not If you can't check that it is really an enum value, why bother? wx itself accepts int for enum? ex: // Bitmap flags enum wxBitmapType { wxBITMAP_TYPE_INVALID, // should be == 0 for compatibility! wxBITMAP_TYPE_BMP, wxBITMAP_TYPE_BMP_RESOURCE, ... wxBITMAP_TYPE_ANY = 50 }; wxImage(const wxString& name, long type = wxBITMAP_TYPE_ANY, int index = -1) > > wxLua_lua_isnumbertype > case LUA_TNIL: * MAKE INVALID can use [num or 0] Ok. > //case LUA_TSTRING: // will be 0 unless really a number "2" > case LUA_TNUMBER: > case LUA_TBOOLEAN: > > Thoughts? > John Labenski > -- Regards, Hakki Dogusan |
|
From: Francesco M. <f18...@ya...> - 2006-12-12 15:13:21
|
Hi, John Labenski ha scritto: > First off, I'm going to rename some rather unfortunately named > functions. These are mostly internal to wxLua, but you may have to > rebuild your bindings using genwxbind.lua. > > More importantly, do we want stricter function parameter type > checking. Lua itself is very generous and will convert numbers to > strings, nil to number, etc... BUT, this means that without some > checking you can spend a lot of time debugging a small typo since vars > can be created on the fly with the value nil. even if honestly I still haven't found enough time to start using wxLua myself :(, just a dummy advice: I'd keep the auto conversion code (it's an important part of modern interpreted languages I think) but I understand what you mean - so maybe we could add a work mode to wxLua interpreter so that it logs the creation of each new variable (to help debugging). This sort of logging has the disadvantage however that the log may become extremely long and thus unusable for big programs. BASIC (I started programming with it ;)) had an "Option Explicit" statement which allowed to turn on & off at run-time the creation of the variables on the fly: http://msdn2.microsoft.com/en-us/library/y9341s4f(vs.80).aspx maybe something like that could be the solution... Francesco |
|
From: Klaas H. <db...@nl...> - 2006-12-13 08:17:59
|
John Labenski wrote: > First off, I'm going to rename some rather unfortunately named > functions. These are mostly internal to wxLua, but you may have to > rebuild your bindings using genwxbind.lua. > > More importantly, do we want stricter function parameter type > checking. I like that. The more the better, i never understood what is so good about this automatic conversion, in general it does not save me time in the end, just more confusion :-) Klaas -- Unclassified |
|
From: Eero P. <epa...@ko...> - 2006-12-13 09:07:33
|
Francesco Montorsi wrote: > BASIC (I started programming with it ;)) had an "Option Explicit" > statement which allowed to turn on & off at run-time the creation of the > variables on the fly: > I have been using the "strict.lua" code piece with my wxLua applications, and it seems to catch my "mistyped a variable name" errors quite well. Eero |
|
From: John L. <jla...@gm...> - 2006-12-13 17:09:21
|
Ok well, based on everyones agreement I'll make things a little
stricter to provide a little better error checking. You'll get a
message along the lines of "expected XXX but got YYY".
Regards,
John Labenski
On 12/13/06, Eero Pajarre <epa...@ko...> wrote:
> Francesco Montorsi wrote:
>
> > BASIC (I started programming with it ;)) had an "Option Explicit"
> > statement which allowed to turn on & off at run-time the creation of the
> > variables on the fly:
>
> I have been using the "strict.lua" code piece with my wxLua applications,
> and it seems to catch my "mistyped a variable name" errors quite well.
>
>
> Eero
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> wxlua-users mailing list
> wxl...@li...
> https://lists.sourceforge.net/lists/listinfo/wxlua-users
>
|