lua-users home
lua-l archive

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

On Dec 21, 2009, at 12:21 AM, steve donovan wrote:

> seq(io.lines(mypipe)):take(10):upper():enum():map('..'):printall '\n'
> That is, take the first 10 elements, apply the upper() method to all
> elements, convert to a (key,value) sequence, concatenate these values,
> and print out the lines:
> ...
> The interesting operation is the :upper() call, which is equivalent to
> :map(string.upper). The idea is this: if a method is not found in the
> Seq type, then assume that it is a method of the element type. If a
> clear error message is produced in the case when this assumption
> fails, then I can't see the harm in this shortcut.

I've liked that trick as well. It gets used in various promise architectures as well. Send a message to a promise and get a promise for the invocation of the message on the resolved promise.

It does push for making the sequence methods less likely to overlap on namespace. Michael Franz's work in Lagoona on namespaces for messages was interesting in that regard.