Talk:Lua (programming language)

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Confusing "Example" in 4.1[edit]

Marked as ambiguous the example from the section on the C API stack:

"Negative indices indicate offsets from the top of the stack (for example, −1 is the last element) ..."

The use of "last" just confused me more. Last added, or last to be removed? Judging from the preceding text, I'd guess it's the former, in which case I suggest this be changed to "for example, -1 is the most recently added element", or even "the last element added". It might also be worth mentioning whether positive indices are zero-indexed (is 0 or 1 the bottom-most element?) — Preceding unsigned comment added by 64.58.7.42 (talk) 18:08, 20 January 2015 (UTC)[reply]

Historic Acronym?[edit]

I know it is explicitly stated on the Lua webpage that it is not an acronym[1], however lua.h in the versions prior to 3.0[2] all seem to have a variation of the following header:

/*

    • LUA - Linguagem para Usuarios de Aplicacao
    • Grupo de Tecnologia em Computacao Grafica
    • TeCGraf - PUC-Rio
    • $Id: lua.h,v 3.32 1996/11/20 13:49:32 roberto Exp $
  • /

Correct me if I'm wrong, but isn't that "Language for Users of Applications"? --97.88.6.36 (talk) 14:21, 5 September 2015 (UTC)[reply]

Hi, yes. Linguagem para Usuários de Aplicação can be translated as "Language for Application Users", but according to this e-mail exchange [3] [4], it was just an internal joke among the Brazilian developers, never meant to become an official acronym. Maybe this could be cited in the article. —capmo (talk) 16:27, 5 September 2015 (UTC)[reply]

Applications[edit]

Why is there a list of things done in Lua? Will it ever be complete? If not, what's it for?

Neither C, Java, Perl nor Ruby have such a list. That lets me think the list is some kind of ego boost, telling everyone how very à la mode the language is.

Let's get rid of the list.-88.198.68.229 (talk) 18:40, 7 September 2015 (UTC)[reply]

Regular expression pattern matching[edit]

Apparently, Lua has a regex-like pattern matching, but they don't use the term "Regular expression"; it looks like they purposefully do so. See http://www.lua.org/manual/5.3/manual.html#6.4.1 --Jerome Potts (talk) 14:48, 10 November 2016 (UTC)[reply]

Strictly, the Lua language does not support regular expressions as a syntactic construct in the way that Perl et al do. The Lua standard String library does include pattern matching functions, but the syntax is a lot more limited than the standard or common PCRE variants. -- TerryE (talk) 18:59, 10 November 2016 (UTC)[reply]
Thanks. It seems to me that an article on a scripting language should indicate whether it supports/uses regexes ; i'm thinking of that as pretty much of a requirement. In this case, a mention of pattern matching should be present, and express whether it is regex-like or not. --Jerome Potts (talk) 21:16, 10 November 2016 (UTC)[reply]

Lead section (too short and errors)[edit]

Content as of now:

Lua (/ˈluːə/ LOO-ə, from Portuguese: lua [ˈlu.(w)ɐ] meaning moon) is a lightweight multi-paradigm programming language designed primarily for embedded systems and clients.[1] Lua is cross-platform, since it is written in ANSI C,[2] and has a relatively simple C API.[3]

That is unarguably wrong, Lua is not designed primarily for embedded systems. Depending on which source is referenced, it is a general purpose [2] or a scripting [1] language originally [2] / primarily [1] designed as an embeddable language (though it is also very suitable as an interpreted language for embedded systems due to its very low footprint).

Maybe someone can help me flesh this out to adhere with WP policies?

Also I don't really understand why it should be too short though, I compared with other pages about programming languages and their lead sections are often even shorter.

Cleartrain (talk) 14:07, 14 June 2017 (UTC)[reply]

My vague recollection from reading some of Ierusalimschy's early documentation a long time ago was that Lua was designed for embedded systems. I see that the second paragraph ("extending software applications") somewhat contradicts the first ("embedded systems"). However, the article should be based on reliable sources. Per WP:LEAD, the lead should be a brief summary of key points that follow in the article. What else would you think should be in the lead? Johnuniq (talk) 01:48, 15 June 2017 (UTC)[reply]

Wary of what appears to be self advertising[edit]

I have just removed a new reference:

  • Mitchell (2017). Lua Quick Reference. foicica.com. ISBN 978-0-9912379-3-7.

that was added by an anonymous user (IP:71.62.73.129) at the head of the reference list. I've had a look at the contents and it seems to add nothing more than PiL, and I have been unable to find any independent references to it or decent reviews, and I suspect that this is simply an attempt at self-advertising by the author.

At the same time, it seems that the de facto primary Lua reference written by Lua's principle author, Ierusalimschy's PiL, is buried half-way down the list, so I've hoisted it to the top. TerryE (talk) 10:32, 16 July 2017 (UTC)[reply]

Can embedding Lisp-like code?[edit]

e.g.:

  quote(string)                     -> "string"
  quote(quote(expr))                -> "quote(expr)"
  quote(quasiquote(expr))           -> "quasiquote(expr)"
  quote(quasiquote(unquote(expr)))  -> "quasiquote(unquote(expr))"
  quote(unquote(expr))              -> "unquote(expr)"
  quasiquote(string)                -> "string"
  quasiquote(quote(expr))           -> "quote(expr)"
  quasiquote(quasiquote(expr))      -> "quasiquote(expr)"
  quasiquote(unquote(expr))         -> expr

Incorrect example in 2.1[edit]

The factorial example doesn't handle factorial(0) or factorial(1) correctly. The factorial example at lua.org would be a better alternative.

   -- defines a factorial function
   function fact (n)
     if n == 0 then
       return 1
     else
       return n * fact(n-1)
     end
   end

Followed by an example of its use:

   print("enter a number:")
   a = io.read("*number")        -- read a number
   print(fact(a))

https://www.lua.org/pil/1.html — Preceding unsigned comment added by 2601:500:8500:9221:E9B3:E4D8:940C:6B81 (talk) 21:15, 10 December 2017 (UTC)[reply]

Embedded systems vs. embedded programming language[edit]

The lede in the article seems to claim that Lua was designed for embedded systems, while the source provided instead claims that the language was designed to be an embedded programming language. That's a huge difference, and it seems to me that the Wikipedia is in grave error here. Embedded systems are computers with very little memory and a low computing power that are embedded into larger systems. Embedded programming languages are interpreters embedded into compiling programming languages in order to add a configurability to the program written. Rursus dixit. (mbork3!) 13:18, 11 December 2017 (UTC)[reply]

External links modified[edit]

Hello fellow Wikipedians,

I have just modified one external link on Lua (programming language). Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:

When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.

This message was posted before February 2018. After February 2018, "External links modified" talk page sections are no longer generated or monitored by InternetArchiveBot. No special action is required regarding these talk page notices, other than regular verification using the archive tool instructions below. Editors have permission to delete these "External links modified" talk page sections if they want to de-clutter talk pages, but see the RfC before doing mass systematic removals. This message is updated dynamically through the template {{source check}} (last update: 18 January 2022).

  • If you have discovered URLs which were erroneously considered dead by the bot, you can report them with this tool.
  • If you found an error with any archives or the URLs themselves, you can fix them with this tool.

Cheers.—InternetArchiveBot (Report bug) 20:32, 7 January 2018 (UTC)[reply]

−3, –3, and -3 are three different things; to wit a minus, an endash, and a hyphen. Dis sayin' ... --Brogo13 (talk) 20:15, 11 February 2020 (UTC)[reply]

I explained the problem, which is unrelated to this article, at my talk. Johnuniq (talk) 23:12, 11 February 2020 (UTC)[reply]
The problem, according to your edit summary, was my script—I have none. I simply found some hyphens masquerading as dashes and some where minus signs would make sense e.g. west longtitudes and south latitudes. (Why they work but minuses don't is still beyond me.) --Brogo13 (talk) 03:12, 12 February 2020 (UTC)[reply]
Template parameters expect numbers to be numbers, for example 12.3 or -12.3 (that's a hyphen which is the universal symbol for a negative number in programming languages). Some code in MediaWiki accepts a minus sign as equivalent to negative but modules (using Lua) do not, not unless the module takes extra steps to convert minus signs to hyphens before interpreting the numbers. Minus signs are typographic symbols for humans. Johnuniq (talk) 03:47, 12 February 2020 (UTC)[reply]

Object oriented programming?[edit]

In 'metatables', we learn that __index is a function that is called __index(self, key) whenever a key is not found.

But in 'object oriented programming', __index is set to Vector itself.

Does this mean that a table *is* a self function that performs lookup? That x['foo'] is the same as x(x, 'foo') ?

203.13.3.90 (talk) 00:54, 21 July 2020 (UTC)[reply]

No it isn't. You can convince yourself of that by using https://www.lua.org/cgi-bin/demo and pasting the following:
x = {}

x['foo'] = 123

print( x['foo'] )

print( x(x, 'foo') )
The first print returns 123 as expected, the second returns an error. A table clearly performs a lookup, but is not a function in the Lua sense. For more information on datatypes, see https://www.lua.org/manual/5.3/manual.html#2 --RexxS (talk) 19:57, 21 July 2020 (UTC)[reply]