lua-users home
lua-l archive

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

The question I posted is not strictly related to which language ( C or C++ )
should lua target. In fact, I think
it´s better to have a C interface and ´conception´ ... it´s
more ´useable´ than to jacket all people and circumstances to C++. At last,
it´s allways possible to
interface C++ to C, the opposite is not always straigthforward. The
´constructor´ I mentioned for userdata is a matter of convenience, and has
no intimate
relation to the host language itself ( my tests are writen and compiled
using plain C ). In fact, a userdata ´method´
may or may not correlate with a C++ ´method´. Also, the
wiki has a beatyful example of how to interface a C++ class to a lua
userdata ( I learned a lot of it ).
What I am taking from C++ is the basic concept behind
´user types´ not being second class citizens. So, C++ allows one to
´redefine´ ( or plainly, define ) what the
asignation, comparation, and arith ops means to a class.
Also, it allows the programer to define the semantics of
user-class-to-native-objects operations, etc
It´s not necessary to change the lua interface ( or language ) to get these
OO ideas supported
----- Original Message -----
From: "Basile STARYNKEVITCH" <>
To: "Multiple recipients of list" <>
Sent: Tuesday, October 08, 2002 2:35 PM
Subject: userdata considerations

>>>>> "mnicolet" == mnicolet  <> writes:

    mnicolet> I migrated to lua 5.0a because userdata manageability.
    mnicolet> Also, I devised a lot of userdata support routines.
    mnicolet> They are included in luapi ... I will post the lua 5.0
    mnicolet> version of it next days.  The best (unique ?) way I
    mnicolet> found to deal with userdata is to have a "constructor"
    mnicolet> for every of them; u = newudtype( construction arguments
    mnicolet> here ) Of course, every userdata "type" must have its
    mnicolet> own constructor, and of course, the constructor
    mnicolet> semantics is privative for the "type" ...  But I"am
    mnicolet> thinking about lua"s native support for that stuff.  My
    mnicolet> first and main "userdata" is a lua bind to some class I
    mnicolet> use extensively in my applications to "wrap" the native
    mnicolet> C/C++ objects. [...]

I skipped an interesting part of Mnicolet's message. But I think it
raise the following issue: is lua a C or C++ embeddable scripting
language, i.e. does the Lua API target C or C++?

I definitely think Lua (even the 5. and future 6. versions) should
target C, not C++.

If you designed a language easy to embed into C++ applications (which
lua is not, it targets C not C++) you'll get a different API and a
different language.

I undestand C++ coders are using Lua, but Lua should target C coders,
not C++ one!


email: basile<at>starynkevitch<dot>net
alias: basile<at>tunes<dot>org
8, rue de la Faïencerie, 92340 Bourg La Reine, France