[racket] How to view source code of procedures? MIT scheme "pp" equivalent?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Dec 27 19:35:51 EST 2013


On Dec 27, 2013, at 6:27 PM, Scott Klarenbach wrote:

> I noticed that MIT Scheme has the "pp" procedure which prints the source code of a given function.  Is there an equivalent way to do this in Racket?

No. The 'pp' idea probably dates back to the age of Lisp-machine repls when MIT programmers thought that you enter functions into the repl and the program is the current state of the repl. Since definitions for large programs scroll off the visible screen, you need pp. 


> More generally, I'm looking to normalize nested procedures to their most rudimentary expressions.


This might be a MIT misunderstanding about the relationship between Scheme and the lambda calculus. It is certainly not possible in general and I see no pragmatic use case for an approximation. 

-- Matthias



























> 
> For example:
> 
> (define (something? x) (> x 3))
> (define (something-else? x) (< x 10))
> (define (combined x) (and (something? x) (something-else? x)))
> 
> (normalize combined) =>
> '(lambda (x) (and (> x 3) (< x 10)))
> 
> ((normalize combined) 7) => #t
> 
> I'm sure it's not so simple and a robust general solution involves some type of beta reduction and/or argument constraints, but I'm just looking for a nudge in the right direction.
> 
> Thanks.
> 
> 
>  
> 
> -- 
> Talk to you soon,
> 
> Scott Klarenbach
> 
> PointyHat Software Corp.
> www.pointyhat.ca
> p 604-568-4280
> e scott at pointyhat.ca
> 200-1575 W. Georgia
> Vancouver, BC V6G2V3
> 
> _______________________________________
> To iterate is human; to recur, divine
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20131227/4a671177/attachment.html>

Posted on the users mailing list.