{"id":46348011,"url":"https://github.com/gmpalter/cl-forth","last_synced_at":"2026-03-04T22:03:13.222Z","repository":{"id":255574970,"uuid":"762479137","full_name":"gmpalter/cl-forth","owner":"gmpalter","description":"Common Lisp implementation of the Forth 2012 Standard","archived":false,"fork":false,"pushed_at":"2025-12-16T20:12:34.000Z","size":703,"stargazers_count":133,"open_issues_count":0,"forks_count":8,"subscribers_count":14,"default_branch":"main","last_synced_at":"2026-01-20T13:58:05.319Z","etag":null,"topics":["forth","forth-2012"],"latest_commit_sha":null,"homepage":"","language":"Common Lisp","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/gmpalter.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-02-23T21:39:32.000Z","updated_at":"2026-01-13T19:56:11.000Z","dependencies_parsed_at":"2024-12-02T20:37:06.630Z","dependency_job_id":null,"html_url":"https://github.com/gmpalter/cl-forth","commit_stats":null,"previous_names":["gmpalter/cl-forth"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/gmpalter/cl-forth","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmpalter%2Fcl-forth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmpalter%2Fcl-forth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmpalter%2Fcl-forth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmpalter%2Fcl-forth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gmpalter","download_url":"https://codeload.github.com/gmpalter/cl-forth/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmpalter%2Fcl-forth/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30095695,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T21:59:23.547Z","status":"ssl_error","status_checked_at":"2026-03-04T21:57:50.415Z","response_time":59,"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":["forth","forth-2012"],"created_at":"2026-03-04T22:03:10.254Z","updated_at":"2026-03-04T22:03:13.206Z","avatar_url":"https://github.com/gmpalter.png","language":"Common Lisp","readme":"# CL-Forth\n\nCommon Lisp implementation of the [Forth 2012 Standard](https://forth-standard.org), CL-Forth\n\n## Supported Platforms\n\nCL-Forth is fully supported by CCL v1.12.2-82 or later.\n\nCL-Forth is fully supported by SBCL 2.1.0 or later.\n\nCL-Forth supports LispWorks 8.0.1 or later. However, at present, the word `RESIZE-FILE` will always return an error indication,\nresulting in 7 failures in the File-Access word set tests.\n\nCL-Forth compiles under ECL 24.5.10 but crashes running the Forth test suite.\n\n\n## Supported Operating Systems\n\nCL-Forth is supported on macOS, Linux, and Windows.\n\nOn macOS, it has been verified to run on macOS Ventura or later.\n\nOn Linux, it has been verified to run on distributions with 5.10.162 kernels or later.\n\nOn Windows, it has been verified to run on Windows 10 or later.\n\n\n## License\n\nCL-Forth is made available under the terms of the [MIT License](LICENSE).\n\n\n## Usage\n\nCL-Forth is defined using ASDF and is dependent on the [CFFI](https://github.com/cffi/cffi) and\n[trivial-gray-streams](https://github.com/trivial-gray-streams/trivial-gray-streams ) libraries.\n\nTo fetch a copy of CL-Forth and the [Forth 2012 Test Suite](https://github.com/gerryjackson/forth2012-test-suite.git) configured\nto only run tests for those word sets implemented by CL-Forth.\n\n``` bash\ngit clone https://github.com/gmpalter/cl-forth.git --recurse-submodules\n```\n\n[QuickLisp](https://www.quicklisp.org/) is probably the simplest way to fetch the CFFI and trivial-gray-streams\nlibraries. Follow the instructions on the QuickLisp webpage to download, install, and add QuickLisp to your Lisp's init\nfile. To install the libraries, evaluate the following forms. (You only have to do this one time.)\n\n``` lisp\n(ql:quickload '#:cffi)\n(ql:quickload '#:trivial-gray-streams)\n```\n\nTo load CL-Forth into Lisp\n\n``` lisp\n(require '#:asdf)\n(load \"cl-forth.asd\")\n(asdf:load-system '#:cl-forth)\n```\n\nYou can run the [Forth 2012 Test Suite](https://github.com/gerryjackson/forth2012-test-suite.git)\n\n``` lisp\n(asdf:test-system '#:cl-forth)\n```\n\nTo start the CL-Forth interpreter loop\n\n``` lisp\n(forth:run)\n```\n\nCL-Forth is case-insensitive.\n\n\n### Building a Standalone CL-Forth\n\nYou can build a standalone CL-Forth application.\n\nLaunch Lisp and evaluate the forms\n\n``` lisp\n(require '#:asdf)\n(load \"cl-forth.asd\")\n(asdf:load-system '#:cl-forth/application)\n(forth-app:save-application \"cl-forth\")\n```\n\nThis will create an executable named `cl-forth`. When you run `cl-forth`, it will startup directly into the Forth interpreter\nloop.\n\n``` forth\n./cl-forth\nCL-Forth Version 1.3\nRunning under Clozure Common Lisp Version 1.13 (v1.13) DarwinX8664\n1 1 + .\n2 OK.\n: hello-world .\" Hello World!\" cr ;\nOK.\nhello-world\nHello World!\nOK.\nsee hello-world\nSource code for hello-world:\n(DEFUN FORTH-WORDS::HELLO-WORLD (FS \u0026REST PARAMETERS)\n  (DECLARE (IGNORABLE PARAMETERS))\n  (WITH-FORTH-SYSTEM (FS)\n    (TAGBODY (WRITE-STRING \"Hello World!\")\n             (TERPRI)\n     :EXIT)))\nOK.\nbye\nIn this session:\n  1 definition created\n  240 bytes of object code generated\n```\n\nThe application recognizes these command line arguments\n\n| | |\n| --- | --- |\n| `‑‑interpret EXPR`, `‑i EXPR` | Evaluate `EXPR` before entering the Forth interpreter loop. `EXPR` may need to be quoted to avoid interpretation by the shell.  This argument may be used multiple times. |\n| `‑‑transcript PATH` | Record a timestamped transcript of this session in the file `PATH` |\n| `‑‑help`, `‑h` | Display the available command line arguments and exit |\n| `‑‑version`, `‑V` | Display the version of CL-Forth and exit |\n\n\n## Missing Words\n\nCL-Forth does not implement the optional Block word set.\n\nCL-Forth does not implement the optional Extended-Character word set.\n\nCL-Forth does not implement `KEY` which is part of the Core word set.\n\nThe following words that are part of the optional Facility and Facility extensions word set are not implemented.\n\n| | | | | |\n| --- | --- | --- | --- | --- |\n| `AT-XY` | `KEY?` | `PAGE` | `EKEY` | `EKEY\u003eCHAR` |\n| `EKEY\u003eFKEY` | `EKEY?` | `EMIT?` | `K-ALT-MASK` | `K-CTRL-MASK` |\n| `K-DELETE` | `K-DOWN` | `K-END` | `K-F1` | `K-F10` |\n| `K-F11` | `K-F12` | `K-F2` | `K-F3` | `K-F4` |\n| `K-F5 `| `K-F6` | `K-F7` | `K-K8` | `K-F9` |\n| `K-HOME` | `K-INSERT` | `K-LEFT` | `K-NEXT` | `K-PRIOR` |\n| `K-RIGHT` | `K-SHIFT-MASK` | `K-UP` |\n\n  \n## Foreign Function Interface\n\nCL-Forth includes a foreign function interface (FFI) loosely based on the External Library Interface in\n[SwiftForth](https://www.forth.com/swiftforth/). See [FFI.md](FFI.md) for details.\n\n\n## Optimization\n\nCL-Forth includes an __experimental__ optimizer which tries to simplify the code generated by CL-Forth by eliminating as much\nuse of the data stack as possible. There are additional optimizations applied to eliminate unnecessary validity checks when\nthose checks can be shown to be redundant. (E.g, checking that the character count given to `TYPE` is not negative.)\n\nThe optimizer is controlled by a boolean flag whose address is stored in the `OPTIMIZER` variable. You change the value of\nthis flag using the words `ON` and `OFF`.\n\nTo turn the optimizer on, execute `OPTIMIZER ON` and to turn it off, execute `OPTIMIZER OFF`.\n\nBy default, the optimizer is off.\n\nUnder SBCL, the Forth test suite runs approximately 33% faster and generates approximately 25% less object code.\n\nSome examples of the optimizer's effect on code generated by CL-Forth follows.\n\n``` forth\nCL-Forth Version 1.4.1\nRunning under Clozure Common Lisp Version 1.13 (v1.13) DarwinX8664\nshow-code on\nOK.\nvariable x variable y variable z\nOK.\noptimizer off\nOK.\n: test1 x @ y @ 256 + + z ! ;\nSource code for test1:\n(DEFUN FORTH-WORDS::TEST1 (FS PARAMETERS)\n  (DECLARE (IGNORABLE PARAMETERS))\n  (WITH-FORTH-SYSTEM (FS)\n    (TAGBODY (STACK-PUSH DATA-STACK 4503599627370496)\n             (STACK-PUSH DATA-STACK (CELL-SIGNED (MEMORY-CELL MEMORY (STACK-POP DATA-STACK))))\n             (STACK-PUSH DATA-STACK 4503599627370504)\n             (STACK-PUSH DATA-STACK (CELL-SIGNED (MEMORY-CELL MEMORY (STACK-POP DATA-STACK))))\n             (STACK-PUSH DATA-STACK 256)\n             (STACK-PUSH DATA-STACK\n                         (CELL-SIGNED (+ (CELL-SIGNED (STACK-POP DATA-STACK))\n                                         (CELL-SIGNED (STACK-POP DATA-STACK)))))\n             (STACK-PUSH DATA-STACK\n                         (CELL-SIGNED (+ (CELL-SIGNED (STACK-POP DATA-STACK))\n                                         (CELL-SIGNED (STACK-POP DATA-STACK)))))\n             (STACK-PUSH DATA-STACK 4503599627370512)\n             (SETF (MEMORY-CELL MEMORY (STACK-POP DATA-STACK)) (STACK-POP DATA-STACK))\n     :EXIT)))\nOK.\noptimizer on\nOK.\n: test1opt x @ y @ 256 + + z ! ;\nSource code for test1opt:\n(DEFUN FORTH-WORDS::TEST1OPT (FS PARAMETERS)\n  (DECLARE (IGNORABLE PARAMETERS))\n  (WITH-FORTH-SYSTEM (FS)\n    (TAGBODY (SETF (MEMORY-CELL MEMORY 4503599627370512)\n                   (CELL-SIGNED (+ (CELL-SIGNED (+ 256\n                                                   (CELL-SIGNED (MEMORY-CELL\n                                                                 MEMORY\n                                                                 4503599627370504))))\n                                   (CELL-SIGNED (MEMORY-CELL MEMORY 4503599627370496)))))\n     :EXIT)))\nOK.\noptimizer off\nOK.\n: test2 x 128 type cr ;\nSource code for test2:\n(DEFUN FORTH-WORDS::TEST2 (FS PARAMETERS)\n  (DECLARE (IGNORABLE PARAMETERS))\n  (WITH-FORTH-SYSTEM (FS)\n    (TAGBODY (STACK-PUSH DATA-STACK 4503599627370496)\n             (STACK-PUSH DATA-STACK 128)\n             (LET ((COUNT (STACK-POP DATA-STACK)) (ADDRESS (STACK-POP DATA-STACK)))\n               (WHEN (MINUSP COUNT)\n                 (FORTH-EXCEPTION\n                   :INVALID-NUMERIC-ARGUMENT\n                   \"Count to TYPE can't be negative\"))\n               (MULTIPLE-VALUE-BIND (FORTH-MEMORY OFFSET)\n                   (MEMORY-DECODE-ADDRESS MEMORY ADDRESS COUNT)\n                 (WRITE-STRING (FORTH-STRING-TO-NATIVE FORTH-MEMORY OFFSET COUNT))))\n             (TERPRI)\n     :EXIT)))\nOK.\noptimizer on\nOK.\n: test2opt x 128 type cr ;\nSource code for test2opt:\n(DEFUN FORTH-WORDS::TEST2OPT (FS PARAMETERS)\n  (DECLARE (IGNORABLE PARAMETERS))\n  (WITH-FORTH-SYSTEM (FS)\n    (TAGBODY (LET ((COUNT 128) (ADDRESS 4503599627370496))\n               (DECLARE (IGNORABLE COUNT ADDRESS))\n               (MULTIPLE-VALUE-BIND (FORTH-MEMORY OFFSET)\n                   (MEMORY-DECODE-ADDRESS MEMORY 4503599627370496 128)\n                 (WRITE-STRING (FORTH-STRING-TO-NATIVE FORTH-MEMORY OFFSET 128))))\n             (TERPRI)\n     :EXIT)))\nOK.\nbye\nIn this session:\n  7 definitions created\n  3920 bytes of object code generated\n  24 bytes of memory allocated\n```\n\n## Additional Words\n\nCL-Forth includes a number of words defined by other implementation that are not part of the Forth 2012 Standard.\n\nThese words are specific to CL-Forth.\n\n| | |\n| --- | --- |\n| `.SF` | Display the contents of the floating-point stack |\n| `.SR` | Display the contents of the return stack |\n|  `ALL-WORDS` | Display all words in all word lists in the search order |\n| `BREAK` | Enter a Lisp break loop |\n| `INLINEABLE` | Mark that the most recent definition's code may be inlined |\n| `NOTINTERPRETED` | Mark that the most recent definition must only appear in definitions |\n| `OPTIMIZER` | Return the address of the flag that controls whether generated code is optimized (**EXPERIMENTAL**) |\n| `P.` | Display the top cell of the data stack as a pointer (i.e., 16 hex digits) ||\n| `RELOAD` | Reload a predefined definition (i.e., created by `define-word`) |\n| `REMOVE` | Erase a single word |\n| `SETINLINEABLE` | Enable/disable inlining of an existing word |\n| `SHOW-BACKTRACES` | Return the address of the flag that controls whether exceptions display the return and data stacks |\n| `SHOW-CODE` | Return the address of the flag that controls whether completing a definition shows the generated code |\n| `STATISTICS` | Report some useful statistics about this CL-Forth session |\n\nThese words are defined as \"Common Usage\" in the [Forth Programmer's Manual, 3rd Edition](https://www.forth.com/forth-books/).\n\n| | | | | |\n| --- | --- | --- | --- | --- |\n| `,\"` | `2+` | `2-` | `C+!` | `CONTEXT` |\n| `CURRENT` | `CVARIABLE` | `M-` | `M/` | `NOT` |\n| `NUMBER` |`NUMBER?` | `VOCABULARY` |\n\nThese words are defined by [SwiftForth](https://www.forth.com/swiftforth/).\n\n| | | | | | |\n| --- | --- | --- | --- | --- | --- |\n| `-?` | `EMPTY` | `GILD` | `OFF` | `ON` | `OPTIONAL` |\n| `SILENT` | `VERBOSE` | `WARNING` | `\\\\` | `{` |\n\n\n## Implementation\n\n_TO BE SUPPLIED_\n\n\n## Native Code Support\n\nCL-Forth implements `CODE` and `;CODE` to allow the definition of words written in Lisp rather than Forth. The terminator for\nthe Lisp code block is `;ENDCODE`.\n\nHere is an example of using native code.\n\n``` c\n\\ ( c-addr1 u - c-addr2 u)\n\\ Converts the string at C-ADDR1 U to uppercase and leaves the result in transient space at C-ADDR2 U.\nCODE UPCASE\n  (let ((count (cell-signed (stack-pop data-stack)))\n        (address (stack-pop data-stack)))\n    (unless (plusp count)\n      (forth-exception :invalid-numeric-argument \"Count to UPCASE must be positive\"))\n    (multiple-value-bind (data offset)\n        (memory-decode-address memory address count)\n      (let* ((original (forth-string-to-native data offset count))\n             (upcased (string-upcase original))\n             (string-space (reserve-string-space memory))\n             (address (transient-space-base-address memory string-space)))\n        (ensure-transient-space-holds memory string-space count)\n        (multiple-value-bind (data offset)\n            (memory-decode-address memory address count)\n          (native-into-forth-string upcased data offset)\n          (seal-transient-space memory string-space)\n          (stack-push data-stack address)\n          (stack-push data-stack count)))))\n;ENDCODE\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmpalter%2Fcl-forth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgmpalter%2Fcl-forth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmpalter%2Fcl-forth/lists"}