Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6338765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:30:45+00:00 2026-05-24T19:30:45+00:00

Does racket have something like guile’s procedure-source function, e.g.: (define (plus-one x) (+ 1

  • 0

Does racket have something like guile’s procedure-source function, e.g.:

(define (plus-one x) (+ 1 x))
(procedure-source plus-one) –> (quote (+ 1 x))

I’m trying to make something akin to a debugging tool for beginning students, in which they can see partial or complete evaluations of a particular function while they play with its behavior in a 2htdp/universe. So I could use a macro for this case, except in their program I’d still like the definition to look exactly as usual, so I can’t just have them quote it in the first place and eval it later, unless I redefine define… which might be okay, but I’d appreciate pointers on how best to do it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:30:45+00:00Added an answer on May 24, 2026 at 7:30 pm

    The problem you’re running into is due to a Beginner Student Language restriction: normally, higher-order functions are a syntactic error in the language, because beginners shouldn’t know about them yet.

    There’s a way to opt-out of this. Your procedure-source can be labeled as one of the exceptions to this restriction, by using provide-higher-order-primitive, which is specifically meant to cooperate with BSL.

    Here’s what your library looks like with it:

    #lang racket/base
    (require lang/prim
             racket/bool
             (for-syntax racket/base))
    
    (provide define/save-source)
    (provide-higher-order-primitive procedure-name (fn))
    (provide-higher-order-primitive procedure-source (fn))
    
    
    (define *procedure-name-hash* (make-hash))  
    (define *procedure-source-hash* (make-hash))  
    (define (save-source! fn name body)  
       (hash-set! *procedure-name-hash* fn name)
       (hash-set! *procedure-source-hash* fn body))
    
    (define (procedure-name fn)
      (hash-ref *procedure-name-hash* fn false))
    (define (procedure-source fn)
      (hash-ref *procedure-source-hash* fn false))
    
    (define-syntax define/save-source
      (syntax-rules ()
        ((_ (name formals ...) body-expressions ...)
         (begin
           (define name (λ(formals ...) body-expressions ...))
           (save-source! name 'name '(λ(formals ...) body-expressions ...))))
        ((_ name (λ(formals ...) body-expressions ...))
         (begin
           (define name (λ(formals ...) body-expressions ...))
           (save-source! name 'name '(λ(formals ...) body-expressions ...))))
        ((_ name value)
         (define name value))))
    

    BSL programs that use this should be able to use procedure-name and procedure-source fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone use have a good regex library that they like to use? Most
So Emacs is pretty good at editing Scheme/Racket/Lisp code. One good thing it does
Does Windows Phone 7 have anything like iPhone's UITableView? [Basically, I'm porting an iOS
Does anyone know how to use the define function and pass a variable into
Does anyone know a trick that would allow me to do something like this
Does Google force employees who have offers from Facebook to leave immediately?
Does the Java language have delegate features, similar to how C# has support for
Does anyone have any recommendations of tools that can be of assistance with moving
Does C# have built-in support for parsing strings of page numbers? By page numbers,
Does anyone have a definitive answer to whether Sql Server Management Objects is compatible

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.