[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Standard Libraries:
- From: Mark Hamburg <mark@...>
- Date: Mon, 21 Dec 2009 11:17:28 -0800
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:
>
> 1FIRST LINE
> 2SECOND
> ...
>
> 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.
Mark
- References:
- Standard Libraries: (was: and Lua marches on), steve donovan
- Re: Standard Libraries: (was: and Lua marches on), steve donovan
- Re: Standard Libraries: (was: and Lua marches on), Mark Hamburg
- Re: Standard Libraries: (was: and Lua marches on), steve donovan
- Re: Standard Libraries: (was: and Lua marches on), Mark Hamburg
- Re: Standard Libraries: (was: and Lua marches on), steve donovan
- Re: Standard Libraries:, Doug Rogers
- Re: Standard Libraries:, steve donovan
- Re: Standard Libraries:, Mark Hamburg
- Re: Standard Libraries:, steve donovan