
@leif seems like you could just have the version on your web page have the corrections in it

oh, i think sxml might, thanks @notjack ; fyi @zenspider yes map works fine, but i was hoping to do something like “replace every <a>
node with a different node”, which ends up being pretty verbose to do recursively

@samth Yup. And I will do that soon. But it also seems reasonable to point out the diffs explicitly.

At the moment, searching for foo
on https://pkgs.racket-lang.org/ goes to https://pkgd.racket-lang.org/pkgn/search?q=foo which spins for a minute before giving 502 Proxy Error
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /pkgn/search.
Reason: Error reading from remote server
Apache/2.4.7 (Ubuntu) Server at <http://pkgd.racket-lang.org\|pkgd.racket-lang.org> Port 443

Not sure if that’s a bat signal for @jeapostrophe @tonyg @cfinegan or other

New topic. This surprised me:
$ echo "#lang racket" > lang.rkt
$ echo "(module mod racket)" > mod.rkt
$ racket -e '(require syntax/modread) (with-module-reading-parameterization (λ () (with-input-from-file "lang.rkt" read)))'
'(module lang racket (#%module-begin))
$ racket -e '(require syntax/modread) (with-module-reading-parameterization (λ () (with-input-from-file "mod.rkt" read)))'
'(module mod racket)
That is, #lang
files get #%module-begin
added on read
, but module expression files do not. Even using with-module-reading-parameterization
and expand-to-top-form
doesn’t add #%module-begin
.

Of course it’s N/A in most cases because you’d probably expand
that before rewriting it, like the errortrace
and gui-debugger
annotators do, and that will add the #%module-begin
. (I just had an odd situation where I can’t expand
the whole thing.) ¯_(ツ)_/¯

here, with-module-reading-parameterization
won’t change that, because read
in the second case is really just producing some s-expressions

expand-to-top-form
doesn’t change that because module
is a top-form

I think the difference is that the reader for #lang
(or maybe for racket
) adds the #%module-begin
, not some part of read
itself

@jimmy has joined the channel

(define/match (board-ref . args)
[(r c) (board-ref board (->coord r c))]
[(rc) (hash-ref (board-b board) rc)])
;; battleship.rkt:42:3: match: wrong number of match clauses, expected 1 and got 2
;; in: (r c)
clue me? I thought dotting the args was the right way to do variable arity

also really confused why that is about the number of clauses… not the pattern itself?

I think you want ((list* r c))
instead of (r c)

First, I think the number of sub-patterns in each match*-pattern needs to be the same — and needs to be equal to the number of arguments, where the rest argument counts as 1.

or ((cons r c))

same as: [(`(,r ,c)) (board-ref board (->coord r c))], yes?

gah

damnit

generally I avoid quoting in match patterns, they’re a complex enough grammar as is

unless matching against something with lots of symbolic literals I want to ignore

I got tangled up rewriting this and forgot the board argument… now it passes tests:
(define/match (board-ref . args)
[(`(,board . (,r ,c))) (board-ref board (->coord r c))]
[(`(,board . (,rc))) (hash-ref (board-b board) rc)])

I’m not sure how to say that in non-quotey form. cons… list* ?

list-rest?

well, the first one could just be list

FWIW maybe a define/convert
utility would be appropriate:
(define/convert (board-ref b (rc #:convert ->coord))
(hash-ref (board-b board rc)))

I’ve never seen that… cool, thanks

wait. I’ve never seen that because it doesn’t exist?

it doesn’t, I’m hypothesizing

haha

I don’t think it’d be tricky to make though

oh wait you’re using multiple arguments to mean a list?

ok. they can both be plain list patterns… that does seem cleaner

how is board-ref
supposed to be called exactly? either (board-ref b r c)
or (board-ref b coord)
?

(define/match (board-ref . args)
[((list board r c)) (board-ref board (->coord r c))]
[((list board rc)) (hash-ref (board-b board) rc)])
;; vs
(define/match (board-ref . args)
[(`(,board ,r ,c)) (board-ref board (->coord r c))]
[(`(,board ,rc)) (hash-ref (board-b board) rc)])

yes, both. I’m gonna have to use one for a wire protocol and don’t want to write string->coords
but I want to write clean and easy tests and internal playtesting

is there a parameter or something to un-truncate test failure output?

for rackunit? how is your output being truncated?

the error coming up for match failures includes the call args, which is a 10x10 board… but the tail is the important part for me

ohhh

moot point now, but I’d like to roll that up in some handler

I’d be surprised if there’s a way to do that at all

you could make your board print differently with gen:custom-write

boo

huh, there’s no define/case
built in to racket for use with case-lambda

huh. haven’t used that one either… not sure when I’d want to pick that over the match one

case-lambda
will report better arity information in this case

the define/match
form constructs a function with an arity claiming to accept any number of arguments, but I think case-lambda
is smarter than that and makes a function that knows it accepts either two or three arguments

(define-simple-macro
(define/case f:id (~and clause [(arg:id ...) body:expr ...+]) ...)
(define f (case-lambda clause ...)))
(define/case board-ref
[(b r c) (board-ref b (->coord r c))]
[(b rc) (hash-ref (board-b b) rc)])

yeah.. the arity mismatch message truncates the one arg and shows the rest. that’s nice

(define-simple-macro (define/case name (formals body ...+) ...)
(define name (case-lambda [formals body ...] ...)))
(define/case board-ref2
[(board r c) (board-ref2 board (->coord r c))]
[(board rc) (hash-ref (board-b board) rc)])

Is there a cleaner/better way of saying either of these things?
(define (board->string board)
(string-join
(for/list ([r (in-list rows)])
(string-join
(for/list ([c (in-list cols)])
(->marker (board-ref board r c)))))
"\n"))
(module+ test
(check-equal? (board->string (make-board))
(string-join
(for/list ([r (in-list rows)])
". . . . . . . . . .")
"\n")))

I want to have something like build-string
that takes a proc that returns strings (or just a string duplicated N times)

Basically Ruby’s String#*

but board->string
also feels stilted

there’s a bug in GUI’s rectangles:
(require racket/gui/base)
(define (draw-box broken)
(define canvas (make-bitmap 51 28))
(define dc (send canvas make-dc))
(send dc set-brush "WhiteSmoke" 'solid)
(send dc set-pen "black" (if broken 1 2) 'long-dash)
(send dc draw-rectangle 1 1 50 25)
canvas)
(printf "only dashed on the sides:~n")
(draw-box 'broken)
(printf "correctly dashed, but needs to be 2x wide:~n")
(draw-box #f)

@zenspider there might be a way to use math/array
to do that more cleanly, but it might also be a hassle

are all packages in the main distribution hosted in github repos under the “racket” organization?

@notjack there are maybe a couple exceptions

@samth if new packages were added to the main distribution though, they’d go under the racket org?

that depends if they already existed someewhere else

in which case they would maybe stay there

there aren’t really any rules here

gotcha