pocmatos
2017-2-17 09:22:18

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?


pocmatos
2017-2-17 09:22:51

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


samth
2017-2-17 14:22:32

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


dnf85
2017-2-17 20:36:45

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:


florence
2017-2-17 20:37:50

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


dnf85
2017-2-17 20:39:18

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


ben
2017-2-17 20:39:30

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


dnf85
2017-2-17 20:42:13

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)


dnf85
2017-2-17 20:42:23

oh OK :slightly_smiling_face:


dnf85
2017-2-17 20:43:05

I’ll look at ddict then!


ben
2017-2-17 20:46:28

dnf85
2017-2-17 21:01:33

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.


dnf85
2017-2-17 21:11:58

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:


dnf85
2017-2-17 21:12:02

Thanks!


null
2017-2-18 01:17:43

@null has joined the channel