On 1/10/2013 8:23 PM, Thomas Berg wrote:
True, but:
0. I used it as an example of syntax and principles.
1. As I often compile it and if necessary optimize at a high level/use an
external tool I seldom have problems with that. (To where did you port what ?
Curious if z/OS...)
Yes. I ported Lua to z/OS and it's lightening fast. It also supports
multiple paradigms - procedural, OO, prototype, functional etc.
I wrote a RESTFul web server that runs DB2 queries returning JSON
payloads in 50 lines of code.
require "mercury"
luasql = require( "luasql.odbc" )
json = require( "cjson" )
module( "proteus", package.seeall, mercury.application )
-- create the DB2 connection
local env = luasql.odbc()
local con = assert( env:connect() )
local proteus = {}
-- generic query to list arbitrary objects
function proteus.list_query( query )
print(query)
local cur = assert( con:execute( query ) )
local rows = {}
local row = cur:fetch( {}, "a" )
while row do
table.insert( rows, row )
row = cur:fetch( {}, "a" )
end
return rows
end
-- lists proteus objects with filtering
function proteus.list_objects( params )
local query = "select * from " .. params.env .. ".object"
if params.level then
level = params.level:upper()
query = query .. " where level = '" .. level .. "'"
end
if params.objtype ~= "*" then
objtype = params.objtype:upper()
query = query .. " and object_type = '" .. objtype .. "'"
end
return json.encode( proteus.list_query( query ) )
end
-- dispatchers
get( "/proteus/objects/:env/",
function() return proteus.list_objects( params ) end )
get( "/proteus/objects/:env/:level",
function() return proteus.list_objects( params ) end )
get( "/proteus/objects/:env/:level/:objtype",
function()
p.dump(response)
p.dump(params)
return proteus.list_objects( params )
end )
2. I'm not quite sure what you mean. Trying to guess an answer: I use (when
compiled) /*%INCLUDEs when practical and statically include REXX functions when
performance is needed.
Copybooks are one thing, modules are another. Modules allow you to
create instances of objects. BTW, I've got bench-tests that show
compiled REXX can be slower
http://users.tpg.com.au/crayford/rexx-lua-c-io-benchmark.htm.
3. Well, I suppose so, haven't tried that other than a COBOL panel exit to call
a rexx (which of course is a bit different case). BTW, have you an example of
that ?
I wrote a regex package for REXX that simply delegates to the C++ TR1
regex package. It was difficult to do because I had to write assembler
stubs to call CEEPIPI http://users.tpg.com.au/crayford/rexxre.txt.
If anybody is interested in REXX regex let me know. It's alpha status
but more than usable. In contrast, the entire Lua I/O library is a
couple of hundred lines of code wrapping C library calls.
To implement VSAM support was 20 lines.
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN