dash.el icon indicating copy to clipboard operation
dash.el copied to clipboard

Make `-let` support clojure stuff

Open Fuco1 opened this issue 10 years ago • 4 comments

I was just looking at the code from the other PR, and it ocured to me, why not make -let's [] syntax match what clojure has?

See https://clojuredocs.org/clojure.core/let

It seems nice :)

Fuco1 avatar Jan 14 '15 18:01 Fuco1

Extending (-let [p s] ..) to (-let [p1 s1 p2 s2 ..] ..) would be a nice first step. :or and :as requires a bit more effort :P

fbergroth avatar Jan 14 '15 22:01 fbergroth

There is some :keys and :as things, I don't know what it does yet. But yea, more assignment forms was what I primarily ment. I've always found that syntax a bit... friendlier.

Fuco1 avatar Jan 14 '15 22:01 Fuco1

Right, so :keys [foo bar] rather than &plist* :foo :bar (#111). Can string and symbol keys be handled in some way? :keys ["foo" :bar] looks a bit odd. Sorry, getting a bit late. Probably :keys would only handle keywords.

fbergroth avatar Jan 14 '15 22:01 fbergroth

As I understand it :as is the equivalent of haskell foo@(structure) right? I very much want to have that :) I would implement this using &as to stay consistent though.

:or seems less useful, but sometimes it might be nice (e.g. inside -when-let or -if-let forms)

We can't easily have :keys because we can't figure out the type of the structure we pass in to destructure, so we have to hint with &plist etc.

Fuco1 avatar May 03 '15 12:05 Fuco1