[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: about lposix
- From: Sam Roberts <sroberts@...>
- Date: Tue, 17 Oct 2006 15:50:20 -0700
On Tue, Oct 17, 2006 at 02:47:50PM -0700, Mark Edgar wrote:
> Sam Roberts wrote:
> >When I require 'blah' it doesn't matter to me how much of the
> >functionality is implemented in lua, and how much in C, though
> >I do care what apis I get.
> >
> >Both are trivially implementable in terms of each other:
>
> Exporting the two simple C functions is the more primitive interface,
> compared to exporting a table/userdatum with a metatable and two
> metamethods.
Let me try to be more clear, because we aren't even having the same
conversation.
I do not suggest that any particular code be written in C, or in lua.
Thats an architectural problem for the (hypothetical) library
implementor, and perhaps they will do it as you wish.
I do suggest that by the time the (hopefully) high-level API is achieved
(through some combination of lua and C code, one presumes), that a
table-like API is more graceful to use for accessing the environment.
Its a personal preference. The environment is a table/hash-like
structure in perl, ruby, and php (and probably an assoc in scheme), and
I'd be happy to see lua go the same way.
Also, I suggest that it is useful to iterate ones own environment, and
that only two simple functions are insufficient for this.
> It's difficult to imagine what "/*.c" would do on a Windows system. Not
I have no difficulty imagining, possibly because I have programmed in a
language where glob does in fact work on both unix and windows:
http://www.ruby-doc.org/core/classes/Dir.html#M000835
The / is translated to the local system conventions by the library,
insulating the caller from that particular system variation. Using /
as the standard directory seperator also avoids the problem that in
ruby, lua, and several other languages, the \ character is an escape
character in strings, so it has to be escaped to use as a directory
seperator if OS-specific conventions are used on windows:
f = io.open"dir\\file.txt" -- yuck!
Cheers,
Sam