lua-users home
lua-l archive

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


>    I've read Mr. Graham's article and found it quite enlightening. 
> I've waded a bit through the world of LISP, but I'm sure we have 
> quite a lot of people in the list who understand fully the language's 
> features and might provide us with a better comparison than the one I 
> might conceivably furnish.

I studied LISP in university and even got to the point where I understood that you 
could write self generated code in it.  But the braces really got to me.  Ergo, I am 
looking at Lua right now in the hopes that its as powerful as LISP, since I prefer 
the Lua syntax.  For now, I am just doing this for my own amusement, since I was 
recommended this language some years ago.

>    However, to try to answer your question: lua programs can execute 
> lua code that's built on run-time. Look for dostring(). I'm not sure 
> if that's enough to parallel "macro" capability, but my guess would 
> be it is.

That appears to do it!  One thing I could not quite trace through it how you convert 
from Lua strings to C strings.  The \000 issue is a bit weird though.  I mean 
dostring which takes a Lua string argument eventually calls lua_dostring with a C 
string (char *) argument.  Walking through your conversions a little, I was 
expecting some conversion of the encountered \000's to something, or just rejecting 
conversions if a \000 was encountered, however when I drilled into it, it looks like 
the path is just:

    luaL_check_lstr ->
    lua_tostring ->
    svalue ->
    o->value.ts.str -> which is a char[]

without any scanning or searching or analysis about whether or not there is \000 in 
there.  Furthermore, the string length from the Lua string does not seem to have 
been explicitely injected as part of the conversion, so can I take this to mean that 
Lua strings are actually internally always auto-terminated with a \000?  Should I 
also then take it that conversion from Lua strings to C strings just terminate 
either at the first \000 or the length of the Lua string, whichever comes first?
 
>    I do recommend Paul Graham's article, referenced below, as good 
> reading for any programmer -- particularly one that hasn't learned 
> any new languages in the last year or so. :)

Yes, if you don't mind the "anecdotal evidence==proof" style of argument.  :o)  Its 
a good read, though, for people interested in start ups or the LISP language.
 
> (BTW: how do you think we could rate 'Befunge' (a bi-directional 
> language) in the lattice? And please don't get me started on the 
> n-directional variations... ;) )

That depends ... what does "Befunge", and "bi/n-directional language" mean?  :o)


--
Paul Hsieh
qed@pobox.com