samth changed the topic of #racket to: Racket v7.6 has been released: https://blog.racket-lang.org/2020/02/racket-v7-6.html -- Racket -- https://racket-lang.org -- https://pkgs.racket-lang.org -- Paste at http://pasterack.org
badkins has joined #racket
badkins has quit [Remote host closed the connection]
badkins has joined #racket
badkins has quit [Ping timeout: 240 seconds]
acarrico has joined #racket
<greghendershott> bremner: Usually this would mean needing to use `define-syntax` and the template uses `syntax/loc` instead of `syntax` a.k.a. `#'`
<greghendershott> A short thing I wrote about this: https://www.greghendershott.com/2014/01/syntax-loc-and-unit-tests.html
<greghendershott> Having said that, I've found using `define-syntax-rule` often does work fine for location info?
<greghendershott> Maybe it does not do so here, because of other macros involved.
<bremner> that was my uninformed guess
<greghendershott> Like I'm guessing "with-heap" is a macro, and maybe the loc is lost there? Not sure.
<bremner> with-heap and test are both macros.
<bremner> thanks for the example.
<greghendershott> I /think/ even if (say) with-heap were misbehaved, your own test/heap macro could handle the loc fine, but it would mean needing to use define-syntax and syntax/loc. so not quite as convenient.
efm has quit [Ping timeout: 256 seconds]
<greghendershott> You just need to provide some piece of the user's input syntax, as the location for syntax/loc.
<bremner> huh. same behaviour with that approach. http://pasterack.org/pastes/70007
<bremner> the new macro is on line 103
<bremner> I guess I could make a more minimal example and run the macro stepper.
efm has joined #racket
efm has quit [Client Quit]
efm has joined #racket
badkins has joined #racket
badkins has quit [Remote host closed the connection]
badkins has joined #racket
badkins has quit [Ping timeout: 246 seconds]
KDr21 has quit [Remote host closed the connection]
KDr21 has joined #racket
dmiles has quit [Ping timeout: 256 seconds]
<technomancy> https://p.hagelb.org/struct-match.html <- any idea what's wrong with this pattern match? I just get "bad syntax" which doesn't help much
iyzsong has joined #racket
<rmnull> technomancy: u forgot to wrap the parens for each case
<rmnull> https://docs.racket-lang.org/reference/match.html#%28form._%28%28lib._racket%2Fmatch..rkt%29._define%2Fmatch%29%29
<technomancy> hah; of course.
<technomancy> I have a feeling I'm going to be doing that a lot
<technomancy> thanks
<rmnull> np ;)
<technomancy> I'm writing a GUI configurator for my microscheme keyboard firmware; taking some time to get back into the swing of things
<technomancy> right now I've got handlers that call struct-copy on a box with an immutable struct inside; if performance is never going to be an issue does that sound like a decent way to do it?
YuGiOhJCJ has joined #racket
<technomancy> why is #\tab not allowed in a case clause?
<technomancy> huh... for symbols I can put them straight in a clause but for some reason characters must be in lists?
<technomancy> weird
acarrico has quit [Ping timeout: 240 seconds]
libertyprime has joined #racket
dddddd has quit [Remote host closed the connection]
<jcowan> Case uses eqv?, and there is no guarantee that (eqv? #\a #\a) is always true
<jcowan> oops, brain fart. Yes there is.
<jcowan> But (case foo (this ...) (that ...) is bad; it needs to be (case foo ((this) ... ((that) ...))
endformationage has quit [Quit: WeeChat 2.6]
pilne has quit [Quit: Live long and prosper \v//]
Sgeo__ has quit [Read error: Connection reset by peer]
pilne has joined #racket
Sgeo has joined #racket
dmiles has joined #racket
badkins has joined #racket
badkins has quit [Remote host closed the connection]
libertyprime has quit [Read error: Connection reset by peer]
Lowl3v3l has quit [Read error: Connection reset by peer]
Lowl3v3l has joined #racket
Lowl3v3l has left #racket [#racket]
doyougnu has joined #racket
aeth has quit [Ping timeout: 250 seconds]
aeth has joined #racket
sauvin has quit [Ping timeout: 250 seconds]
revtintin has joined #racket
sauvin has joined #racket
badkins has joined #racket
badkins has quit [Remote host closed the connection]
badkins has joined #racket
badkins has quit [Ping timeout: 250 seconds]
libertyprime has joined #racket
nullcone has quit [Quit: Connection closed for inactivity]
badkins has joined #racket
badkins has quit [Remote host closed the connection]
vraid has joined #racket
revtintin has quit [Quit: WeeChat 1.9.1]
libertyprime has quit [Read error: Connection reset by peer]
dddddd has joined #racket
epony has quit [Quit: reconf]
epony has joined #racket
true-grue has joined #racket
acarrico has joined #racket
YuGiOhJCJ has quit [Quit: YuGiOhJCJ]
pilne has quit [Ping timeout: 246 seconds]
iyzsong has quit [Ping timeout: 246 seconds]
pilne has joined #racket
pilne has quit [Read error: Connection reset by peer]
pilne has joined #racket
doyougnu has quit [Remote host closed the connection]
pilne has quit [Read error: Connection reset by peer]
rgherdt has joined #racket
pilne has joined #racket
pilne has quit [Read error: Connection reset by peer]
pilne has joined #racket
badkins has joined #racket
libertyprime has joined #racket
ayerhart has joined #racket
<technomancy> jcowan: what's bad about it? why does it work sometimes and not others?
<bremner> technomancy: last week I learned about evcase
<bremner> which probably doesn't exist in microscheme
<bremner> I guess the case syntax is weird to allow a list of symbols or numbers
<technomancy> bremner: I'm actually past the part where I'm writing in a shared subset
<bremner> I wrote a couple of define-syntax-rules to turn case-like things into conds
<bremner> they don't handle 'else' though
<technomancy> now I'm writing a GUI to let you configure your layout with point-and-click https://hi.technomancy.us/notice/9tFky6iT3mwQApKM3U
<technomancy> the idea is that it would emit a .scm file appropriate for microscheme
<jcowan> technomancy: can you show examples of what works and what does not?
<technomancy> jcowan: (case key ('tab "tab-works") (#\return "return-fails))
<technomancy> jcowan: it's even weirder because the gui frame's callback seems pretty arbitrary about whether keycodes are emitted as symbols or characters
<bremner> weird. I didn't think the () were optional
<jcowan> Ah.
<jcowan> Yes, the parens around the cases are not optional, even if there is only one.
<bremner> or 'tab is secretly (quote tab) ?
<technomancy> bremner: oooooh of course
<jcowan> You need to say ((#\return)) "should work now")
<technomancy> jcowan: yeah, I got that; I was just confused about the inconsistency
<jcowan> What inconsistency?
<jcowan> If the first element of a case clause is not a list, it's a syntax error.
<technomancy> jcowan: because I was thinking of 'tab as a symbol rather than how in that particular context it gets expanded into (quote tab) by accident
<technomancy> because it's never evaluated
<jcowan> right
<jcowan> ' is handy but you need to make quite sure you are using it in a context where an expression is wanted
<technomancy> I should probably just trade that out for a pattern match anyway
<jcowan> (Also, ' is non-hygienic; it means whatever quote is bound to)
<technomancy> haha, god; if I'm rebinding quote I have bigger problems than that
<jcowan> so (let ((quote -)) '32) => -32
<jcowan> Obfuscated Scheme
<jcowan> TIL that Racket's case uses equal? instead of eqv? like most Schemes
<bremner> uh. it does?
<bremner> that is strange for something that only works on symbols and numbers.
<technomancy> really tempted to pull in egal? from rackjure because getting the equivalence procedure wrong is so tedious =\
<jcowan> Yes, you can case-match on strings e.g.
<bremner> oh, I see. yes, that is useful
<technomancy> haha, that was the first macro I ever wrote in elisp
<technomancy> to work around the fact that case is useless for strings >_<
<technomancy> really, really, really stupid
<jcowan> If you poke around you can probably find the definition of case-using, which specifies an equivalence predicate
<technomancy> probably the worst function in my entire file is this one: https://p.hagelb.org/update-layout.html
<technomancy> where I update a nested vector inside a struct
<technomancy> the only ways to make that less awful are lenses or mutability; is that accurate?
<jcowan> What does vector-set return? I am only familiar with vector-set!.
<technomancy> oh shoot; right; I had to define that myself
<technomancy> vector-set is the immutable equivalent; it returns a new vector with the one slot updated
<technomancy> for context; the whole file: https://p.hagelb.org/gui.rkt.html
<technomancy> maybe I should just write this as an imperative program instead of using immutability
<bremner> in principle it should be fast enough to use hash-set for vector-set
<bremner> i.e. just use immutable hash-tables instead of vectors.
<technomancy> bremner: I don't care about speed really, but the data is conceptually very linear
<technomancy> having it print to the repl in undefined order would be very awkward
<jcowan> A way to make it more legible is to let your vector-set take any (even) number of arguments
<technomancy> jcowan: it's not setting multiple things in one vector, it's setting an element in one vector nested inside another
<jcowan> Oh, of course it is.
<jcowan> SFTN
<technomancy> in clojure you could do this with (update-in st [:layouts (:layout st) (selected st)] (keycode-for key))
<technomancy> and I've done something like that with lenses in the past, but I'd rather avoid 3rd-party libraries if possible
sauvin_ has joined #racket
<technomancy> I'm not that concerned about concurrency or having this program get too big; a mutable struct and vector would probably be a lot simpler here.
sauvin has quit [Ping timeout: 250 seconds]
sauvin_ is now known as sauvin
libertyprime has quit [Read error: Connection reset by peer]
nullcone has joined #racket
CoderPuppy has quit [Quit: Breaking stuff]
cpup has joined #racket
<samth> jcowan: racket's case uses eqv?
<samth> rudybot: init racket/base
<rudybot> samth: error: with-limit: out of time
<samth> rudybot: init racket/base
<rudybot> samth: your racket/base sandbox is ready
<jcowan> samth: It's documented as using equal?, unlike R[567]RS and any other Scheme I know of.
<samth> rudybot: (case (string #\a) [("a") 1] [else 'jcowan])
<rudybot> samth: ; Value: 1
<samth> weird, that must have changed at some point
<jcowan> Probably when somebody wrote case clauses with literal strings and complained because they didn't work.
badkins has quit [Remote host closed the connection]
badkins has joined #racket
badkins has quit [Remote host closed the connection]
zenen has joined #racket
<zenen> hi everyone! does racket have some sort of built in lambda reduction that can output a reduced lambda function from a more complicated one?
N0S4A2 has joined #racket
<zenen> I've got an assignment which is asking us to reduce a lambda expression in both normal and applicative order and then confirm which is the order used in racket. When I input the function, however, the output is always #<procedure>
<zenen> the function, if it helps with context, is (lambda (f) (lambda (x) (f (f x))) (lambda (f) (lambda (x) (f (f x)))) f x)
<bremner> I could be wrong, but I think racket procedures are not "reduced" until you run them. So maybe "trace" would be more useful that display/print
badkins has joined #racket
cpup has quit [Read error: Connection reset by peer]
cpup has joined #racket
badkins has quit [Remote host closed the connection]
rmnull has quit [Quit: WeeChat 2.7.1]
rmnull has joined #racket
badkins has joined #racket
true-grue has quit [Ping timeout: 250 seconds]
rgherdt has quit [Ping timeout: 246 seconds]
badkins has quit [Remote host closed the connection]
<technomancy> how hard you figure would it be to port this 3.5kloc C compiler to racket? https://ryansuchocki.github.io/microscheme/
badkins has joined #racket
<technomancy> I bet most of it would be redundant
<technomancy> you'd probably mostly just be porting this one file https://github.com/ryansuchocki/microscheme/blob/master/src/codegen.c
<jcowan> technomancy: What would be the point of porting the compiler other than the lulz?
<jcowan> Something that runs ms programs in your favorite Scheme would be much easier to provide.
<jcowan> But the documentation is really lacking.
<technomancy> jcowan: I'm adding basic stuff like `when' and `getenv' and `cond' in C and ... C is a very bad language to write a compiler in
<technomancy> it's just tedious
* jcowan nods
<technomancy> and there's not even a macro system
<technomancy> plus I've never done a #lang before =)
<aeth> huh? when is just (if test (begin body) #<undefined>) or something along those lines
<aeth> why use C for it?
<aeth> Scheme only really needs if and lambda in the host language afaik
<jcowan> Oh, just add psyntax or alexpander in front
<jcowan> aeth: No macros in ms
<technomancy> aeth: I didn't choose C
<aeth> jcowan: oh
<technomancy> I think this guy chose it so he could get a masters thesis out of it
badkins has quit [Ping timeout: 258 seconds]
<aeth> but, hey, it uses C so it has "macros" anyway ;-)
<technomancy> because if you did it in racket it would be too easy =P
<jcowan> You don't need a #lang
<jcowan> you just use read to process the input file, since the lexical syntax is a subset of Scheme's.
<technomancy> sure; that would be fine too
<aeth> technomancy: if you did it in Racket, then it wouldn't be too hard to port it to the language itself and thus make it a self-hosting compiler, which is more impressive
<technomancy> aeth: hah, well, that won't work with this one
<technomancy> microscheme runs on computers that have 2.5kb of ram
<jcowan> it would actually: you underestimate how limited ms is.
<aeth> ah
<jcowan> Self-hosting in the sense that the ms compiler is written in ms, not that the compiler runs on an Arduino.
<technomancy> maybe, if you added a bunch of PC-only extensions for stuff like filesystem IO, but at that point ... eh
<aeth> sorry, I didn't realize it was micro as in microcontroller not micro as in ultraminimalist
<aeth> although, yes, you could still get the compiler to run on a PC in the language itself