This is probably not a very good idea for numerous reasons, but here's one way to do that:
(just extend the 'define' to set! things that are already bound)

#lang racket

(require
 (rename-in racket/base [define define-original])
 (for-syntax syntax/parse))

(define-syntax (define stx)
  (syntax-parse stx
    [(define i:id v:expr) (if (identifier-binding #'i)
                              #'(set! i v)
                              #'(define-original i v))]
    [(define (f:id arg:id ...) body ...)
       (if (identifier-binding #'f)
           #'(set! f (lambda (arg ...) body ...))
           #'(define-original (f arg ...) body ...))]))

(define (func x) 3)
(define (func a b) b)

(define x 4)
(define x 2)


Cheers!
-- caner

On 10/26/2016 07:41 AM, İlker Kesen wrote:
Hi,

I want to allow redefinition of already defined expressions (variables, 
procedures etc.), but Racket prevents me. I know, in DrRacket I can allow it 
via graphical preferences interface for Pretty Big and R5RS languages. However, 
I want to allow that operation in racket and sicp languages, too. There's no 
option for those languages in that graphical interface and no documentation, 
too (at least I couldn't have found). My question is, how can I do that? I want 
to allow multiple re-definitions over and over again, not just for once. Here, 
I attach an example and it's output.

Thanks in advance.


--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to