

yup this is wack and makes stuff weird


but really, just, don’t use cons
pairs to represent arbitrary pairs of things

just let lists be lists and if you have a pair of two things, make a struct for them

if only so you get useful names for the fields

assocs are very useful dictionaries though, memory and time efficient for few entries, and very easy to manipulate

I’d much rather have something that prevents duplicate keys

I don’t disagree though it’s not a bug I’ve had often, nor that I can recall lost me a lot of time

and there’s certainly a lot more functions for transforming lists than there are for transforming hash tables

(the fact that hash-filter
returns a list is incredibly evil)

It’s also quite nice to be able to sort the dictionary, in particular for printing

( this can even be used for better performance than with hashes in some cases)

yeah sorted maps are an important use case

ideally I’d just have a good API for that specifically

As long as it’s as efficient :p

I think there’s a package that does that

Or something in data/

The usual toy interpreter in intro to prog lang usually implements an environment with an assoc list, with duplicate keys

It’s really easy to implement it. Adding a value is just consing to the front. No need to check for duplication.

to deal with the problems discussed in the original post, could we just do that with entry
structs instead of cons cells for the mappings http://docs.racket-lang.org/rebellion/Entries.html\|docs.racket-lang.org/rebellion/Entries.html

(list (entry 'a 1) (entry 'b 2))
instead of (list (cons 'a 1) (cons 'b 2))

Of course, if what you want is a singly linked list of tuples

Usually i just have a list a struct objects

And I often even use #:prefab so I can easily write/read

A classic use case I often have currently is to read log files that contain many entries in text form. I parse them with match and regexps, generate a list of #s(info ...)
(although entry
is a good name), then a #s(summary ...)
with some stats about the infos, and cache everything to a file for faster loading next time.

(I should probably write a small lib at some point… there’s already with-input-from-file/cache
in bazaar/file
though, but bazaar
is unstable)

In my lang, there is no cons
, and lists are always proper (specifically, I just provide rebellion/collection/list
). I also use different syntax for rest arguments, so dot syntax is unnecessary. For example, instead of (λ (a . rest) <body>)
, there is {λ a rest ... ⇒ <body>}
, borrowing the ellipses syntax from syntax templates.