Ben Kelly | 1 Aug 01:44
Picon

Re: [ANN] vstruct - 1.0 beta 2

>> 2008/7/27 Christof Schardt <christof <at> schardt.info>:
>> Ben Kelly wrote:
>>>         What is it?
>>>         Why use it?
>>>         Where is it?
>> I am missing an important question:
>>         How use it?
>>
>> More specific: what do I have to "require" ?
>> I tried "require("init") without success. Also the
>> other files couldn't be "required".
>>
> Peter Cawley wrote:
> Place the files in a directory called vstruct, then use
> require("vstruct") - one of the places that Lua looks when you do
> require(name) is name/init.lua
>

I'll expand that part of the mail/README for the next release.
	Ben

Ben Kelly | 1 Aug 01:46
Picon

Re: [ANN] vstruct - 1.0 beta 2

Jerome Vuarand wrote:
> 2008/7/25 Ben Kelly <ranavin <at> gmail.com>:
>>> The tricky module-mechanism is not easy to
>>> understand. I mean things like this
>>>
>>>      local name = (...):gsub('%.[^%.]+$', '')
>>>      local read = require (name..".read")
>>>
>>> and similar lines.
>> I'm not actually entirely happy with that; it feels ugly and slightly
>> hackish. I have yet to come up with a better way, though.
> 
> The standard 'module' function does that work. You can replace:
> 
> local name = (...):gsub('%.[^%.]+$', '')
> local read = require (name..".read")
> local write = require (name..".write")
> local compile = {}
> 
> with:
> 
> module(..., package.seeall)
> local read = require (_PACKAGE.."read")
> local write = require (_PACKAGE.."write")
> local compile = _M

The problem is that I want the submodules to be entirely local to the
module; end users shouldn't be able to see struct.read/struct.write
without explicitly requiring it. Using module() means going out and
clearing away the extra table entries it creates first.
(Continue reading)

David Manura | 1 Aug 02:09
Favicon

Re: FAQ? combining all modules into a single bytecode file

Christian Lindig writes:
> On Jul 31, 2008, at 1:42 PM, Jerome Vuarand wrote:
> > You can try the following script to generate a bytecode file of all
> > the listed modules (see the beginning of the script). Then in your
> > final program, just call dofile("preload.lbc") before using (through
> > 'require' as usual) any of your modules.
> 
> Thanks for this idea. Wouldn't it make sense to implement this in  
> luac as an option? ...

Check out Pre-Loader, which was announced on this list a few weeks ago:

  http://loop.luaforge.net/release/preload.html
  http://lua-users.org/lists/lua-l/2008-07/msg00195.html
  http://lua-users.org/wiki/BinToCee

David Manura | 1 Aug 02:27
Favicon

Re: How to count the number of lines in a string?

Luiz Henrique de Figueiredo writes:
> > ...
> > local n = select(2, s:gsub("[^\n]*\n[^\n]*", ""))
> Or this:
> 	local _,n = s:gsub('.-\n', '')

May be less memory efficient but terser:

      return # s:gsub("[^\n]", "")

The general form can answer queries such as, "How many characters in a given set
are in a string?"

Ben Kelly | 1 Aug 04:42
Picon

Re: Determine if function is defined with C API?

>>> How would I do something like this?  From lua_pcall, I get a return
>>> value of 2 but is this defined somewhere?  Should I just check for
>>> that value or is there a preferred constant?
> 
> This requires the function be on the stack and that you know the index,
> though.
> 
If he's in a position to use pcall on it, it's already on stack and thus
using lua_isfunction() is entirely reasonable, no?
	Ben

Picon

Determine if function is defined with C API?

Ben Kelly wrote:
>>>> How would I do something like this?  From lua_pcall, I get a return
>>>> value of 2 but is this defined somewhere?  Should I just check for
>>>> that value or is there a preferred constant?
>> 
>> This requires the function be on the stack and that you know the
>> index, though. 
>> 
> If he's in a position to use pcall on it, it's already on stack and
> thus using lua_isfunction() is entirely reasonable, no?
> 	Ben

I took the "return value of 2" to mean lua_pcall returned 2 (which I believe
is LUA_ERRRUN) so perhaps the function is not on the stack? Simply pushing
some random things onto the stack (none of which are functions) and then
calling lua_pcall will give you a return value of 2. It could be the
function is on the stack but the number of arguments (nargs) supplied to
lua_pcall is incorrect. I think further details from Joey are needed.

David Manura | 1 Aug 06:36
Favicon

[ANN] lua2c 0.2 - a Lua-to-C translator

This is to announce the first milestone release of lua2c.

lua2c converts a given Lua 5.1 source file into an equivalent C source file
written in terms of Lua C API calls.  It passes most of the Lua 5.1 test suite
(except for a few unimplemented features, mainly coroutines) and even compiles
itself.  Current performance is about 25%-75% of regular Lua, though future
versions might improve that via optimizations.  It is written entirely in Lua. 
One possible application is to allow seamless inlining of C code inside Lua
code, since Lua is converted to C, but you may find other novel uses, which I'd
like to hear about.

For further details see http://lua-users.org/wiki/LuaToCee .

Steve Donovan | 1 Aug 08:48
Picon

Re: New version of lconsole available

Any error messages, or did it fail silently?  If so, then run lconsole.wlua 
from a command prompt using lua.exe, then you'll see actual error messages 
;)  I really should do something about the 'silent error' thing!

Things to check out for:
 - is CRForm.lua, CLRPackage.lua in lualibs?
- is luanet.dll, LuaInterface.dll in clibs?

steve d.

----- Original Message ----- 
From: Mike Crowe
To: Lua list
Sent: Thursday, July 31, 2008 3:33 PM
Subject: Re: New version of lconsole available

Hey folks,

I gave a very cursory effort to trying to run this with the new Lua for 
Windows system (http://luaforwindows.luaforge.net/).  Seems like we are 
missing something to run this?  Or did I just botch it?

Mike

On Thu, Jul 31, 2008 at 9:08 AM, steve donovan <steve.j.donovan <at> gmail.com> 
wrote:

On Thu, Jul 31, 2008 at 2:53 PM, Andrew Wilson <agrwagrw <at> gmail.com> wrote:
> My default browser was IE and it was real slow to startup, on the
> order of tens of seconds maybe even a minute. AGRW
(Continue reading)

Tony Finch | 1 Aug 14:00
Picon
Favicon

Re: FAQ? combining all modules into a single bytecode file

On Thu, 31 Jul 2008, Christian Lindig wrote:
>
> Today, luac compiles multiple modules by prepending code that calls each
> chunk (i.e. module). As a consequence, embedded 'requires' are executed
> before all modules are executed. Is this behavior still useful in the
> presence of 'module' and 'require'?

It works OK for me if I present the modules to luac sorted so that all
require calls occur after the corresponding module call.

Tony.
--

-- 
f.anthony.n.finch  <dot <at> dotat.at>  http://dotat.at/
BISCAY: SOUTHWESTERLY 5 OR 6, OCCASIONALLY 7 LATER. ROUGH. RAIN OR SHOWERS.
MODERATE OR GOOD.

Jerome Vuarand | 1 Aug 14:54
Picon
Gravatar

Re: FAQ? combining all modules into a single bytecode file

2008/8/1 Tony Finch <dot <at> dotat.at>:
> On Thu, 31 Jul 2008, Christian Lindig wrote:
>>
>> Today, luac compiles multiple modules by prepending code that calls each
>> chunk (i.e. module). As a consequence, embedded 'requires' are executed
>> before all modules are executed. Is this behavior still useful in the
>> presence of 'module' and 'require'?
>
> It works OK for me if I present the modules to luac sorted so that all
> require calls occur after the corresponding module call.

That's why it's easier to only preload the modules. You can preload
them in any order, the actual loading will happen when necessary, when
first 'require'd.


Gmane