@callimachus has joined the channel
@ananth.pattabiraman has joined the channel
A quick question here: How can I inspect or log things in Racket? Is there a way to do that?
Thanks a lot in advance!
Actual logging can be done as described here: https://docs.racket-lang.org/reference/logging.html?q=logger
But if you just want to see some value, then I usually just use displayln
.
Also, there is a traditional debugger available (but for some reason, I never use it): https://docs.racket-lang.org/drracket/debugger.html?q=debugger
@soegaard2 Thank you! I mean if I have this piece of code: (define (sup l)
(cond
[(empty? (rest l))
(first l)]
[else
(if (> (first l)
(sup (rest l)))
(first l)
(sup (rest l)))]))
How can I inspect (I’m coming from Elixir where we use a lot of IO.inspect() ) what is going on in different clauses? Thanks a lot again!
I like the simple solution:
(define (sup l)
(cond
[(empty? (rest l))
(displayln (list "rest is empty: " l))
(first l)]
[else
(displayln (list "rest not empty: " l))
(if (> (first l)
(sup (rest l)))
(first l)
(sup (rest l)))]))
But … this type of program is perfect for (hold your horses) The Algebraic Stepper.
The algebraic stepper allows you to run your program one step at a time (and go backwards).
Here is an example of how to use it: https://stackoverflow.com/questions/39549417/understanding-scheme-function/39549516#39549516
In your case, enter the function definition and a call to it, like: (define (sup l)
(cond
[(empty? (rest l))
(first l)]
[else
(if (> (first l)
(sup (rest l)))
(first l)
(sup (rest l)))]))
(sup (list 1 2 3 4 5))
Choose “Intermediate Language with lambda” and then click the foot.
@soegaard2 thank you so much! That is exactly what I wanted :slightly_smiling_face: Thanks a lot again!
In creating a #lang my-lang
how would I go about expanding this: #lang my-lang
x
y
(+ 1 2)
into this: (define (func x y)
(list x y 3))
Would
(define (func x y)
(list x y (+ 1 2)))
be OK?
I think what I’m asking is how to expand each expression when it might refer to arguments of a function it doesn’t know about yet
I think you’re supposed to quote the arguments and unquote them in the macro, but I could be wrong
The easiest would be (define-syntax-rule (#%module-begin vars:id ... body) (define (func vars ...) (list vars ... body)))
sorry that should be define-syntax-parse-rule
OK yes, that would give me (define (func x y) (list x y (+ 1 2)))
…
But what I really need to be able to do (I think, in this project) is expand-once
each expression before it goes in the function.
Because #lang my-lang
module might include forms that expand to require
or define
(Some of you probably recognize this is related to my beeswax thing https://github.com/otherjoel/beeswax)
You can use local-expand
with define-values
and #%require
in the stop list to recognize those forms that expand to require
and define
.
OK, I will read up on that one, thanks! :+1:
@phoe has joined the channel
Is there a convenience way to comment out enclosing expressions? For example: (define testo
(λ (x)
(onceo
(conde
((== 'tea x) succeed)
((== 'cup x) succeed)
(else fail)))))
I’d like to comment onceo
. (define testo
(λ (x)
;; (onceo
(conde
((== 'tea x) succeed)
((== 'cup x) succeed)
(else fail))
;; )
))
“paredit” can raise a sexp though, not comment.
Nope. I made a proposal here though: https://github.com/racket/rhombus-brainstorming/issues/124
I think you could get what you want with block comments #\| ... \|#
:
for example, this would just leave (== 'tea x)
as the definition of the lambda function #lang racket
(define testo
(λ (x)
#\| (onceo
(conde
( \|# (== 'tea x) #\| succeed)
((== 'cup x) succeed)
(else fail)) \|# ))
As many of you now know, we’re well into the release cycle for version 8.1 of Racket.
Racket, of course, isn’t just a language implementation. It’s a community of implementors (that’s you!), and all of the amazing packages that you produce.
As part of the release process, we run tests on every released package, using the current release candidate.
As is usually the case, some packages that worked in the last version (8.0) are not working correctly with the release candidate.
This is sometimes because of a regression in the package, and sometimes because of a new problem with Racket itself.
We currently have a tracking issue on github, showing all of the package regressions:
https://github.com/racket/racket/issues/3779
If any of these packages are yours, you might be interested to see what’s going on, and maybe there are things you can fix! Exciting!
You should keep in mind that this is only a list of those packages that have observably regressed since last time. There are of course many other packages with build or test failures, and you can always see these listed at
https://pkg-build.racket-lang.org
Thanks in advance for your help!
John Clements & the Release Management Team