ChanServ changed the topic of #racket to: The Racket Programming Language -- https://racket-lang.org/ -- https://racket.discourse.group/ -- http://pasterack.org -- logged at https://libera.irclog.whitequark.org/racket/ -- This is the right place to ask for help with DrRacket. Remember to wait around for an answer!
Tuplanolla has quit [Quit: Leaving.]
Origin has joined #racket
philip has joined #racket
Origin has quit [Ping timeout: 252 seconds]
spdegabrielle has quit [Quit: Connection closed for inactivity]
chiselfuse has quit [Remote host closed the connection]
chiselfuse has joined #racket
ormaaj has quit [Ping timeout: 248 seconds]
ormaaj has joined #racket
lucasta has quit [Quit: Leaving]
philip has quit [Ping timeout: 276 seconds]
macabro has quit [Quit: ERC 5.5.0.29.1 (IRC client for GNU Emacs 29.4)]
skapata has quit [Remote host closed the connection]
yonkeltron has quit [Ping timeout: 276 seconds]
macabro has joined #racket
yonkeltron has joined #racket
libertyprime has joined #racket
to-hu has joined #racket
libertyprime has quit [Ping timeout: 252 seconds]
Origin has joined #racket
<Putonlalla> It looks like `free-vars` cannot handle `define` or `define-values`. Is there a procedure that can?
<bremner> hmm. not an expert, but what happens if you fully expand (I guess to a module form?) first
<Putonlalla> Forbidden forms may still be present in top-level bindings.
<Putonlalla> Well, I just got `free-vars: unknown core form: lambda` error message out of it, so now I just think it's broken.
<Putonlalla> Evaluating `(expand #'(define (twice prc) (lambda (x) (prc (prc x)))))` gives `#'(define-values (twice) (lambda (prc) (lambda (x) (#%app prc (#%app prc x)))))` and then `free-vars` chokes on `lambda` that was supposed to expand into `#%plain-lambda` or `case-lambda`.
<Putonlalla> So, `expand` doesn't expand according to this. https://docs.racket-lang.org/reference/syntax-model.html#%28part._fully-expanded%29
<Putonlalla> I can't find any tests verifying this either. There's no `fully-expanded?` defined anywhere.
<bremner> maybe post to discourse? matthew flatt reads that
<Putonlalla> I think it's faster to implement my own expander.
<bremner> o.O
<bremner> ok then.
<samth> Putonlalla: free-vars expects fully-expanded code and only works on expressions (although changing it to work with define-values would be pretty easy). Here's an example of using it successfully:
<samth> Putonlalla: also I'm not sure where you got the idea that expand doesn't fully expand programs
<Putonlalla> Only `#%plain-lambda` and `case-lambda` are in the grammar, while `lambda` is still left after expansion.
<samth> I think you took the expansion and then typed it in again which doesn
<samth> 't give the same answer
<samth> the `lambda` in the output there is the same binding as `#%plain-lambda` in the fully-expanded grammar
<samth> (which is why `free-vars` works in my snippet
<samth> )
<Putonlalla> Oh. That's not very intuitive.
<samth> the symbol in an identifier representation doesn't tell you what binding it is (and can't)
gnomon_ has joined #racket
gnomon_ has quit [Client Quit]
<Putonlalla> Now that I spent a little time thinking about this, it also seems like `free-vars` doesn't actually give you the free variables in an expression. It gives you the bound variables.
<Putonlalla> That is, `(free-vars (expand #'(+ 1 x)))` yields `'()` instead of `'(+ x)`.
skapata has joined #racket
philip has joined #racket
to-hu has quit [Remote host closed the connection]
<samth> Putonlalla: mostly this is because you're working at the top level which doesn't really have "free" and "bound" variables. The idea is to look at the "free lambda/let-bound variables of an expression" which is not what `x` is
<samth> If you want `+` in the output you need the `#:module-bound?` keyword argument
libertyprime has joined #racket
lucasta has joined #racket
lucasta has quit [Quit: Leaving]
Tuplanolla has joined #racket
lucasta has joined #racket