Skip to content

Change destructuring syntax to align with "match" #29

@allie-jo

Description

@allie-jo

Python 3.10 introduced a canonical destructuring syntax with match. I think we should change the existing clojure like syntax to align with the syntax introduced by Python match which is already used by our existing match implementation.

Here's what I had in mind.

(let+ [{"a key" a-sym  {"a" [{:keys [b c d]} :as nested  e f #* rest]}} some-big-dict]
  [a-sym b c d nested e f rest])

This has key and binding symbol swapped compared to clojure, but Hy isn't Clojure 🤷‍♀️ and I like the consistent syntax with our existing match implementation. the only addition here is the :keys option. Which, looks up by string keys and maintains the idiom of keywords being arguments not identifiers themselves (even though there's nothign stopping you from destructuring keywords here or in match)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions