[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Apache Portable Runtime
- From: Peter Odding <xolox@...>
- Date: Tue, 13 Mar 2007 23:50:22 +0100
Hi all! (again)
I'm writing a binding to the Apache Portable Runtime[1] for Lua. This is
my first real C module for Lua and I've run into some `idiom
mismatches', so I want to know what other potential users prefer:
*Bitfields*
APR uses bitfield extensively. Some of this functionality is too low
level for Lua, but other stuff I really want to make available. For
example when calling stat[2] some properties (13 total) might be
expensive to retrieve, so they must be explicitly requested with a
bitfield of property flags. Up till now I've used a string where each
character maps to a flag. This is concise but feels obfuscated. The
other option is to let the user create a bitfield from Lua numbers,
which are `constants' my library makes available. This is clear and
readable, but very verbose, and the operators | and + are not really
compatible, i.e. adding the same flag twice basically destroys the
bitfield... Any other suggestions?
*Microseconds*
The `Time Routines' module[3] uses microseconds as it's basic unit of
time. Lua uses the C runtime, which most of the time uses seconds (on
Windows and Linux at least AFAIK). Should my binding convert between the
two, or let users do [T / 1000000] when they want to use os.date or
os.difftime? If my reasoning is correct, the division my library makes
should not lose precision when Lua uses floating point numbers... Right?
Which would you prefer?
Sorry for the long message and thanks for your time,
- Peter
[1] http://apr.apache.org/
[2] http://apr.apache.org/docs/apr/1.2/group__apr__file__stat.html
[3] http://apr.apache.org/docs/apr/1.2/group__apr__time.html