[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: luasocket: inheritance
- From: William Trenker <wtrenker@...>
- Date: Wed, 1 Jun 2005 18:55:35 -0700
First, please excuse me if this has already been discussed.
I have been using compat-5.1r3 with luasocket-2.0-beta3 with good
results but I have to patch certain luasocket files to get inheritance to
work. I just want to check here if I'm doing this correctly or if
I'm missing something.
Here's a simple example:
lines 66 and 67 in mime.lua are:
mime.wrapt['base64'] = wrapt['text']
mime.wrapt['default'] = wrapt['text']
I'm assuming that the right-hand-side is supposed to reference wrapt in lmime which is imported in line 13 as:
local mime = require("lmime")
But when I try to bring mime.lua into lua, it can't find wrapt in the global namespace, like this:
Lua 5.0.2 Copyright (C) 1994-2004 Tecgraf, PUC-Rio
> local mime = require"mime"
/usr/share/lua/packages/mime.lua:66: attempt to index global `wrapt' (a nil value)
stack traceback:
/usr/share/lua/packages/mime.lua:66: in main chunk
/usr/share/lua/packages/compat-5.1.lua:180: in function `require'
stdin:1: in main chunk
[C]: ?
Of course, if I patch mime.lua like this everything works fine:
mime.wrapt['base64'] = lmime.wrapt['text']
mime.wrapt['default'] = lmime.wrapt['text']
The same sort of thing seems to be the case in the http.lua
module. It refers to functions in the socket module (eg:
socket.protect in line 257) but those lower-level lsocket functions are
undefined in the higher-level socket.http module that is referenced in
http.lua. Again, some patches here and there solve the
problem. But is this just a matter of patching bugs or am I
missing something? Are
the low-level socket functions (i.e. lsocket) supposed to be
automatically added into
the namespace of the higher-level socket module (socket.http)?
Thanks again for the helpful advice I've received here.
Cheers,
Bill Trenker
Kelowna BC Canada