Mel Wilson | 1 Jul 03:23 2008

Re: LUA Vs Javascript

Eric Tetz wrote:
> Stephen Kellette wrote:
>> Much as I like Lua, the purist/stripped down nature of it means that I think
>> it will be forever a specialist niche language
> 
> That's the *point* of Lua.
> 
> It's designed to be an extension language, and one of it's stated goal
> is to "be small, and have a small implementation.  Otherwise, the cost
> of adding the library to an application may be too high".  Ruby,
> Python, Perl, Javascript, etc. don't have that constraint.

My own use for Lua is to let people write plug-ins to run in the 
soft-real-time core of a computerized musical instrument.  If I find 
that Lua is delaying processing my events while it cobbles up names 
for its own data structures -- names that no-one should ever care 
about -- I will become depressed.

	Mel.

Leo Razoumov | 1 Jul 06:01 2008
Picon

Re: BUG in table.concat

On 6/28/08, Petite Abeille <petite.abeille <at> gmail.com> wrote:
>
>  On Jun 29, 2008, at 12:54 AM, Leo Razoumov wrote:
> > The last example also has 2 holes (t[2],t[4]) but it works.
>
>  ipairs "will iterate over the pairs (1,t[1]), (2,t[2]), ···, up to the
> first integer key absent from the table."
>
>  http://www.lua.org/manual/5.1/manual.html#pdf-ipairs

My problem is with "table.concat" and _not_ with ipairs.
Reading carefully your reply I still cannot figure it out while one
hole breaks table.concat but two holes work fine.

Finally, nil values are not stored in a table. According to the
reference manual assigning t[k]=nil clears the t[k] value.

>  "Don't claim that you have found a bug"
>  -- Eric Steven Raymond, "How To Ask Questions The Smart Way", 2001
> http://www.catb.org/~esr/faqs/smart-questions.html#id306810
>

It is either a bug in Lua implementation or a bug in Lua documentation.

--Leo--

David Manura | 1 Jul 06:23 2008

Re: checking lua using gimpel pc-lint

Roberto Ierusalimschy writes:
> > (2)
> >  int error = GetLastError();...
> > GetLastError returns instead a DWORD type, which is normally used[2].
> > Internally, DWORD is a "typedef unsigned long DWORD;" in windef.h
> > despite what the MSDN docs[3] say.
> 
> Should we declare error as DWORD?

It probably really doesn't matter in practice.  The error code gets converted
from unsigned to signed back to unsigned.  Furthermore, I doubt the sign bit is
ever set in practice (for such non-HRESULT error codes as noted in winerror.h
and HRESULT_FROM_WIN32).  It also doesn't generate any compiler warnings.

Here's a few more:

(8)

  if (L) lua_atpanic(L, &panic);
lauxlib.c(649) : Warning 546: Suspicious use of &

  status = lua_cpcall(L, &pmain, &s);
lua.c(387) : Warning 546: Suspicious use of &

"...the use of the & [on a function name] is redundant and could be erroneous."

(9)

Info 759: header declaration for symbol 'luaD_seterrorobj(struct lua_State *,
    int, struct lua_TValue *)' defined at (line 51, file ldo.c) could be moved
(Continue reading)

Kristofer Karlsson | 1 Jul 09:47 2008
Picon

Re: BUG in table.concat

I don't think it's a bug, it says in the manual:
"Given an array where all elements are strings or numbers".
An array in lua implies a continuous list of non-nil values from index 1 and up.

You get the result you get because in the first case, the length of
the table is 1:
> =#{[1]=1, [3]=3,  [5]=4}
1

so it just concatenates between 1 and 1.
In the second example, the length is 4:
> =#{[1]=1, [2]=2, [4]=4}
4

which explains the crash when trying to get the value at index 3.

On Tue, Jul 1, 2008 at 6:01 AM, Leo Razoumov <slonik.az <at> gmail.com> wrote:
> On 6/28/08, Petite Abeille <petite.abeille <at> gmail.com> wrote:
>>
>>  On Jun 29, 2008, at 12:54 AM, Leo Razoumov wrote:
>> > The last example also has 2 holes (t[2],t[4]) but it works.
>>
>>  ipairs "will iterate over the pairs (1,t[1]), (2,t[2]), ···, up to the
>> first integer key absent from the table."
>>
>>  http://www.lua.org/manual/5.1/manual.html#pdf-ipairs
>
> My problem is with "table.concat" and _not_ with ipairs.
> Reading carefully your reply I still cannot figure it out while one
> hole breaks table.concat but two holes work fine.
(Continue reading)

Eric Tetz | 1 Jul 10:06 2008
Picon

Re: BUG in table.concat

Leo Razoumov wrote:
> the following code crashes Lua-5.1.2 and Lua-5.1.3 (luajit)

That's not a crash. If Lua crashed, you would be getting an error
message from the operating system, or perhaps from a runtime library
linked into the Lua executable. What you saw is a graceful script
failure: Lua halted execution of a script because of a runtime error,
and printed a nice error message with a stack trace.

> I still cannot figure it out while one
> hole breaks table.concat but two holes work fine.

Luck?

>From the definition of the length operator:
"If the array has 'holes' (that is, nil values between other non-nil values),
then #t may be any of the indices that directly precedes a nil value"

>From the definition of table.concat:
"returns table[i]..sep..table[i+1] ··· sep..table[j]"
"default for j is the length of the table"

You're not providing 'j', so it ends up being #t. In your first
example, j ended up being 4, so concat failed on table[i+1] (as it
should, given the definition of concat). In your second example, you
got lucky and j ended up being 1.

> It is either a bug in Lua implementation or a bug in Lua documentation.

Neither. You can see from the definition of concat that it requires a
(Continue reading)

Ong hean kuan | 1 Jul 10:41 2008
Picon

include LuaThread to Lua 5.1.3

Hi All:
I have downloaded LuaThread and from the README, it seems that is not for Lua 5.1.3, i can't find
lua/config
lua/src/lib

I can't find also EXTRA_LIBS, DEFS keywords in any of the files.

Can Lua 5.1.3 compiled with LuaThread?


Best Regards,
--
Hean Kuan Ong
http://linux.byexamples.com
http://cc.byexamples.com
http://wordpress.byexamples.com

Philippe Lhoste | 1 Jul 11:02 2008
Picon
Picon

Re: LUA Vs Javascript

On 30/06/2008 23:37, Michal Kolodziejczyk wrote:
> If your users can be "forced" to use a browser with svg support (firefox 
> is OK), I would suggest JavaScript+SVG for browser side

Although I love SVG, the current trend seems to be the use of the Canvas API, which has 
the advantage of being available out of the box in Opera and latest Safari as well.
And JS framework Dojo even allows to use an unified API on Internet Explorer as well 
(using the old VML there).

> For the browser side you could also consider flash (actionscript is 
> similar to JS, but the code runs faster, especially if you have 
> realplayer 10).

Do you mean that RealPlayer made its own Flash player, faster than Adobe one?

> If you want graphical GUI in your browser, there is no better/easier way 
> than svg+JS or flash.

Well, Canvas too, to be complete (just another solution I throw in).
And to be even more complete, we cannot dismiss Java. Hey, something like Processing makes 
graphics in applets dead easy.

--

-- 
Philippe Lhoste
--  (near) Paris -- France
--  http://Phi.Lho.free.fr
--  --  --  --  --  --  --  --  --  --  --  --  --  --

Dr. Markus Walther | 1 Jul 12:30 2008

Secure tables in Lua?

The CTM book p.203ff (online version reachable from Wikipedia p.207ff)

(http://en.wikipedia.org/wiki/Concepts,_Techniques,_and_Models_of_Computer_Programming)

defines secure values, i.e. data structures inaccessible without knowing 
a special key. The goal is to create secure abstract data types (stacks, 
etc.) that protect suitable parts of their internal representations 
(e.g. revealing only access methods).

The CTM proposal has two parts. NewName is an operation that creates a 
unique name that cannot be printed or typed in. Chunks are limited 
records with only the selection operator '.' available.

Now chunks created with such a unique name as selection key can only be 
accessed if you know the key, otherwise throwing an error (and not 
revealing the key).

IMHO the whole CTM approach focussing on minimal extensions to a kernel 
language is very compatible with Lua's philosophy, so I wondered if this 
particular idea could be borrowed.

My question therefore to the list: how would one go about replicating 
this in (extended?) Lua, perhaps first for tables?

My initial thoughts were to use a metatable approach with a new 
write-only field mt.__secure (or perhaps __protected) guarding R/W 
access to protected entries of main table t. mt.__secure would hold the 
key k to unlock t[k] (perhaps generalized to a table of such keys k_i).
A new builtin name() generates fresh keys.

Rawget on t[k] must be impossible if protection is enabled. Perhaps 
type(k) == "name" and print(k) == "name:suppressed" or similar. No 
table-walking with next/(i)pairs etc. can discover k.

This is just to get the discussion started, ideas and feedback welcome!

--Markus

David Jones | 1 Jul 12:59 2008
Picon

Re: LUA Vs Javascript


On 1 Jul 2008, at 10:02, Philippe Lhoste wrote:

> On 30/06/2008 23:37, Michal Kolodziejczyk wrote:
>> If your users can be "forced" to use a browser with svg support  
>> (firefox is OK), I would suggest JavaScript+SVG for browser side
>
> Although I love SVG, the current trend seems to be the use of the  
> Canvas API, which has the advantage of being available out of the  
> box in Opera and latest Safari as well.

That's not an advantage, SVG also works out of the box on Opera and  
Safari.

Canvas _does_ have the advantage of working on the iPod (whereas SVG  
does not, despite being Safari).

drj

Picon

Re: checking lua using gimpel pc-lint

> Info 759: header declaration for symbol 'luaX_tokens' defined at (line 37, file
>     llex.c) could be moved from header to module
> Info 765: external 'luaX_tokens' (line 37, file llex.c) could be made static
> 
> These functions could be made static, though there could be reasons to keep them
> external.

Yes. For instance, luaX_tokens is used by my token filter hack and by my
lstrip.


Gmane