joelmccracken
2019-5-26 16:40:18

I looked at all the filename/path functions, but cant seem to find a good way to get the basename of a file. any suggestions?


soegaard2
2019-5-26 16:40:53

@joelmccracken Btw - I think I got an idea about the problem yesterday.


joelmccracken
2019-5-26 16:41:02

oh cool


soegaard2
2019-5-26 16:43:08

If you add an @(require "set-globals.rkt") to you pm-file, then you will run the setters at the right time.


soegaard2
2019-5-26 16:46:22

Maybe file-name-from-path ?


joelmccracken
2019-5-26 16:46:31

Idk that sounds like it would have the same issue


joelmccracken
2019-5-26 16:46:49

beign in a different “environment” from the main script, build.rkt


soegaard2
2019-5-26 16:47:14

Could be.


greg
2019-5-26 19:10:08

@joelmccracken By “basename” you mean name.ext or just name in /path/to/name.ext?




greg
2019-5-26 19:12:28

p.s. These all will work with C:\path\to\name.ext as well.


todo
2019-5-26 19:23:49

I am familiar with Clojure style macros (a macro is a function that takes sexp as input, produces sexp as output, and often uses lots of quasiquote / unquote).

I am interested in learning Racket style “hygienic” macros. Is there a good resource that focuses on walking me through lots of examples (as opposed to explaining lots of theory) ?



githree
2019-5-26 19:24:52


todo
2019-5-26 19:44:05

@githree: Thanks!


joelmccracken
2019-5-26 23:08:11

sorry @greg I was def incorrect, i thought unix basename returned foo out of basename baz/foo.tar.gz, but it actually returns foo.tar.gz


joelmccracken
2019-5-26 23:08:59

i meant that I just wanted foo. I actually hacked around it by doing (first (string-split filename "."))


joelmccracken
2019-5-26 23:09:34

context is that i was hoping to get my-post out of <http://my-post.html.pm\|my-post.html.pm>


joelmccracken
2019-5-26 23:10:19

so using replace-extension i’d have to apply it repeatedly until it comes to a fixed point


joelmccracken
2019-5-26 23:10:35

(which sounded worse to me)


joelmccracken
2019-5-26 23:11:19

I guess i was thinking that maybe there could be a package out there that I just don’t know about that adds all kinds of niceties to do this kind of thing


joelmccracken
2019-5-26 23:11:52

(i’m still pretty new to Racket, so I apologize to everyone for the repeated “how do I do x?” queries, lol)


joelmccracken
2019-5-26 23:32:35

just saw the function ~a, good idea


matias
2019-5-27 03:07:49

oh ok, cool


carl.morris.world
2019-5-27 03:29:36

I have question about scope of let-syntax. I wanted to eval a quoted sexp inside a let-syntax, but it didn’t work. I solved it by moving the syntax definition into a top level define-syntax. The goal was to take the output of a lang brag parser and expand the resulting quoted sexp using some syntax defined in the let-syntax. The point of using the let-syntax was so that the syntax could be parameterized by the enclosing function’s arguments. Maybe eval was the wrong tool? Or am I trying to do something peculiar?


carl.morris.world
2019-5-27 03:31:42

To clarify I had expected let-syntax to add its bindings to current-namespace, but it didn’t. I am guessing I don’t quite understand how namespaces work with let type bindings.


soegaard2
2019-5-27 06:48:30

@carl.morris.world Sounds like a job for local-expand.