{"id":15107733,"url":"https://github.com/wilfred/mal_pharo","last_synced_at":"2025-10-07T02:57:40.278Z","repository":{"id":66760509,"uuid":"214301986","full_name":"Wilfred/mal_pharo","owner":"Wilfred","description":"A Make A Lisp implementation in Pharo","archived":false,"fork":false,"pushed_at":"2019-10-20T23:28:13.000Z","size":71,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T15:39:55.438Z","etag":null,"topics":["lisp","mal","pharo-smalltalk"],"latest_commit_sha":null,"homepage":null,"language":"Smalltalk","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Wilfred.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-10-10T23:14:35.000Z","updated_at":"2024-08-08T19:18:36.000Z","dependencies_parsed_at":"2023-02-24T22:15:12.975Z","dependency_job_id":null,"html_url":"https://github.com/Wilfred/mal_pharo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Wilfred/mal_pharo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wilfred%2Fmal_pharo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wilfred%2Fmal_pharo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wilfred%2Fmal_pharo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wilfred%2Fmal_pharo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Wilfred","download_url":"https://codeload.github.com/Wilfred/mal_pharo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wilfred%2Fmal_pharo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278712683,"owners_count":26032741,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["lisp","mal","pharo-smalltalk"],"created_at":"2024-09-25T21:41:16.950Z","updated_at":"2025-10-07T02:57:40.261Z","avatar_url":"https://github.com/Wilfred.png","language":"Smalltalk","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Make A Lisp\n\nAn implementation of [MAL](https://github.com/kanaka/mal) using [Pharo\nSmalltalk](http://pharo.org/).\n\nThis implementation is almost complete, and passes the self-hosting\nMAL test suite.\n\n## Code Organisation\n\n### Tests\n\nThis implementation includes over 100 unit tests in the\n`MakeALisp-Tests` diretory. This is in addition to the invaluable MAL\ntest suite.\n\nSmalltalk has brilliant TDD tooling and supports\nedit-and-continue-execution from the debugger, so it was often easier\nto start features/bugfixes with a unit test.\n\n### Steps\n\nMost MAL implementation have a shared library of functionality, then a\ndifferent step1, step2 etc file with an increasingly complex `MAL`\nclass.\n\nSmalltalk is image oriented, so all the code is stored\ntogether. Maintaining 10 different images would be very cumbersome, so\nI've used the same implementation for all the steps.\n\n### Dispatching Evaluation\n\nMAL convention is to implement evaluation using an `EVAL` function\nthat switches on the name of special forms, and an `eval_ast` function\nthat switches on the runtime type (symbol, list, etc).\n\nSmalltalk strongly prefers dynamic dispatch here. See the `evalIn:`\nmethod on `MalList` for evaluation logic.\n\n### Dispatching Special Forms and Built-Ins\n\nEach special form (`if`, `let*`, etc) and built-in function (`+`,\n`cons`, etc) is a self-contained class. To avoid needing to register\nthe classes elsewhere, each class implements `malName` and I use\nreflection to find the correct special form or function.\n\nThis is from `MalSpecialForm`:\n\n```\nmatchesSymbol: aSymbol\n\tself\n\t\tsubclassesDo: [ :f |\n\t\t\tf malName = aSymbol value\n\t\t\t\tifTrue: [ ^ f ] ].\n\t^ nil\n```\n\n### Tail-call Optimisation\n\nSmalltalk allocates stack frames on the heap. You can't get stack\noverflows: if you infinitely recurse you will eventually OOM instead.\n\nLooking at the `sum2` function from `step5_tco.mal`:\n\n```\n(def! sum2\n    (fn* (n acc)\n         (if (= n 0)\n             acc\n             (sum2 (- n 1) (+ n acc)))))\n```\n\nTCO means this function uses O(1) stack, whereas this implementation\nuses O(N) stack. The function is still O(N) in both cases if you allow\narbitrary size numbers.\n\nSmalltalk favours letting the stack grow: the built-in implementation\nof factorial is a simple recursive function.\n\nThis implementation therefore doesn't implement TCO, but still passes\nthe TCO tests. I think it makes the code more readable and\ndefinitely helps keep stack traces useful, but it feels like a slight\ncheat.\n\n## License\n\nLicensed under MPL 2.0 (Mozilla Public License 2.0), consistent with\nthe other MAL implementations.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilfred%2Fmal_pharo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilfred%2Fmal_pharo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilfred%2Fmal_pharo/lists"}