{"id":18310591,"url":"https://github.com/eudoxia0/interim","last_synced_at":"2026-01-20T13:34:15.077Z","repository":{"id":146721713,"uuid":"134187591","full_name":"eudoxia0/interim","owner":"eudoxia0","description":"Low-level Lisp with compile-time memory management","archived":false,"fork":false,"pushed_at":"2018-05-26T16:09:00.000Z","size":167,"stargazers_count":274,"open_issues_count":0,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-09T11:51:25.944Z","etag":null,"topics":["compiler","lisp","sml"],"latest_commit_sha":null,"homepage":null,"language":"Standard ML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eudoxia0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-20T21:18:21.000Z","updated_at":"2025-04-06T07:57:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"2f07ecf1-2dd2-49dd-a5c5-c98deab76cab","html_url":"https://github.com/eudoxia0/interim","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/eudoxia0/interim","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eudoxia0%2Finterim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eudoxia0%2Finterim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eudoxia0%2Finterim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eudoxia0%2Finterim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eudoxia0","download_url":"https://codeload.github.com/eudoxia0/interim/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eudoxia0%2Finterim/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28603794,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T12:01:53.233Z","status":"ssl_error","status_checked_at":"2026-01-20T12:01:46.545Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["compiler","lisp","sml"],"created_at":"2024-11-05T16:14:58.009Z","updated_at":"2026-01-20T13:34:15.060Z","avatar_url":"https://github.com/eudoxia0.png","language":"Standard ML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Interim\n\n[![Build Status](https://travis-ci.org/eudoxia0/interim.svg?branch=master)](https://travis-ci.org/eudoxia0/interim)\n\n**Interim** is a statically-typed, low-level dialect of Lisp featuring\ncompile-time, GC-free memory management.\n\nInterim is a technology demonstrator for compile-time memory management\nusing [regions][region-cyclone]. As of 2018, the only major language with\ncompile-time memory management is [Rust][rust], which is notoriously tough to\nlearn. Interim was built to prove that sound, GC-free, compile-time memory\nmanagement can be both simple to implement and easy to learn and use.\n\n## Overview of Regions\n\nMemory safety is achieved by preventing three classes of errors:\n\n- `NULL` pointers\n- Double `free()`\n- Use after `free()` (dangling pointers)\n\nPreventing `NULL` pointers is easy: we use an option type (called `Maybe` in\nHaskell). In the case of Interim, we have a special pointer type called\n`nullable` which represents a pointer which is potentially `NULL`. The `case`\nconstruct can be used to extract a never-`NULL` pointer in a safe way.\n\nPreventing double `free()` and use after `free()` errors is harder, and this is\nwhere regions come in.\n\nConsider this code:\n\n~~~lisp\n(letregion rho\n  (let ((p (allocate rho 10)))\n    (letregion rho'\n      (let ((p' (allocate rho' 12)))\n        nil))))\n~~~\n\nWhat we're doing here is:\n\n1. Defining a region `rho`. Regions are both lexical objects and run-time values.\n2. Defining a variable `p`, whose initial value is the result of allocating the\n   number 10 in the region `rho`.\n\n   An `allocate` call takes a value of type `T` and a region indentifier,\n   allocates enough memory in the region to hold that value, and returns a\n   pointer to it. The result pointer has the type `(nullable T R)`, where `T` is\n   the type of the value we're allocating and `R` is the region identifier.\n\n3. Defining a new region `rho'`.\n4. Defining a new variable `p'`, whose initial value is `(allocate rho' 12)`,\n   that is, the result of allocating the value `12` in the region `rho'`.\n5. Finally, return `nil`.\n\nNow notice what happens if we try to store `p'` in `p`:\n\n~~~lisp\n(letregion rho\n  (let ((p (allocate rho 10)))\n    (letregion rho'\n      (let ((p' (allocate rho' 12)))\n        (\u003c- p p')))))\n~~~\n\nThe compiler will fail with\n\n~~~\nCannot assign to variable 'p': the type of the variable is (nullable i32 rho),\nwhile the type of the expression is (nullable i32 rho')\n~~~\n\nThis is the key to preventing dangling pointer errors: _pointers are tagged with\nthe region they belong to_. A pointer cannot escape its lifetime, to a higher-up\nregion or to a global variable, because the types won't match.\n\nDouble `free()` errors are prevented through a straightforward feature of\nregions: there is no way to do a manual `free()`, and everything in a region is\nfreed automatically when exiting the region's body.\n\n## Examples\n\nFor more examples, look in the `examples/` directory.\n\n### Hello World\n\n~~~lisp\n(defun main () i32\n  (println \"Hello, world!\")\n  0)\n~~~\n\n### Fibonacci\n\n~~~lisp\n(defun fib ((n i32)) i32\n  (if (\u003c n 2)\n      n\n      (+ (fib (- n 1))\n         (fib (- n 2)))))\n\n(defun main () i32\n  (print \"fib(30) = \")\n  (println (fib 30))\n  0)\n~~~\n\nOutput:\n\n~~~\nfib(30) = 832040\n~~~\n\n### Regions\n\n~~~lisp\n(defun main () i32\n  (letregion rho\n    (let ((p (allocate rho 10)))\n      (case p\n        ((not-null p')\n         (print \"Allocated successfully! Value: \")\n         (println (load p'))\n         0)\n        (null\n         (println \"Out of memory!\")\n         -1)))))\n~~~\n\nOutput:\n\n~~~\nAllocated successfully! Value: 10\n~~~\n\n## Building\n\nYou need [MLton][mlton], git and make to build Interim. On Ubuntu:\n\n~~~bash\n$ sudo apt-get install mlton git make\n~~~\n\nThen:\n\n~~~bash\n$ make interim\n~~~\n\nAfter building, try\n\n~~~bash\n$ make examples\n~~~\n\n### Dependencies\n\nThe only dependency is [Parsimony][parsimony], a parser combinator library.\n\n## Design\n\nBeing a technology demonstrator, Interim lacks many features of real languages:\nmodules, macros, higher-order functions, and higher-order types are not\nimplemented since the focus is on region-based memory management.\n\nAs the name implies, Interim is a stepping stone or proof of concept for a\nlarger, more sophisticated language.\n\n## Bibliography\n\n- Grossman, Dan, Greg Morrisett, Trevor Jim, Michael Hicks, Yanling Wang, and\n  James Cheney. [\"Region-based memory management in Cyclone.\"][region-cyclone]\n  ACM Sigplan Notices 37, no. 5 (2002): 282-293.\n\n- Swamy, Nikhil, Michael Hicks, Greg Morrisett, Dan Grossman, and Trevor\n  Jim. [\"Safe manual memory management in Cyclone.\"][safe-mem] Science of\n  Computer Programming 62, no. 2 (2006): 122-144.\n\n- Gay, David, and Alex\n  Aiken. [Memory management with explicit regions][explicit]. Vol. 33,\n  no. 5. ACM, 1998.\n\n## License\n\nCopyright 2018 Fernando Borretti.\n\nLicensed under the GPLv3 license. See the COPYING file for details.\n\n[rust]: https://www.rust-lang.org/en-US/\n[mlton]: http://mlton.org/\n[parsimony]: https://github.com/eudoxia0/parsimony\n\n[region-cyclone]: https://www.cs.umd.edu/projects/cyclone/papers/cyclone-regions.pdf\n[safe-mem]: http://www.cs.umd.edu/projects/PL/cyclone/scp.pdf\n[explicit]: http://titanium.cs.berkeley.edu/papers/gay-thesis.pdf\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feudoxia0%2Finterim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feudoxia0%2Finterim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feudoxia0%2Finterim/lists"}