pocmatos
2018-6-18 07:47:44

@ma77rix go ahead. Everyone else is on the other side of planet earth, therefore sleeping. :slightly_smiling_face:


pocmatos
2018-6-18 12:07:10

How can I specify #:methods on structure types created with make-struct-type? Surely this is possible but the docs on make-struct-type doesn’t even refer to #:methods.


pocmatos
2018-6-18 12:07:38

Is there maybe a correspondence between methods and properties that I can advantage of and maybe specify methods as properties?


samth
2018-6-18 12:30:23

I don’t think there’s currently a supported way to do that


pocmatos
2018-6-18 12:36:42

really? that’s really strange.


pocmatos
2018-6-18 12:38:27

I was just reading racket code to understand how deep the rabbit hole goes.


pocmatos
2018-6-18 12:38:32

This line here



pocmatos
2018-6-18 12:38:44

seems to be where #:methods are handled.


pocmatos
2018-6-18 12:38:55

somehow this seems to convert methods into properties.


pocmatos
2018-6-18 12:39:34

Unfortunately though, the operations used to do this are not exported, like generic-property.


pocmatos
2018-6-18 12:41:23

What this seems to mean is that there’s no way to implement struct-types at runtime which implement a set of generic methods, which would be quite a serious shortcoming for someone who really needs these things. me


shu--hung
2018-6-18 16:38:36

I think struct definitions work at runtime too


shu--hung
2018-6-18 16:41:57

#:methods is internally implemented using struct properties and the APIs here https://github.com/racket/racket/blob/master/racket/collects/racket/private/generic-methods.rkt


shu--hung
2018-6-18 16:42:09

but I think struct properties is all what make-struct-type knows


pocmatos
2018-6-18 19:23:17

@shu—hung ok, I am actually quite surprised that you are right. i was quite sure this was not going to work: (define (make-s) (struct foo (a b) #:mutable #:extra-constructor-name make-foo) make-foo) but it did.


shu--hung
2018-6-18 19:33:35

yeah struct expands to call to make-struct-type at runtime


githree
2018-6-18 20:39:23

is there any way to make this: (assq 'select '((SELECT . "dummy") (DROP . "hat"))) return the first pair - to make the comparison case insensitive?


samth
2018-6-18 20:40:08

@githree maybe use assf and a comparison function?


githree
2018-6-18 20:43:53

I tried this: (assf (lambda (arg) (eq? 'select #ci arg)) '((SELECT . "dummy") (DROP . "hat"))) but no success


githree
2018-6-18 20:46:41

I could do symbol->string and then use string-ci=? but was wondering if there was more elegant solution


samth
2018-6-18 20:50:31

@githree that’s what I would do


githree
2018-6-18 20:50:40

ok, thanks


ma77rix
2018-6-18 21:08:43

thanks, I found this common lisp doc http://www.lispworks.com/documentation/HyperSpec/Body/m_do_do.htm with more examples which is helpful, but Im not sure that it works in racket, is there any doc about comparing racket and common lisp ?


ma77rix
2018-6-18 21:09:57

another question is I’m still not clear about continuation and lambda, could you guys pls recommend some good article/book about them ?


samth
2018-6-18 21:10:18

Common Lisp and Racket have a common ancestor about 40 years ago, so taking code from one to the other isn’t going to be very helpful


ma77rix
2018-6-18 21:11:48

I found racket do doc first, but it doesn’t explain var in do loop https://docs.racket-lang.org/reference/for.html


samth
2018-6-18 21:11:53

those are both big topics — I would recommend books like “The Little Schemer”, “How to Design Programs”, or others


ma77rix
2018-6-18 21:12:23

i see, thanks :+1:


samth
2018-6-18 21:12:48

Racket programmers don’t usually use do at all


ma77rix
2018-6-18 21:14:24

you mean we should use recursion instead of do ?


ma77rix
2018-6-18 21:15:24

just start learning racket


samth
2018-6-18 21:17:02

I would use for and other related loop constructs


samth
2018-6-18 21:17:23

if you’re new to racket, I recommend the “Realm of Racket” book as well


ma77rix
2018-6-18 21:19:56

will go check it. thanks :slightly_smiling_face:


greg
2018-6-19 01:57:26

I like that xrepl is enabled by default these days, but. How can I temporarily disable it? (I want to experiment with racket -it program-using-datalog.rkt, and rule out xrepl contributing to the problem.)


greg
2018-6-19 01:59:16

Oh -q seems to do the trick.


lexi.lambda
2018-6-19 02:00:03

greg
2018-6-19 02:02:27

Thanks, that is indeed where I found -q just now. :slightly_smiling_face:


ma77rix
2018-6-19 06:35:20

Hello, I know the meaning of each expression, but don’t understand why we need values in the for loop ? (for/fold ([sqrs 0] [count 0]) ([i '(1 2 3 4 5 6 7 8 9 10)]) (values (+ (sqr i) sqrs) (if (> (sqr i) 50) (add1 count) count)))


pocmatos
2018-6-19 06:40:13

@ma77rix You need values in the for loop because you are folding over 2 values.


pocmatos
2018-6-19 06:40:27

No values are needed if folding over a single value.


pocmatos
2018-6-19 06:40:42

You are folding over sqrs and count.


pocmatos
2018-6-19 06:41:31

To add all the elements of a list with for/fold: (for ([accum 0]) ([i (in-range 10)]) (+ accum i))


pocmatos
2018-6-19 06:41:52

No values needed as you are accumulating a single value.


ma77rix
2018-6-19 06:44:46

Thanks Paulo. I got it, but why ? why we need values when for/fold more than one value ?


jboyens
2018-6-19 06:48:55

My Racket app spawns another process. What’s the best way to ensure no matter what happens, that process gets cleaned up? I looked around at custodians, but it doesn’t seem quite right. Neither do some searches for finalizers.


jboyens
2018-6-19 06:48:59

Any suggestions?


pocmatos
2018-6-19 06:58:20

@ma77rix what would the alternative be? You need to state the values to use in the next loop iteration.


pocmatos
2018-6-19 06:59:07

@jboyens are these threads or places or subprocesses?