Talk:Lua Programming/Expressions

Strings, long brackets
Article says, "Strings] can be written in Lua by being contained in double quotes, single quotes or long brackets, which were covered before in the section about comments." This is misleading because the phrase "long bracket" as defined by Lua applies only to to a string delimiter yet the term was previously used to describe what Lua defines as the "long comment" delimiter. "Long bracket strings" and "long comments" are two completely different concepts at the semantic level that have only a syntactic similarity (the use of brackets (and equal signs to indicate nesting levels). The two semantic concepts are separated at the syntactic level by the inclusion of two hyphens before both the opening and closing brackets/equal signs for long comments. These two concepts should be discussed separately at the semantic level, although their syntactic similarities might be mentioned parenthetically, as an aid to remembering those similarities. But because the semantics differ, the attempt to refer back to the earlier discussion of "long brackets" that should instead have discussed "long comments," can only produce confusion.

It should also be discussed that strings enclosed by long brackets -- unlike strings enclosed by quotation marks -- are treated by Lua as literal strings, with no escaping of characters required or allowed and with each newline treated as a literal newline. That has both advantages and disadvantages, which is why Lua provides both forms of strings. A reminder reference to this discussion might be added to the Literals section of the article. Marbux (discuss • contribs) 04:00, 10 December 2013 (UTC)


 * I have added notes to make it less confusing. --Mark Otaris (discuss • contribs) 05:03, 18 December 2013 (UTC)

Escaping characters in strings
The "Strings" section contains the following phrase: "an escape character, which will always be a backslash ('\') in Lua ..." This is technically inaccurate. In a pattern string, some characters are escaped using the percent sign "$". Pattern strings must at times include both types of escape characters. Marbux (discuss • contribs) 04:00, 10 December 2013 (UTC)
 * This is not the same kind of escaping; escape characters mentioned here are only for making it possible to include in a string characters that would not otherwise be considered part of the string. However, because the same term is used, although in a different context, it is indeed probable that readers could be confused, so I have added a note here about it, and it may be a good idea to add a remind in the section about patterns (when that section is added). --Mark Otaris (discuss • contribs) 05:09, 18 December 2013 (UTC)

Booleans
Includes the statement, "This is literally written in Lua as 'true' or 'false', which are reserved keywords." The boolean values should be written with code tags rather than surrounded by quotation marks, which can lead to confusion. The values are not strings and are not written in or by Lua as strings, so should have no quotation marks. Marbux (discuss • contribs) 04:00, 10 December 2013 (UTC)
 * I corrected that mistake. I must've been distracted when writing that part. --Mark Otaris (discuss • contribs) 05:10, 18 December 2013 (UTC)

Mathematical statements
In the section Types you state: "In fact, one of the main difference between mathematics and computer science is that programming languages have statements and expressions, while mathematics only have expressions." I do not agree. Mathematics consists also of statements with expressions; there is no difference in this regard. See also the simple example in the second paragraph in. --Johnwayne1986 (discuss • contribs) 15:43, 6 August 2015 (UTC)
 * Absolutely. Expressions that have a truth value in mathematical notation (propositions… anything that can imply something else or that a probability can be given to) can be called statements when asserted (when you say that $$\forall n\;(Q(n) \Rightarrow P(n))$$, or even that $$2+2=4$$, you're making a statement). That doesn't have much in common with the statements we use in programming languages, but the claim was silly and not very relevant anyway so I have removed it. --Mark Otaris (discuss • contribs) 07:56, 21 August 2015 (UTC)

Relational operators missing
I miss the relational operators in the Booleans section. Something like "The relational operators,  ,  ,  ,  ,   return always   or  ." would be enough, since the meaning should be clear, but the type is remarkable. --Johnwayne1986 (discuss • contribs) 16:30, 6 August 2015 (UTC)
 * They're surely worth mentioning in the section about booleans, since they always return boolean values. Thank you for the feedback! --Mark Otaris (discuss • contribs) 08:06, 21 August 2015 (UTC)