{"id":20602595,"url":"https://github.com/losinggeneration/forsp-go","last_synced_at":"2026-04-19T12:33:23.572Z","repository":{"id":255764478,"uuid":"853566397","full_name":"losinggeneration/forsp-go","owner":"losinggeneration","description":"A Go port of Forsp","archived":false,"fork":false,"pushed_at":"2024-09-07T10:07:25.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-17T02:08:44.986Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/losinggeneration.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-09-06T23:33:46.000Z","updated_at":"2024-09-07T10:07:28.000Z","dependencies_parsed_at":"2024-09-07T02:51:10.257Z","dependency_job_id":"0ad23e3b-e68e-4db3-bcde-2bafbac7c0b8","html_url":"https://github.com/losinggeneration/forsp-go","commit_stats":null,"previous_names":["losinggeneration/forsp-go"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/losinggeneration%2Fforsp-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/losinggeneration%2Fforsp-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/losinggeneration%2Fforsp-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/losinggeneration%2Fforsp-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/losinggeneration","download_url":"https://codeload.github.com/losinggeneration/forsp-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242245325,"owners_count":20096086,"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":[],"created_at":"2024-11-16T09:14:14.151Z","updated_at":"2026-04-19T12:33:23.531Z","avatar_url":"https://github.com/losinggeneration.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Forsp: A Forth+Lisp Hybrid Lambda Calculus Language\n\nA Go port of Forsp, a hybrid language combining Forth and Lisp.\n\nForsp is a minimalist language.\n\n## Features\n\nForsp has:\n  - An S-Expression syntax like Lisp\n  - Function abstraction like Lisp\n  - Function application like Forth\n  - An environment structure like Lisp\n  - Lexically-scoped closures like Lisp (Scheme)\n  - Cons-cells / lists / atoms like Lisp\n  - A value/operand stack like Forth\n  - An ability to express the Lambda Calculus\n  - A Call-By-Push-Value evaluation order\n  - Only 3 syntax special forms: ' ^ $\n  - Only 1 eval-time special form: quote\n  - Only 10 primitive functions need to self-implement\n  - Ability to self-implement in very little\n\n## Port\n\nSince this is a port of the original [Forsp](https://github.com/xorvoid/forsp)\nit's suggested to check out the original C version too. This was, more-or-less\na fun day project to port the C code to Go. I've also always liked the idea of\nForth. I've implemented a bare metal Forth before, but have never done a Lisp,\nand this seemed like a good introduction implementation as the original C is\n\u003c 700 lines of code.\n\nGiven time \u0026 interest, I may rework this from a stand alone program to an\npackage + program. For this reason, consider the API unstable and subject to\nchange without any guarantees.\n\n## Discussion\n\nSee blog post for details: [Forsp: A Forth+Lisp Hybrid Lambda Calculus Language](https://xorvoid.com/forsp.html)\n\n## Tutorial\n\nThe best way to learn Forsp is to [read the tutorial](examples/tutorial.fp)\n\n## Recursive Factorial Example\n\n```\n(\n  ($x x)                       $force\n  (force cswap $_ force)       $if\n  ($f $t $c $fn ^f ^t ^c fn)   $endif\n\n  ; Y-Combinator\n  ($f\n    ($x (^x x) f)\n    ($x (^x x) f)\n    force\n  ) $Y\n\n  ; rec: syntax sugar for applying the Y-Combinator\n  ($g (^g Y)) $rec\n\n  ; factorial\n  ($self $n\n    ^if (^n 0 eq 1)\n      (^n 1 - self ^n *)\n    endif\n  ) rec $factorial\n\n  5 factorial print\n)\n```\n\n## Self-implementation (compute() and eval() core functions)\n\n```\n  ; compute [$comp $stack $env -\u003e $stack]\n  ($compute $eval\n    ^if (dup is-nil) (rot $_ $_) ( ; false case: return $stack\n      stack-pop\n      ^if (dup 'quote eq)\n        ($_ stack-pop rot swap stack-push swap ^eval compute)\n        (swap $comp eval ^comp ^eval compute) endif\n    ) endif\n  ) rec $compute\n\n  ; eval: [$expr $stack $env -\u003e $stack $env]\n  ($eval\n    ^if (dup is-atom) (\n      over2 swap env-find dup $callable\n      ^if (dup is-closure) (swap $stack cdr unpack-closure ^stack swap ^eval compute)\n      (^if (dup is-clos)   (force)\n                           (stack-push)  endif) endif)\n    (^if (dup is-list)\n      (over2 swap make-closure stack-push)\n      (stack-push) endif) endif\n  ) rec $eval\n```\n\n## Building and Demo\n\nBuilding:\n\n```\ngo build\n```\nor if you want to try the low-level \u0026 unsafe primitives\n```\ngo build -tags unsafe\n```\n\nExamples:\n\n```\n./forsp examples/tutorial.fp\n./forsp examples/demo.fp\n./forsp examples/factorial.fp\n./forsp examples/currying.fp\n./forsp examples/church-numerals.fp\n./forsp examples/higher-order-functions.fp\n./forsp examples/church-numerals.fp\n./forsp examples/low-level.fp\n./forsp examples/fibonacci-functional.fp\n./forsp examples/forsp.fp\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flosinggeneration%2Fforsp-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flosinggeneration%2Fforsp-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flosinggeneration%2Fforsp-go/lists"}