{"id":29974850,"url":"https://github.com/citycide/cascade","last_synced_at":"2025-08-04T07:08:54.410Z","repository":{"id":132630190,"uuid":"110378851","full_name":"haltcase/cascade","owner":"haltcase","description":"Method, accessor, and assignment cascades for Nim, inspired by Smalltalk \u0026 Dart.","archived":false,"fork":false,"pushed_at":"2024-05-13T16:06:16.000Z","size":13,"stargazers_count":102,"open_issues_count":2,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-28T18:09:21.203Z","etag":null,"topics":["assignment-cascades","cascade","macro","nim","self","this","with"],"latest_commit_sha":null,"homepage":"","language":"Nim","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/haltcase.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}},"created_at":"2017-11-11T20:46:05.000Z","updated_at":"2025-02-05T22:23:20.000Z","dependencies_parsed_at":"2024-11-23T12:15:17.654Z","dependency_job_id":null,"html_url":"https://github.com/haltcase/cascade","commit_stats":null,"previous_names":["citycide/cascade"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/haltcase/cascade","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haltcase%2Fcascade","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haltcase%2Fcascade/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haltcase%2Fcascade/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haltcase%2Fcascade/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/haltcase","download_url":"https://codeload.github.com/haltcase/cascade/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/haltcase%2Fcascade/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268660109,"owners_count":24286024,"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-08-04T02:00:09.867Z","response_time":79,"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":["assignment-cascades","cascade","macro","nim","self","this","with"],"created_at":"2025-08-04T07:02:16.182Z","updated_at":"2025-08-04T07:08:54.398Z","avatar_url":"https://github.com/haltcase.png","language":"Nim","funding_links":[],"categories":["Language Features","Macros"],"sub_categories":["Functional Programming","Byte Size"],"readme":"# cascade \u0026middot; [![nimble](https://flat.badgen.net/badge/available%20on/nimble/yellow)](https://nimble.directory/pkg/cascade) ![license](https://flat.badgen.net/github/license/haltcase/cascade)\n\n\u003e Method \u0026 assignment cascades for Nim, inspired by Smalltalk \u0026 Dart.\n\ncascade is a macro for Nim that implements _method cascades_, a feature\noriginally from Smalltalk that's made its way into modern languages like\n[Dart][dart] and [Kotlin][kotlin].\n\nIt allows you to avoid repeating an object's name for each method call\nor assignment. A common case is something like a button:\n\n```nim\n# before\nvar res = Button()\nres.text = \"ok\"\nres.width = 30\nres.color = \"#13a89e\"\nres.enable()\n```\n\nWith cascade, you don't need to repeat yourself:\n\n```nim\n# after\nlet btn = cascade Button():\n  text = \"ok\"\n  width = 30\n  color = \"#13a89e\"\n  enable()\n```\n\nAlso notice you can avoid declaring a `var` if you don't need to modify\nthe target object after the fact \u0026mdash; the object is mutable within the\ncascade block but becomes a `let` binding outside of that block.\n\n## installation \u0026 usage\n\nInstall using [Nimble][nimble]:\n\n```shell\nnimble install cascade\n```\n\nThen `import` and use:\n\n```nim\nimport cascade\n\nlet x = cascade y:\n  z = 10\n  f()\n```\n\n## supported constructs\n\n* field assignment\n\n  ```nim\n  let foo = cascade Foo():\n    bar = 100\n\n  # ↑ equivalent ↓\n\n  var foo = Foo()\n  foo.bar = 100\n  ```\n\n* nested field assignment\n\n  ```nim\n  let foo = cascade Foo():\n    bar.baz.qux = \"awesome\"\n\n  # ↑ equivalent ↓\n\n  var foo = Foo()\n  foo.bar.baz.qux = \"awesome\"\n  ```\n\n* proc/template/method calls\n\n  ```nim\n  let foo = cascade Foo():\n    fn(\"hello\", \"world\")\n\n  # ↑ equivalent ↓\n\n  var foo = Foo()\n  foo.fn(\"hello\", \"world\")\n  ```\n\n* nested calls on fields\n\n  ```nim\n  let foo = cascade Foo():\n    bar.baz.seqOfStrings.add \"more awesome\"\n\n  # ↑ equivalent ↓\n\n  var foo = Foo()\n  foo.bar.baz.seqOfStrings.add \"more awesome\"\n  ```\n\n* `if` and `when` conditionals\n\n  ```nim\n  let foo = cascade Foo():\n    if someCondition: bar.baz = 2\n\n  # ↑ equivalent ↓\n\n  var foo = Foo()\n  if someCondition: foo.bar.baz = 2\n  ```\n\n* `cascade`s can be nested within each other\n\n  ```nim\n  let foo = cascade Foo():\n    bar = cascade Bar():\n      baz = cascade Baz():\n        str = \"we're down here now!\"\n\n  # ↑ equivalent ↓\n\n  var foo = Foo()\n  foo.bar = Bar()\n  foo.bar.baz = Baz(str: \"we're down here now!\")\n  ```\n\n\u003e Is something missing? Check the open [issues][issues] first or open a new\none. Pull requests are appreciated!\n\n## building\n\nTo build cascade from source you'll need to have [Nim][nim] installed,\nand should also have [Nimble][nimble], Nim's package manager.\n\n1. Clone the repo: `git clone https://github.com/haltcase/cascade.git`\n2. Move into the newly cloned directory: `cd cascade`\n3. Make your changes: `cascade.nim`, `tests/tests.nim`\n4. Run tests: `nimble test`\n\n## contributing\n\nYou can check the [issues][issues] for anything unresolved, search for a\nproblem you're encountering, or open a new one. Pull requests for improvements\nare also welcome.\n\n## license\n\nMIT © [Bo Lingen / haltcase](https://github.com/haltcase)\n\n[dart]: https://dart.dev/language/operators#cascade-notation\n[kotlin]: https://kotlinlang.org/docs/scope-functions.html#apply\n[nim]: https://github.com/nim-lang/nim\n[nimble]: https://github.com/nim-lang/nimble\n[issues]: https://github.com/haltcase/cascade/issues\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcitycide%2Fcascade","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcitycide%2Fcascade","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcitycide%2Fcascade/lists"}