Talk:Lua (programming language)
This is the talk page for discussing improvements to the Lua (programming language) article. This is not a forum for general discussion of the article's subject. |
Article policies
|
Find sources: Google (books · news · scholar · free images · WP refs) · FENS · JSTOR · TWL |
Archives: Index, 1, 2Auto-archiving period: 12 months |
This level-5 vital article is rated C-class on Wikipedia's content assessment scale. It is of interest to multiple WikiProjects. | |||||||||||||||||||||||||||||||||||||||||||||||
|
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
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)
- 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)
Not strongly typed
[edit]Info box says in "Typing discipline", "strong", but that is not true.
Similar to PHP or JavaScript, (and probably Perl and AWK), Lua has is weakly typed especially in arithmetic, i.e. "10" + 1 is allowed and result is integer 11 (technically number 11.0). Same with "5.5" * "2", is integer 11. On the other hand indexing into a "array" (table), t["1"] and t[1] are different (but t[0+"1"] and t[1] are same).
Some people argue that that is still strong typing, because for string concatenation one would use ".." in Lua. But that is not good enough argument. For example Wikipedia says C is weakly typed, but arguably Lua has even weaker type system, due to above mentioned value coercion in arithmetic, which does not happen in C. 81.6.34.169 (talk) 01:32, 1 September 2024 (UTC)
Problems with "Inheritance" section
[edit]The "Inheritance" subcategory in the article is written and phrased in a way that could easily lead a reader to believe believe features such as multiple inheritance are features built into the Lua language. However, the technique is a pattern implemented using metatables, not a language feature.
While the "Object-oriented programming" category above does indeed explain that Lua doesn't have a built-in concept of classes, the addition of the class inheritance section below it seems to deviate from that tone, and it describes a niche pattern that is rarely used; it feels like somebody wrote their own little pet program in Lua and added it to the article masquerading as a feature. 24.68.84.200 (talk) 07:17, 29 September 2024 (UTC)
- C-Class level-5 vital articles
- Wikipedia level-5 vital articles in Technology
- C-Class vital articles in Technology
- C-Class Brazil articles
- Low-importance Brazil articles
- C-Class education and science in Brazil articles
- Low-importance education and science in Brazil articles
- Education and science in Brazil task force articles
- WikiProject Brazil articles
- C-Class Computer science articles
- Mid-importance Computer science articles
- WikiProject Computer science articles
- C-Class Computing articles
- Mid-importance Computing articles
- C-Class software articles
- Unknown-importance software articles
- C-Class software articles of Unknown-importance
- All Software articles
- C-Class Free and open-source software articles
- Mid-importance Free and open-source software articles
- C-Class Free and open-source software articles of Mid-importance
- All Free and open-source software articles
- All Computing articles