lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Aug 3, 2009 at 3:47 PM, Colin wrote:
> On Mon, Aug 3, 2009 at 8:58 PM, Luiz Henrique de wrote:
>>> Regarding the strings as monoid, with the addition as concatenation,
>>> is nowhere near wild, it's wildly normal ;-)
>>
>> Sure. But that does not mean you *need* to use "+" to represent its operation.
>> AWK for instance uses nothing (i.e., juxtaposition), which is the popular
>> practice in formal languages
> ....Presumably there are some other reasons for this design decision.
> Actually, I darkly remember something, let's check... Yes, the
> "Evolution" paper on Lua says "Because the language allows coercion of
> strings to numbers, a + signal would be ambiguous; so, we created the
> syntax .. (two dots) for that operation [concatenation]."

Also should be considered: how to represent repetition.  Formal
languages use "x y^n" or "x (dot) y^n" to represent one x followed by
n y's.  Likewise, Lpeg uses the operator pair  (*,^) for concatenation
and repetition (sort-of), while languages like Python use the operator
pair (+,*).  Lua has no operator suitable for representing n
repetitions via "..".