{"id":13440970,"url":"https://github.com/adam-mcdaniel/wisp","last_synced_at":"2026-04-08T17:31:52.674Z","repository":{"id":45438431,"uuid":"324113471","full_name":"adam-mcdaniel/wisp","owner":"adam-mcdaniel","description":" A lisp👽 written in C++","archived":false,"fork":false,"pushed_at":"2024-04-11T05:10:12.000Z","size":3025,"stargazers_count":201,"open_issues_count":5,"forks_count":21,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-07-23T05:43:02.327Z","etag":null,"topics":["cpp","interpreter","language","lisp"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adam-mcdaniel.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}},"created_at":"2020-12-24T09:05:18.000Z","updated_at":"2025-05-27T06:16:07.000Z","dependencies_parsed_at":"2024-04-13T14:38:34.681Z","dependency_job_id":null,"html_url":"https://github.com/adam-mcdaniel/wisp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/adam-mcdaniel/wisp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adam-mcdaniel%2Fwisp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adam-mcdaniel%2Fwisp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adam-mcdaniel%2Fwisp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adam-mcdaniel%2Fwisp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adam-mcdaniel","download_url":"https://codeload.github.com/adam-mcdaniel/wisp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adam-mcdaniel%2Fwisp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31566784,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["cpp","interpreter","language","lisp"],"created_at":"2024-07-31T03:01:28.413Z","updated_at":"2026-04-08T17:31:52.650Z","avatar_url":"https://github.com/adam-mcdaniel.png","language":"C++","readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003e👻\u003cb\u003ewisp\u003c/b\u003e✨\u003c/h1\u003e\n  \u003cp\u003e\n    \u003cstrong\u003eA lisp👽 written in C++\u003c/strong\u003e\n  \u003c/p\u003e\n  \u003cp float=\"left\"\u003e\n    \u003cimg src=\"./assets/logo.png\" width=\"40%\"/\u003e\n    \u003cimg src=\"./assets/wisp.png\" width=\"58%\"/\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n## Why write a lisp?\n\nLisp is one of those niche, beautiful languages that people only use for two specific purposes:\n\n1. Write a lisp interpreter\n2. To illustrate that code is data!!\n\n_So why add to the list of infinite lisp interpreters?_\n\nThe answer is simple: _**I'm bored out of my mind in quarantine.**_ If you were looking to find out why _this particular_ lisp is special, you're fresh out of luck. \n\nBut isn't the fact that it's a lisp _*enough*_?\n\n![Lisp](./assets/xkcd.png)\n\nyes.\n\n## Syntax and Special Forms\n\nLike every other lisp, this language uses s-expressions for code syntax and data syntax. So, for example, the s-expression `(print 5)` is both a valid code snippet, and a valid list containing the items `print` and `5`.\n\nWhen the data `(print 5)` is evaluated by the interpreter, it evaluates `print` and `5`, and then applies `print` to `5`. \n\nHere's the result.\n\n```lisp\n\u003e\u003e\u003e (print 5)\n5\n =\u003e 5\n```\n\nThat's super cool! But what if we want to define our own functions? _We can use the builtin function `defun`!_\n\n```lisp\n; define a function `fact` that takes an argument `n`\n(defun fact (n)\n  (if (\u003c= n 1)\n     1\n     (* n (fact (- n 1)))\n   ))\n```\n\nThats awesome! But did you notice anything different about the `defun` function? _It doesn't evaluate its arguments._ If the atom `fact` were evaluated, it would throw an error like so:\n\n```lisp\n\u003e\u003e\u003e fact\nerror: the expression `fact` failed in scope { } with message \"atom not defined\"\n```\n\nThis is known as a special form, where certain functions \"quote\" their arguments. We can quote things ourselves too, but the language _automatically_ quotes arguments to special forms itself.\n\nIf you want to \"quote\" a value yourself, you can do it like this.\n\n```lisp\n; quote the s-expression (1 2 3) so it's not evaluated\n\u003e\u003e\u003e (print '(1 2 3))\n(1 2 3)\n =\u003e (1 2 3)\n```\n\nAs you can see, quote negates an evaluation. For example, whenever the expression `''a` is evaluated, it becomes `'a`. This can be useful for when you want to write long lists of data or variable names without wanting to evaluate them as code.\n\n|Special Form|Argument Evaluations|Purpose|\n|:-|-|-|\n|`(if cond a b)`|`if` only evaluates its `cond` argument. If `cond` is truthy (non-zero), then `a` is evaluated. Otherwise, `b` is evaluated.|This special form is the main method of control flow.|\n|`(do a b c ...)`|`do` takes a list of s-expressions and evaluates them in the order they were given (in the current scope), and then returns the result of the last s-expression.|This special form allows lambda functions to have multi-step bodies.|\n|`(scope a b c ...)`|`scope` takes a list of s-expressions and evaluates them in the order they were given _in a new scope_, and then returns the result of the last s-expression.|This special form allows the user to evaluate blocks of code in new scopes.|\n|`(defun name params body)`|`defun` evaluates none of its arguments.|This special form allows the user to conveniently define functions.|\n|`(define name value)`|`define` evaluates the `value` argument, which is then assigned to `name` in the current scope.|This special form allows the user to bind atoms to values in a scope.|\n|`(lambda params body)`|`lambda` evaluates none of its arguments.|This special form allows the user to define anonymous functions.|\n|`(quote x)`|`quote` evaluates none of its arguments.|This is equivalent to the `'expr` syntactic sugar.|\n|`(for x list ...)`|`for` evaluates only its list argument.|`for` iterates through the list storing each element in `x`, and then evaluating all of the rest of the values in the `for` body. It then returns the last value evaluated.|\n|`(while cond ...)`|`while` evaluates only its cond argument.|`while` evaluates its condition expression every iteration before running. If it is true, it continues to evaluate every expression in the `while` body. It then returns the last value evaluated.|\n\n\n## Examples\n\nHere are some example math-y functions to wrap your head around.\n\n```lisp\n; quicksort\n(defun qs (l)\n    (if (\u003c= (len l) 1)\n        l\n        (do\n            (define pivot (first l))\n            (+\n                (qs (filter (lambda (n) (\u003e pivot n)) l))\n                (list pivot)\n                (qs (tail (filter (lambda (n) (\u003c= pivot n)) l)))\n            ))\n    ))\n\n; decrement a number\n(defun dec (n) (- n 1))\n; increment a number\n(defun inc (n) (+ n 1))\n; not a bool\n(defun not (x) (if x 0 1))\n\n; negate a number\n(defun neg (n) (- 0 n))\n\n; is a number positive?\n(defun is-pos? (n) (\u003e n 0))\n; is a number negative?\n(defun is-neg? (n) (\u003c n 0))\n```\n\n## Usage\n\nUsing and compiling wisp\n\n#### Dependencies\n\nCompile with your C++ compiler of choice. This is compatible with all standard versions of C++ since ANSI C++.\n\n```bash\n$ git clone https://github.com/adam-mcdaniel/wisp\n$ cd wisp\n$ g++ wisp.cpp -o wisp\n```\n\n#### Using the binary\n\nRun wisp in interactive mode:\n\n```bash\n$ ./wisp\n\u003e\u003e\u003e (print \"Hello world!\")\nHello world!\n =\u003e \"Hello world!\"\n```\n\nInterpret a file:\n\n```bash\n$ ./wisp \"examples/hello_world.lisp\"\nHello world!\n$ ./wisp -f \"examples/hello_world.lisp\"\nHello world!\n```\n\nInterpret from command line argument:\n\n```bash\n$ ./wisp -c '(print \"Hello world!\")'\nHello world!\n```\n\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadam-mcdaniel%2Fwisp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadam-mcdaniel%2Fwisp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadam-mcdaniel%2Fwisp/lists"}