Go provides this functionality using interfaces.

brucee

On 5 May 2017 at 03:52, Giacomo Tesio <giacomo@tesio.it> wrote:
Nice idea. What do you have in mind instead of file descriptor?

What about returning the current function from Biofn to allow filters'
composition?


Giacomo

2017-05-04 18:23 GMT+02:00 Benjamin Purcell <benjapurcell@gmail.com>:
> I love it
>
> spew
>
> On Thu, May 4, 2017 at 11:02 AM, Julius Schmidt <aiju@phicode.de> wrote:
>> I would like to change bio to do all I/O through a user replaceable
>> function. The attached patch does just that, adding a new function Biofn()
>> to register such a function, which replaces read/write.
>>
>> Main uses I have in mind:
>>
>> 1. Allow programs to flush output buffers before stalling for more input,
>> which would most likely be activated with a command line flag.
>>
>> 2. Use bio with things that are not file descriptors.
>>
>> 3. Apply filters to input/outputs (arguably could also be done with pipes).
>>
>> 4. Use bio with ioprocs.