{"id":37173774,"url":"https://github.com/codr7/gfun","last_synced_at":"2026-01-14T20:18:30.922Z","repository":{"id":161215067,"uuid":"463429572","full_name":"codr7/gfun","owner":"codr7","description":"Lisp 4 Go","archived":false,"fork":false,"pushed_at":"2022-03-06T18:30:23.000Z","size":230,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-06-21T20:06:07.293Z","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/codr7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2022-02-25T06:54:46.000Z","updated_at":"2024-05-27T16:48:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"2a9a5d7b-cdff-4b48-b339-79d0f407631b","html_url":"https://github.com/codr7/gfun","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/codr7/gfun","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codr7%2Fgfun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codr7%2Fgfun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codr7%2Fgfun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codr7%2Fgfun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codr7","download_url":"https://codeload.github.com/codr7/gfun/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codr7%2Fgfun/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28434422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":[],"created_at":"2026-01-14T20:18:30.344Z","updated_at":"2026-01-14T20:18:30.915Z","avatar_url":"https://github.com/codr7.png","language":"Go","funding_links":["https://liberapay.com/andreas7/donate"],"categories":[],"sub_categories":[],"readme":"## GFun\n\n```\n  (fun: fib [n Int] Int\n    (if (\u003c n 2) n (+ (fib (dec n)) (fib (dec n 2)))))\n  \n  (fib 10)\n\n55\n```\n\n### intro\nGFun aims to become a Lispy scripting language/vm implemented and embedded in Go.\u003cbr/\u003e\u003cbr/\u003e\n\nMuch along the same lines as [g-fu](https://github.com/codr7/g-fu), but a tighter implementation that takes everything learned since into account.\u003cbr/\u003e\u003cbr/\u003e\n\nThe different layers of the implementation are well separated and may be used separately or mixed and matched; for example by putting a different syntax on top or adapting the existing one, or adding additional compilation steps.\u003cbr/\u003e\u003cbr/\u003e\n\n### limitations\nFor performance reasons, the core loop specifies operations inline; which means that it's impossible to extend with new operations without changing the code. Limits on number of operations, number of registers etc. are determined by the bytecode [format](https://github.com/codr7/gfun/blob/main/lib/op.go).\n\n### status\nIt's still early days, I'm currently profiling and optimizing the implementation guided by initial performance numbers. All functionality described in this document is expected to work.\n\n### setup\n\n```\n$ cd test\n$ go test\n$ cd ..\n$ go build gfun.go\n$ ./gfun test/all.gf\n$ ./gfun\n```\n\n### types\nGFun supports first class types, `typeof` may be used to get the type of any value.\n\n```\n  (typeof 42)\n\nInt\n  (typeof Int)\n\nMeta\n  (typeof Meta)\n\nMeta\n```\n\n#### Any\nThe root type.\n#### Fun \u003c Any\nThe type of functions.\n#### Bool \u003c Any\nThe boolean type has two values, `T` and `F`.\n#### Int \u003c Any\nThe type of whole numbers.\n#### Macro \u003c Any\nThe type of macros.\n#### Meta \u003c Any\nThe type of types.\n#### Nil \u003c Any\nThe nil type has one value, `_`.\n\n### bindings\nValues may be temprarily bound to identifiers using `let`.\n\n```\n  (let [foo 35 bar (+ foo 7)] bar)\n\n42\n```\n\nValues may be bound until further using `set`.\n\n```\n  (set foo 35 bar 7 baz (+ 35 7))\n  baz\n\n42\n```\n\n### functions\nFunctions may be anonymous.\n\n```\n  (let [foo (fun [bar Int] Int bar)]\n    (dump foo)\n    (foo 42))\n  \n(Fun 0x824634418592)\n42\n```\n\n### performance\nGFun is currently around 1-6 times as slow as Python.\n\n```\n  (fun: fibrec [n Int] Int\n    (if (\u003c n 2) n (+ (fibrec (dec n)) (fibrec (dec n 2)))))\n\n  (bench 100 (fibrec 20))\n\n734\n```\n\n```\n  (fun: fibtail [n Int a Int b Int] Int\n    (if (= n 0) a (if (= n 1) b (fibtail (dec n) b (+ a b)))))\n\n  (bench 10000 (fibtail 70 0 1))\n\n226\n```\n\n#### fusing\nThe generated bytecode is analyzed before evaluation in an attempt to fuse as much of it as possible.\nIn the following example; GFun initially detects that the arguments are not used, which results in the function entry point being moved to 3; then the exit point is moved past the `_` since that's the default return value.\n\n```\n (fun: foo [x Int y Int] Nil _)\n\n2022/03/02 22:13:46 Fused unused load at 1: 32\n2022/03/02 22:13:46 Fused unused load at 2: 33\n2022/03/02 22:13:46 Fused entry to 2\n2022/03/02 22:13:46 Fused entry to 3\n2022/03/02 22:13:46 Fused exit to 3\n0 GOTO 5\n1 NOP\n2 NOP\n3 RET\n4 RET\n```\n### support\nShould you wish to support this effort and allow me to spend more of my time and energy on evolving GFun, feel free to [help](https://liberapay.com/andreas7/donate) make that economically feasible.\n\n### coder/mentor for hire\nI'm currently available for hire.\u003cbr/\u003e\nRemote or relocation within Europe.\u003cbr/\u003e\nSend a message to codr7 at protonmail and I'll get back to you asap.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodr7%2Fgfun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodr7%2Fgfun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodr7%2Fgfun/lists"}