bedeke
2020-11-17 10:49:34

Hi, is this supposed to type-check? (it currently does) : #lang typed/racket/base (: test1 (->* [Integer] [Integer Integer] Integer)) (define (test1 a [b 'symbol]) (cond [(and a b) 1] [else 2])) (define (run1) (test1 0 1 2)) I expected that the arity mismatch and type mismatch for the second argument would be caught. I can make an argument for the default argument. Also for a more restrictive type arity definition, but not a more permissive as I have here.


samth
2020-11-17 14:45:11

That arity mismatch should definitely be caught


badkins
2020-11-17 22:43:38

I’m curious how frequently used the generic-bind package is. I was reviewing/tweaking some old code that was discussed <https://groups.google.com/g/racket-users/c/6Lk1BHmpNjc/m/CTO-fwzZUfUJ|on the mailing list> and came across both https://github.com/AlexKnauth/defpat\|defpat and https://docs.racket-lang.org/generic-bind/index.html\|generic-bind . Given Racket’s capabilities, I would think nice deconstruction forms would be commonly used, but my impression is that they aren’t. I’m curious if I’m wrong, or if right, why.


badkins
2020-11-17 22:52:15

It’s nice that I don’t have to create a custom stream, but I think I’m not crazy enough about the syntax to use it i.e. (neighbor dst) vs. ($ (cons neighbor dst)) (for/list ([ (neighbor dst) (pair-stream pairs) ]) (cons p dst)) (~for/list ([ ($ (cons neighbor dst)) pairs ]) (cons p dst))


wanpeebaw
2020-11-18 02:01:51

What is the best way to dynamically read the program and convert it into Racket code and evaluate it? I use eval to evaluate a code snippet and experience performance degradation.

cpu time: 466 → cpu time: 2565

Only measure the execution time, not compile time.


samth
2020-11-18 02:17:13

My first thought is that your program isn’t in a module, and that’s causing the slowdown


wanpeebaw
2020-11-18 02:28:50

Yes, I just wrap whole code into a block and evaluate it with (eval code ns). How can I improve it?


samth
2020-11-18 02:30:54

Well, first check if my hypothesis is right


samth
2020-11-18 02:31:14

But if so, you would need to put the code in a module


wanpeebaw
2020-11-18 02:46:58

Thanks, I wrapped it with (module temp racket …), now it performs the same.


kellysmith12.21
2020-11-18 07:38:44

Are there best practices for documenting a #lang that reexports several functions from another library (e.g. the Racket stdlib)?


kellysmith12.21
2020-11-18 07:39:33

For example, should the language’s documentation provide its own documentation of those functions, or should it just link to the original library’s documentation?