
Is there a way to define methods of classes that can only be called from objects belonging to the same class without defining them as public
?

i.e., something like public
but only for objects of the same class.

@pocmatos I recommend using define-local-member-name
for this

Hi everyone! Just started recently using Racket for a personal project (and liking it so far!)… Little question: I need a map from keys to values, but also need to preserve the order of insertion. I was about to implement it myself as a list of pairs but I am actually wondering: is there any builtin Racket data structure suitable for that? Many thanks! :slightly_smiling_face:

@dnf85 I think that the ddict package gives you that: http://docs.racket-lang.org/ddict/index.html

Oh right, saw that few mins ago, but just wanted to make sure! thanks!

~you can also use the racket/dict
interface (to a list of pairs)~ (nvm, I don’t think its guaranteed to preserve order)

you mean I can implement my own data structure and then make it implement that interface? (still don’t know how interfaces work in Racket unfortunately, still reading Realm of Racket)

oh OK :slightly_smiling_face:

I’ll look at ddict then!


Thanks! Yes, looks like it does preserve ordering (I played around with the example)… not entirely sure what happens if you remove/add something though. Will look into it.

yep, looks like this is what I want! will use association list as I wanted to do initially but can also use all the stuff provided by Racket since it is a ‘dict?’ Cool! (and, after more tests, looks like there’s no problem with the ordering) :slightly_smiling_face:

Thanks!

@null has joined the channel