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)
Maybe the compiler does that automatically? I guess it does that for constant math expressions to some extent at least
For this specific case, unfortunately it currently doesn’t do that
aw too bad
#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))
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?
You could definitely add that, either in schemify or in cp0
@callan.mcgill has joined the channel
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?
Is “find.rkt” the name of your script?
yes, it is
Ah! It’s the output of the grep
command.
Since grep mod
looks for file that contains “mod” it finds the file file “find.rkt” which of course … contains a line with “mod”.
hahaha, how silly I am
thank you very much
So grep first prints the file name, then a colon, then the line of the file.
:slightly_smiling_face:
If only you had other files that also contains “mod” you would have spotted it.
another question, this doesn’t work: find "." -name (glob "*.hs")
as it says: /usr/bin/find: missing argument to `-name’
I would have thougth this is identical to find . -name *.hs
, am I misunderstanding how it should work?
Try echo find "." -name (glob "*.hs")
I’m just trying to get a feel for rash as it seems v cool
and see what the command becomes.
ah, nice debugging tip, thank you!
Maybe you don’t have any .hs files?
The command becomes find . -name
, this also explains why grep
included a .rkt
file in the previous output
I think glob
maybe doesn’t work how I expect
I think, glob
computes the list of file names and then inserts it in the command.
But if you don’t have any .hs file, it inserts the “empty string” (i.e. nothing).
ah yeah, I am just doing the wrong thing with it
ok great
this DSL is really cool
Agree.
That really helps me out, thank you for your pointers