{"id":13800805,"url":"https://github.com/ztellman/proteus","last_synced_at":"2025-10-22T02:46:12.828Z","repository":{"id":62434311,"uuid":"11357149","full_name":"ztellman/proteus","owner":"ztellman","description":"local. mutable. variables.","archived":true,"fork":false,"pushed_at":"2016-10-24T14:41:02.000Z","size":455,"stargazers_count":113,"open_issues_count":4,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-05-05T23:18:55.289Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Clojure","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/ztellman.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}},"created_at":"2013-07-12T01:04:44.000Z","updated_at":"2025-01-30T21:16:57.000Z","dependencies_parsed_at":"2022-11-01T21:01:53.055Z","dependency_job_id":null,"html_url":"https://github.com/ztellman/proteus","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ztellman%2Fproteus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ztellman%2Fproteus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ztellman%2Fproteus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ztellman%2Fproteus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ztellman","download_url":"https://codeload.github.com/ztellman/proteus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253913244,"owners_count":21983284,"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-08-04T00:01:16.467Z","updated_at":"2025-10-22T02:46:05.496Z","avatar_url":"https://github.com/ztellman.png","language":"Clojure","funding_links":[],"categories":["Awesome macros usage","\u003ca name=\"Clojure\"\u003e\u003c/a\u003eClojure"],"sub_categories":[],"readme":"![](docs/the-blob.jpg)\n\nProteus gives you back the local mutable variables you've so dearly missed.\n\n## usage\n\nAdd this to your `project.clj`:\n\n```clj\n[proteus \"0.1.6\"]\n```\n\nProteus exposes a single macro, `proteus/let-mutable`:\n\n```clj\n(use 'proteus)\n\n(let-mutable [x 0]\n  (dotimes [_ 100]\n    (set! x (inc x)))\n  x)\n```\n\n`let-mutable` gives you variables that can be set using `set!` within the scope.  Since it's unsynchronized and doesn't box numbers, it's faster (often significantly) than Clojure's volatiles, atoms, or refs.  However, these variables cannot escape the local scope; if passed into a function or closed over, the current value of the variable will be captured.  This means that even though this is unsynchronized mutable state, there's no potential for race conditions.\n\nUnless, of course, you want there to be.  It can be sometimes useful to close over the variable rather than the value, for instance when trying to communicate more than the new value from within a `swap!` call.\n\n```clj\n(let [a (atom 0)]\n  (let-mutable [x :foo]\n\n    (swap! a\n      ^:local\n      (fn [a]\n        (set! x :bar)\n        (inc a)))\n\n    x))\n```\n\nHere we've hinted the closure as `:local`, meaning that it's only called within the local scope.  Since this is true for `swap!`, we can safely use the mutable variable as a side-channel for communication.  However, using `:local` on a non-local closure may have strange, reality-defying effects.  Use at your own risk.\n\nThat's it.  That's the end of the library.\n\n## license\n\nCopyright © 2013 Zachary Tellman\n\nDistributed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fztellman%2Fproteus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fztellman%2Fproteus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fztellman%2Fproteus/lists"}