Email or username:

Password:

Forgot your password?
Andrew Tropin

One more reason why it's hard to use alists as associative data structure: There is no built-in destructuring capabilities for it. It seems (ice-9 match) is no help here. Situation becomes even worse if we have a nested data structure.

Going to stack a bunch of let+assoc-ref's I guess.

#scheme #lisp #guile #clojure

16 comments
Grigory Shepelev

@fosskers @abcdw Using guile scheme (with guix) for about 1.5 y. now. Didn't ever heard about plists. Thanks for this mention.

Colin

@abcdw Sorry I haven't touched Scheme in a bit. If it has alists I'm assuming it's also part of the culture to use plists (Property Lists) of the form:

(:a 1 :b 2 :c3)

These are common in CL and Elisp at least, and I've always found them simpler than alists.

Andrew Tropin

@fosskers Yep, it's possible to use plists in Scheme, but it doesn't solve the problem of lack of destructuring. And the tooling for plists probably is even more lacking.

There are a few pattern matching libs, and one of them maybe can do the job. The built in one doesn't AFAIK. Managing external dependencies in Guile is a pain at the moment.

Want this functionality OOTB πŸ˜”
clojure.org/guides/destructuri

Colin

@abcdw I felt the pain of dep management in Guile about a year ago when I was playing with it. While "use Guix" is a solution, it isn't a general one.

Andrew Tropin

@shegeley Nice util!

Probably doesn't solve my problem, because with this macro I can't destructure a vector inside alist value and will need to make nested lets anyway :(

Andrew Tropin

@mykhaylo Thank you for the idea.

Probably I forgot to mention: at the moment I write a Guile Scheme code :) And ideally it should be dependency free.

Andrew Tropin

@mykhaylo It's nice and we have the package manager and the whole operating system built on top of it :)

but the ecosystem is kinda fragmented and tooling is a little lacking.

guix.gnu.org/
git.sr.ht/~abcdw/rde

πŸ‡ΊπŸ‡¦ Mykhaylo :emacs: :clojure:

@abcdw I was playing with guix package manager on Asahi Linux the other day and I really liked the idea.

Andrew Tropin

@civodul
Thank you for sharing!

@link2xt shared one almost satisfying solution with pattern matching:
fosstodon.org/@link2xt/1110848

However, I went with let* + assoc-ref and a few alist- helpers. More verbose, but flexible and usually doesn't require nesting.

@jeko

Go Up