Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binding {binds} #146

Merged
merged 3 commits into from
Apr 17, 2022
Merged

binding {binds} #146

merged 3 commits into from
Apr 17, 2022

Conversation

vito
Copy link
Owner

@vito vito commented Apr 17, 2022

edit: #152 swapped the order of key/values - original description below, just imagine the keys and values are swapped.


support for destructuring scopes via bind forms:

(def {a :a b :b} {:a 1 :b 2})
[a b] ; [1 2]

I decided to give this simpler semantics than Clojure's full associative destructuring. There is no :keys, :as, or :or; just bindings and keys, which can be paired with a default value.

This simpler form can be easily implemented via going over the form and binding alternating pairs in one pass.

Example of using defaults:

(let [{src (:src *dir*/../)
       version (:version "dev")
       os (:os "linux")
       arch (:arch "amd64")} (next *stdin* {})]
  [src version os arch])

vito added 3 commits April 15, 2022 18:10
note: I decided to give this simpler semantics than Clojure's full map
destructuring.

there is no :keys, :as, or :or; just bindings and keys, which can be
paired with a default value.

e.g.:

  (let [{src (:src *dir*/../)
         version (:version "dev")
         os (:os "linux")
         arch (:arch "amd64")} (next *stdin* {})]
    [src version os arch])
@vito vito added the enhancement New feature or request label Apr 17, 2022
@vito vito merged commit d36b4d0 into main Apr 17, 2022
@vito vito deleted the bind-bind branch April 17, 2022 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant