[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Suggestion: file:write() and other methods should return file
- From: Tony Finch <dot@...>
- Date: Mon, 4 Jul 2011 17:32:37 +0100
Javier Guerra Giraldez <javier@guerrag.com> wrote:
> On Sat, Jul 2, 2011 at 10:11 AM, Mark Hamburg <mark@grubmah.com> wrote:
> >
> > io.open( 'foo', 'a+' ):write('fooo'):close():assert()
>
> very interesting. i'd chose to have a single error class, that
> returns self on _every_ function except :err(), that returns nil,error
> and :assert() that fails
>
> is that style common in any language/library you know?
It's pretty straightforward to do this with Haskell. There's a trivial
implementation of the "maybe monad" in the standard prelude, which either
succeeds with a value or fails with nothing - which is a bit feeble as
error indicators go, but it gives you the idea.
Tony.
--
f.anthony.n.finch <dot@dotat.at> http://dotat.at/
South Utsire, East Forties: Northerly 5 or 6, becoming variable 4 later.
Moderate becoming slight. Mainly fair. Moderate or good.