Thijs Schreijer | 25 May 2013 22:51
Picon
Gravatar

LuaSocket: trouble getting system ip addresses

I'm having trouble getting the systems IP addresses.

On Windows this works;
    socket.dns.toip(socket.dns.gethostname())

On Linux (raspberry pi, Ubuntu 10) it doesn't

Test code:
    local socket = require("socket")

    function one(name)
      print('=========='..name..'===========')
      local ip, v = socket.dns.toip(name)
      print('name',v.name,ip)
      print('alias')
      for k,v in pairs(v.alias) do
        print('',k,v)
      end
      print('address')
      for k,v in pairs(v.ip) do
        print('',k,v)
      end
      print('====================================')
    end

    one('localhost')
    one(socket.dns.gethostname())

It delivers:
    pi <at> raspberrypi ~ $ lua listaddr.lua
(Continue reading)

Dirk Laurie | 25 May 2013 06:59
Picon

[ANN] Brief introduction to LPEG (was: LPEG for dummies)

2013/5/1 Dirk Laurie <dirk.laurie <at> gmail.com>:

> I've written the attached. Any comments that will lead
> to the last sentence in it becoming less painful will
> be greatly appreciated.

That paragraph refers to "Brief introduction to LPEG" which is in

   https://github.com/dlaurie/lua-notes

>From the preamble:

- Writing a topic up for oneself is one of the best ways of learning it.
- Once you have learnt it, you can never recapture the difficulty you
  had in understanding the original.
- I promise not to re-work these notes to elegance when I know the
  material well. I will add stuff and correct errors, though. Thanks
  to members of the Lua list for helping me here, particularly
  Pierre-Yves Gérardy.

I have already reached the point where I can't add to notes based
on that philosophy any more, so this is the final version except for
the correction of mistakes.

Pierre-Yves Gérardy | 25 May 2013 00:26
Picon
Gravatar

table.unpack question.

In Lua 5.1 and LuaJIT, `unpack()` accepts tables of up to 8000 elements.

Lua 5.2 lifts this limit for `table.unpack()`, but the maximum size
varies according to the circumstance.

In my test case, it works up to 999970 in the REPL, and 999977 from a script.

Is there a any guaranteed safe size?

-- Pierre-Yves

Luiz Henrique de Figueiredo | 24 May 2013 13:20
Picon

100000+ messages posted

At some point in the last weeks the 100000th message was posted to lua-l.
The traffic statistics are at http://www.lua.org/lua-l-stats.html .

Surprisingly for a list of its size and age, the signal-to-noise ratio
remains quite high, despite a few dips. That the list is so successful
is mainly due to those who generously share their expertise with the
whole Lua community.

I trust we can keep lua-l friendly and welcoming, and full of good advice.
On behalf of the Lua team, I thank you all for joining and helping others.

As we have said in the HOPL paper, the list has become the focal point of
the Lua community and it has been a source of motivation for improving Lua.

--lhf

Vaughan McAlley | 24 May 2013 07:29
Picon

Help with an algorithm

Greetings,

Sorry if this is more suited to a general programming forum—I hope the solution will be in Lua, and there are some pretty switched on people here...

I’d like to iterate through all 40-bit binary numbers that have a Hamming weight of 25 (ie. 25 of the bits are set to 1). My naive solution of testing the Hamming weight of all 40-bit numbers looks like it will take half a year :-) , even with a fairly quick calculation of Hamming weight using 14-bit lookup tables...

An alternative could use something like this:

num = {}

for i = 1, 15 do num[i] = "0" end
for i = 16, 40 do num[i] = "1" end

n = tonumber(table.concat(num), 2)  -- test n

Is there an efficient way of iterating through all combinations of "0" and "1" in num?

Thank you,
Vaughan

Bernd Eggink | 23 May 2013 20:00
Picon

ldoc documentation?

Is there a documentation of ldoc somewhere? I mean, something more 
thorough than what ldoc -h outputs?

One question I can't answer at the moment is the following: In a 
directory containing a set of related sources, is there a way to 
automatically generate an index.html which assembles links to all the 
other html files?

Thanks in advance,
Bernd

--

-- 
http://sudrala.de

Satz Klauer | 23 May 2013 15:28

Hand over global userdata to LUA-called C-function

Hi,

I have a pointer to some user data available during initialisation,
means before the LUA-script is started. This pointer has to be
available during execution of the script, since it is a multithreaded,
explicitely linked shared library environment I can't use just a
global variable that stores these data.

So when a C-function is called out of a running LUA-script I need to
access these user data. Since the C-function is always defined as

int my_lua_called_c_fct(lua_State *L)

there seems to be "L" where I could get these user data from. But how
can I put the data to "L" during initialisation and how can I retrieve
them within that function?

These are some configuration-data that are required to execute
my_lua_called_c_fct()...

Thanks!

Chris Datfung | 23 May 2013 16:15
Picon

HTML Parser Recommendation

I'm looking for a recommendation for an HTML parser that is supported in both lua 5.1 and 5.2.

Thanks,
Chris
liam mail | 23 May 2013 15:39

Moore Lua

Hello lua-l
I thought it was about time that I mentioned Moore Lua here. Moore Lua is simply a paper.li collection of Lua news stories and releases published weekly on Mondays and is associated with the LuaLang twitter account. Being a simple paper.li account it is sometimes hard if not impossible to add some stories but if releasing on this list with a simple [ANN] prefix as per the norm it will be picked up for the next edition.
I feel it has some worth as it also archives past editions and therefore news and releases.

The current edition always available at

-- Liam

What is in a name?
Moore Lua is named after Sir Patrick Moore who was a Lua expert after all, he passed away shortly before the first edition http://paper.li/LuaLang/1355430802?edition_id=7a0429e0-4846-11e2-a045-002590721286
Pierre Chapuis | 23 May 2013 15:22
Picon
Gravatar

lpeg 0.12

Hello list,

is lpeg 0.12 officially released?

I could find an [ANN] thread for RC2 in the archives but not for the final
version, it is not in LuaRocks, but it appears to be available here:
http://www.inf.puc-rio.br/~roberto/lpeg/lpeg-0.12.tar.gz

Also, can anyone confirm 0.12 fixes this 0.11-related segfault with
luajson? https://github.com/LuaDist/Repository/issues/141

--

-- 
Pierre Chapuis

Gerhard Lipp | 23 May 2013 12:35
Picon

Re: Re: LuaSec with nonblocking sockets

Hi!

Concerning this thread:

http://lua-users.org/lists/lua-l/2013-03/msg00122.html

Setting up a luasec with (non blocking) event loop framework lua-ev
seems to work. I used luasec/sample/want/*.lua as basis and ended up
with 3 files:

server_ev.lua: luasec server non-block
client.lua: normal sync luasec client (with additional sleeps to prove
responsiveness of server_ev)
handshake.lua: normal sync luasec client (with additional sleeps to
prove responsiveness server_ev)

https://gist.github.com/lipp/5635191


Gmane