hhvm / hsl-experimental

Experimental features for the Hack Standard Library
MIT License
23 stars 10 forks source link

Remove disposable interfaces, disposable-first approach. #130

Closed fredemmott closed 4 years ago

fredemmott commented 4 years ago

Discussed when removing buffered operations like readLine; we're going to be replacing those with a BufferedReader($handle) class or similar, so composition is going to be a key part of usage. Composition with disposables is banned, so make the API match the common case.

The short version of that discussion is that combining async with buffered IO is complicated, and a strict layering makes things somewhat clearer and safer.

This also cuts the number of interfaces roughly in half.

Future work (very soon): add a disposable API for autoclose. I'm leaving that for a later PR as that's more bikesheddable.

Some options include:

fredemmott commented 4 years ago

Update was cleaning up grep results for _nd; mostly comments, but pipe_nd() too.

azjezz commented 4 years ago

facebook/hhvm#8604 would be nice now :stuck_out_tongue:

$file = File\open_read_write('file.txt');
defer await $file->closeAsync();
facebook-github-bot commented 4 years ago

@fredemmott merged this pull request in hhvm/hsl-experimental@9fb51de1c96cffba5d2b2bb29fb2604e9c374225.