lua-users home
lua-l archive

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

On Dec 17, 2008, at 2:39 PM, Ralph Hempel wrote:

Mark Hamburg wrote:
The following ideas started with studying LINQ, but LINQ is pretty clearly just a piping model for data together with some useful syntax in C# and VB and ways to delay evaluation long enough to allow for translation into SQL or other mechanisms. I'm not going to address how to get to those latter enhancements but pipes are good as any Unix programmer will tell you and as Diego Nehab demonstrated in LTN 12 ( ). So, here are two proposals for how to add pipes to Lua's syntax:

Is this significantly different from the coroutine example in
the PiL book  <> that goes
something like:

consumer( filter ( producer() ) )

Don't get me wrong, I like pipes, I'm just not seeing how
the piping you're proposing is anything more than syntactic
sugar for the above code...

It is just syntactic sugar. The point is that without the sugar, the pipe idiom becomes fairly difficult to follow fairly quickly. That's also why I don't particularly like the Haskell inspired approach (my option 2) which would basically turn the above into:

	consumer $ filter $ producer()

On the other hand, I think there is clarity to be gained from:

	producer() >> filter >> consumer

You can read the code left-to-right instead of inside-out and understand what it does.