rokitna
2022-2-2 10:44:17

it’s possible to write a macro that concatenates the given strings at compile time, too:

(define-syntax-parse-rule (string-append/compile-time s:str ...) #:with result (apply string-append (syntax->list #'(s ...))) result)


laurent.orseau
2022-2-2 10:45:19

Maybe the compiler does that automatically? I guess it does that for constant math expressions to some extent at least


sorawee
2022-2-2 10:48:03

For this specific case, unfortunately it currently doesn’t do that


laurent.orseau
2022-2-2 10:48:28

aw too bad


sorawee
2022-2-2 10:48:52

#lang racket/base (string-append "abc" "def") ;; cp0 --------------------- (lambda (instance-variable-reference .get-syntax-literal!1 .set-transformer!2 print-values3) (call-with-module-prompt (lambda () (#%call-with-values (lambda () (#3%string-append "abc" "def")) print-values3))) (#2%void))


laurent.orseau
2022-2-2 10:50:31

seems to be a legitimate case that warrants an additional compilation case, so as to allow people to actually write in a good style without the runtime cost?


samth
2022-2-2 15:43:28

You could definitely add that, either in schemify or in cp0


callan.mcgill
2022-2-2 18:52:22

@callan.mcgill has joined the channel


callan.mcgill
2022-2-2 18:53:41

I am trying to use rash for the first time and having some unexpected (to me). I have the following script: #!/usr/bin/env racket #lang rash (require racket/port) (require file/glob) echo blah blah grep -r mod -i (glob "*.hs") ls -a When I execute this on the command line I get: blah blah find.rkt:grep -r mod -i (glob "*.hs") hask/A.hs:module A where . .. find.rkt find.rkt~ hask lint-hs.rkt I don’t know why it prints that line: find.rkt:grep -r mod -i (glob "*.hs"), any ideas?


soegaard2
2022-2-2 19:09:02

Is “find.rkt” the name of your script?


callan.mcgill
2022-2-2 19:09:19

yes, it is


soegaard2
2022-2-2 19:11:43

Ah! It’s the output of the grep command.


soegaard2
2022-2-2 19:12:22

Since grep mod looks for file that contains “mod” it finds the file file “find.rkt” which of course … contains a line with “mod”.


callan.mcgill
2022-2-2 19:12:36

hahaha, how silly I am


callan.mcgill
2022-2-2 19:12:42

thank you very much


soegaard2
2022-2-2 19:12:47

So grep first prints the file name, then a colon, then the line of the file.


soegaard2
2022-2-2 19:12:49

:slightly_smiling_face:


soegaard2
2022-2-2 19:13:36

If only you had other files that also contains “mod” you would have spotted it.


callan.mcgill
2022-2-2 19:14:07

another question, this doesn’t work: find "." -name (glob "*.hs") as it says: /usr/bin/find: missing argument to `-name’


callan.mcgill
2022-2-2 19:14:32

I would have thougth this is identical to find . -name *.hs, am I misunderstanding how it should work?


soegaard2
2022-2-2 19:14:41

Try echo find "." -name (glob "*.hs")


callan.mcgill
2022-2-2 19:14:42

I’m just trying to get a feel for rash as it seems v cool


soegaard2
2022-2-2 19:14:53

and see what the command becomes.


callan.mcgill
2022-2-2 19:15:16

ah, nice debugging tip, thank you!


soegaard2
2022-2-2 19:15:28

Maybe you don’t have any .hs files?


callan.mcgill
2022-2-2 19:15:59

The command becomes find . -name, this also explains why grep included a .rkt file in the previous output


callan.mcgill
2022-2-2 19:16:09

I think glob maybe doesn’t work how I expect


soegaard2
2022-2-2 19:16:35

I think, glob computes the list of file names and then inserts it in the command.


soegaard2
2022-2-2 19:16:56

But if you don’t have any .hs file, it inserts the “empty string” (i.e. nothing).


callan.mcgill
2022-2-2 19:17:00

ah yeah, I am just doing the wrong thing with it


callan.mcgill
2022-2-2 19:17:02

ok great


callan.mcgill
2022-2-2 19:17:12

this DSL is really cool


soegaard2
2022-2-2 19:17:42

Agree.


callan.mcgill
2022-2-2 19:17:44

That really helps me out, thank you for your pointers