lua-users home
lua-l archive

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


It was thus said that the Great Jim once stated:
> 
> but the squirrel author has implemented a "tiny regex lib" in ansi C
> (T-Rex is a minimalistic regular expression library written in ANSI C)
> because he "couldn't find any free regular expression library that wasn't huge
> and bloated, while most of the time he needed just basic functionalities"
> as he wrote on
> http://www.demichelis.net/default.aspx?content=projects&template=projects
> 
> a quick look into the squirrel sources reveals that he has implemented the
> squirrel regex functions in sqstdlib/sqstdrex.cpp (663 lines) in procedural
> c style without use of any c++ stdlib regex helper classes.

  Well, one could wrap those regex functions into a Lua module so it's
available for you to use.

> so does that really bloat and make squirrel BIG in any way ? or is it just
> the usual cheap excuse as in "we cant bloat lua with binary/octal integer
> literals" (which anyone else has of course) but have hex integer literals,
> since it does NOT bloat the language in any way and can't be done with
> tonumber().

  That's for Luis and Roberto to answer.  For me, I never needed to use
octal, and I'm past the need for binary literals (I wouldn't mind them, but
I'm not lamenting their lack).

> i am really tired of always the same lamenting. we would not use lua if we
> had not already written thousands of lines of binding c code (which was a
> very stupid decision we bitterly regret by now). the only reason that
> stopped us from using squirrel in the first place was that is written in
> c++ (with all the dependencies that introduces without any gain). if
> squirrel could be rewritten in c we would use it instantly and port all
> the c binding code to it.

  Why was Lua picked in the first place if you now regret it?  Is is the
fact that Lua doesn't have real regex that makes it suck?  Or are there
other factors that make you regret the choice of Lua?

> the squirrel c api is also much better designed.

  Is this the language described by squirrel-lang.org?  Because if so, the
API seems very close to the Lua API (it downright seems Lua influenced the
design from what I can tell).  What is it about the Lua C API that sucks? 
Or why is the squirrel one better?

  Because from my brief look, they seem very similar.

> > Keep in mind that Lua is written in very portable C (almost all C89,
> > some few parts C99) and its pattern facility is built into the source,
> > so it can be compiled on any system with a barebone C compiler. Lua
> > /can/ be compiled as C++, but it doesn't use any C++ library facility
> > that is not also in a C library.

> well, the usual  lamento. on unix you get posix regex and LOTS of other
> useful functions for FREE by the c lib (which you have to use anyway) or
> as direct syscalls.

  In some respects yes.  In other respects no. On Linux you need to link
with pthreads of you use that; not so on other systems.  On Solaris you need
to link with nt if you want to use the network API (socket(), bind(),
accept(), etc) but no so with other Unix systems.  On Windows, POSIX isn't
part of the C library (although I could be wrong, but I would find it
surprising).
  
> when building via "make linux" (for instance) you know what platform is
> used and what it offers (at least std posix functions). (you can also
> check feature macros if you prefer) so instead of linking against big
> bloated crap like libreadline use what's already in the c lib for FREE.
> 
> that could provide a table "regex" (or "re") that makes use of the c lib's
> extended posix regex (which has to be there as required by the posix std.
> btw: are the c++ std regex classes implemented using this c lib support ?)

  I don't know which Unix you are using, but the ones I've had experience
with never came with regex "for free" (as part of libc).  

> there should be also a table "posix" (or "unix" or just "sys") that
> contains the std posix functions (like chdir, mkdir, setenv and the like)
> and is a metatable of the "os" table.
> 
> that "posix" table should also have the metatable "linux" on Linux which
> should contain Linux-only bindings (similar on freebsd, solaris etc)

  There are Lua modules that provide such functionality but I'm guessing you
want those built into the base Lua distribution.  Roberto and Luis have
different priorities; if you agree with them, use Lua.  If you don't, don't
use Lua.

  -spc