lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I would have thought the article would point that out rather quickly, but I guess it didn't.. Imo, C# and lua make a completely wonderful duo, it's a bliss working with it, most of the tedious binding issues normally associated with C are simply gone, and things like the original question in this thread come almost naturally from reflection & attributes in c#...

Binding a function in a class is nothing more than this:

[Pancake.Script.AttrLuaFunc( "Log", "Log to activity console", "string to log" )] public void Log( string _message ) { ListViewItem item = activityconsole.Items.Add( _message ); item.EnsureVisible(); }

...which will spit out the name and description of itself and it's params if queried... (oh, and binding a class etc is simply rather meaningless, since it's already in .net to begin with)

Not sure how any of that would be done even remotely as elegant with C, but probably some form of elaborate wrapping mechanism, or as Matias
suggested, using the debug library.

Sorry for ranting, I just like using it this way, it's like a fresh breeze compared to C+lua (even though that's an order of magnitude easier than most other scripting languages), and I do have to say, this list is pretty predominantly C related... :)


Wesley Smith wrote:
When you say it's easy in C#, how would this be any different from C++?


On 9/14/07, Stefan Sandberg <> wrote:
It's very easy and elegant in C#..

Matias Guijarro wrote:

I would like to implement a kind of "help" function,
that would return a string documenting the function,
taken from the function source code (like Python

Maybe someone already tried ?

For Lua functions, I think a possible solution would
be to use the debug library (debug.getinfo) to find
the source file and to extract a kind of "docstring" out
of the function code.

Of course it will not be possible to do the same for
functions defined at runtime (for example if someone
does "f=function() return 'HELLO' end" no docstring
can be extracted...)...

And what about C functions ?
If I write a Lua library with C functions, I have no idea
how I could get a "docstring" out of it.

Any ideas ?

Thanks in advance!!!