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 8001603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:08:04+00:00 2026-06-04T16:08:04+00:00

When building up some functions, I can make some mistakes. When this happens, I

  • 0

When building up some functions, I can make some mistakes. When this happens, I click RUN and have to re-enter all of the previous definitions and the new attempt.

Is there some way to “undefine” the previous (define (func args ...) body) and just keep going?

  • 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-06-04T16:08:06+00:00Added an answer on June 4, 2026 at 4:08 pm

    First of all, the behaviour is by design.
    Variables can not be mutated outside a module.
    This gives the optimizer a chance to, among other
    things, inline various things.
    See http://docs.racket-lang.org/guide/module-set.html
    for a detailed explanation.

    If you need to modify something inside a module,
    the standard way of doing it, is to use a parameter.

    Here is a quick hack (and I mean hack) that abuses parameters
    to make redefinitions possible.

    To declare a function to be redefineable use redefineable.
    In this example a function foo is declared to be redefineable.

    #lang racket
    
    (define-for-syntax (make-current-name stx id)
      (datum->syntax 
       stx (string->symbol
            (format "current-~a" (syntax-e id)))))
    
    (define-syntax (redefine stx)
      (syntax-case stx ()
        [(_ (name arg ...) body ...)
         (with-syntax ([current-name (make-current-name stx #'name)])
           #'(current-name (lambda (arg ...) body ...)))]))
    
    (define-syntax (redefineable stx)
      (syntax-case stx ()
        [(_ name)
         (with-syntax ([current-name (make-current-name stx #'name)])
           #'(begin
               (define current-name (make-parameter (λ x (error 'undefined))))
               (define (name . xs)
                 (apply (current-name) xs))))]))
    
    (redefineable foo)
    
    (redefine (foo x) (+ x 1))
    

    Now run the program, and in the interaction windows, we can now do as follow:

    Welcome to DrRacket, version 5.3.0.6--2012-05-11(9401a53/a) [3m].
    Language: racket.
    > (foo 41)
    42
    > (redefine (foo x y) (* x y))
    > (foo 2 3)
    6
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building some applications and decided it was time to run my code
Building a search with some custom objects and three scopes: All , Active ,
Building my first SL MVVM application (Silverlight4 RC) and have some issues i don't
I have some controller logic: public function seafood() { $this->set('title', 'Seafood restaurants in and
I am building a conditional formatting feature, where the user can enter an expression
I'm building a photoalbum. You can upload some images, which will be resized, made
I'm building a small PHP/Javascript app which will do some processing for all cities
Suppose you have some source code that comes from the unix world. This source
I have been building a custom control for some time now and overcome a
Currently building this hierarchy of objects and to be able to make the logging

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.