{"id":20135848,"url":"https://github.com/hcarty/ppx_defer","last_synced_at":"2025-04-09T17:33:36.269Z","repository":{"id":3940549,"uuid":"51452548","full_name":"hcarty/ppx_defer","owner":"hcarty","description":"OCaml extension for a Go-ish [%defer ...] syntax ","archived":false,"fork":false,"pushed_at":"2022-05-30T16:50:54.000Z","size":36,"stargazers_count":16,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T09:51:57.504Z","etag":null,"topics":["ocaml","ocaml-extension","ppx"],"latest_commit_sha":null,"homepage":null,"language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hcarty.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-10T16:08:51.000Z","updated_at":"2024-11-04T23:36:56.000Z","dependencies_parsed_at":"2022-08-28T08:03:49.804Z","dependency_job_id":null,"html_url":"https://github.com/hcarty/ppx_defer","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcarty%2Fppx_defer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcarty%2Fppx_defer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcarty%2Fppx_defer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hcarty%2Fppx_defer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hcarty","download_url":"https://codeload.github.com/hcarty/ppx_defer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248077686,"owners_count":21044008,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ocaml","ocaml-extension","ppx"],"created_at":"2024-11-13T21:16:44.203Z","updated_at":"2025-04-09T17:33:35.416Z","avatar_url":"https://github.com/hcarty.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ppx_defer - Go-like `[%defer later]; now` syntax.\n\n![Build status](https://github.com/hcarty/ppx_defer/workflows/Build%20and%20test%20ppx_defer/badge.svg)\n\nThis is an OCaml language extension implementing a somewhat Go-ish\n`[%defer expr1]; expr2` which will defer the evaluation of `expr1` until after\n`expr2`.  `expr1` will still be evaluated if `expr2` raises an exception.\n\nIf you are using Lwt you can use `[%defer.lwt expr1]; expr2`.\n\nThanks to Drup for guidance in figuring out ppx details!\n\n## Using ppx_defer\n\nAs a simple example this code\n```ocaml\nlet () =\n  [%defer print_endline \"world\"];\n  print_endline \"Hello\"\n```\nwill print\n```\nHello\nworld\n```\nas `print_endline \"world\"` was deferred until after `print_endline \"Hello\"`.\n\nA more common use case would be closing an external resource at the end of the\ncurrent expression.\n```ocaml\nlet () =\n  let ic = open_in_bin \"some_file\" in\n  [%defer close_in ic];\n  let length = in_channel_length ic in\n  let bytes = really_input_string ic length in\n  print_endline bytes\n```\nThis will `close_in ic` at the end of the current expression, even if an\nexception is raised.\n\nSee the `examples/` directory for more examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhcarty%2Fppx_defer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhcarty%2Fppx_defer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhcarty%2Fppx_defer/lists"}