hoshom
2020-11-27 08:23:36

Maybe racket has something like python’s textwrap.dedent ? In python you’d write a multiline string, indented as normal, and then use dedent(s)


sorawee
2020-11-27 09:29:47

That sounds like what @-exp does already


phanthero
2020-11-27 09:31:34

Just spent an hour reading about @-exp syntax


phanthero
2020-11-27 09:43:03

#lang at-exp racket (displayln @string-append{ This is a long string. No worries about escaping "quotes" or \escapes. It's also okay to have λ, γ, θ, ... Embed code: @(number->string (+ 3 4)) }) becomes #lang at-exp racket (displayln @string-append{ This is a long string. No worries about escaping "quotes" or \escapes. It's also okay to have λ, γ, θ, ... Embed code: @(number->string (+ 3 4)) }) when indented with Racket Mode in Emacs….. why……


phanthero
2020-11-27 09:43:15

guess I’ll manually indent this file


laurent.orseau
2020-11-27 09:44:23

In DrRacket, indentation is wrong after typing a newline, but then reindenting (tab) works well (better at least).


soegaard2
2020-11-27 10:25:54

Small tip: You can write ~a instead of string-append here.


phanthero
2020-11-27 10:48:51

Nice! Thanks


laurent.orseau
2020-11-27 10:57:07

Though, similarly to scribble, you may prefer to use something like flat-strap (name to be refined to your taste) instead of ~a or string-append so you can use nested lists and remove all parentheses: #lang at-exp racket (define (flat-strap . l) (string-append* (map ~a (flatten l)))) (displayln @flat-strap{ Here's a sequence: @(for/list ([i (in-range 10)]) (list i ": " (sqr i) ", ")) Cool, eh?}) Renders:


laurent.orseau
2020-11-27 10:57:09

Here's a sequence: 0: 0, 1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81, Cool, eh?


laurent.orseau
2020-11-27 10:59:15

The nice thing about ~a is that it will turn non-strings into strings.


phanthero
2020-11-27 11:15:19

How is it possible that this is exactly what I was looking for?


phanthero
2020-11-27 11:15:22

Thanks!


phanthero
2020-11-27 11:57:51

I guess I needed to realize that pretty much everything can come after the @, even things like for, if, cond etc


joshibharathiramana
2020-11-27 18:16:33

how would I do that?


sorawee
2020-11-27 18:28:20

(require (only-in racket define))


greg
2020-11-27 18:54:52

Why: So it looks good. :smile: Note that at-expressions strip the leading spaces, so it’s fine.


greg
2020-11-27 18:56:14

As for at-expressions in general, you’ve probably already discovered all this in other docs, but here’s a blog post I wrote with a few ideas and tips. https://www.greghendershott.com/2015/08/at-expressions.html


greg
2020-11-27 18:57:51

@phanthero ^


joshibharathiramana
2020-11-27 23:21:13

Are there any mnemonics to not confuse between how module , module* and module+ work?


robbiehk131
2020-11-28 02:44:44

Is there a way to disable garbage collector? I want to see how much time it takes to run a piece of code without collecting garbage.


samth
2020-11-28 02:56:34

There’s an environment variable which is probably mentioned in the reference page on garbage collection


samth
2020-11-28 02:57:42

PLTDISABLEGC


robbiehk131
2020-11-28 03:18:27

I tried using (putenv "PLTDISABLEGC" "Y") , but the time procedure still shows gc time.


phanthero
2020-11-28 03:24:12

Yes, I like how you’re doing this as well: (define px pregexp) @px{\d\.\d} ; #px"\\d\\.\\d" lol. Yeah, just using functions with smaller names seems to fix up the indentation issue, so using ~a is better than using string-append probably. Thanks. I know there’s no good solution to this and you probably thought about this a lot when implementing this kind of indentation.


kellysmith12.21
2020-11-28 04:14:07

Are there require and provide shorthands for several modules from the same collection/subcollection? That is, instead of (require mycollect/subcollect/mod1 mycollect/subcollect/mod2 mycollect/subcollect/mod3 mycollect/subcollect/mod4) I could just have something like (require (many mycollect/subcollect mod1 mod2 mod3 mod4))


samth
2020-11-28 04:20:16

you need to set it on the command line when racket starts up


samth
2020-11-28 04:20:37

you can’t pause GC for a period of time


sorawee
2020-11-28 04:46:05

Yes, see multi-in



kellysmith12.21
2020-11-28 05:01:15

Will that work in an (all-from-out ...) form?


sorawee
2020-11-28 05:04:05

I’m confused. You are talking about require-ing, right? But all-from-out is a provide-ing form.


kellysmith12.21
2020-11-28 05:04:42

I was looking for shorthands to use in both require and all-from-out.


kellysmith12.21
2020-11-28 05:05:02

Sorry, I should’ve been more clear.


sorawee
2020-11-28 05:06:33

AFAIK there’s no shorthand for all-from-out, but you should be able to write one yourself using the provide transformer protocol (and this is actually how multi-in was written: as a require transformer)


robbiehk131
2020-11-28 05:15:54

Gotcha, thanks!