CS 251, Fall 2024, Carleton College, Dr. Joshua R. Davis Is Scheme call-by-value? We never asked that until now, because our functions didn't mutate their arguments, because we wrote in a functional style. But how would we test it? (define x 3) (define test (lambda (y) (set! y 5) (display y))) (test x) ; prints 5 x ; gives 3 Is Python call-by-value? x = 3 def test(y): y = 5 print(y) test(x) # prints 5 x # prints 3 But is Python really call-by-value? x = [1, 3, 5, 7] def test(y): y[0] = 5 print(y) test(x) # prints [5, 3, 5, 7] x # gives [5, 3, 5, 7] So should we do that test in Scheme too? (define x '(1 3 5 7)) (define test (lambda (y) (set! y (cons 5 (cdr y))) (display y))) (test x) ; prints (5 3 5 7) x ; gives (1 3 5 7) But maybe that wasn't a good test? (define x '(1 3 5 7)) (define test (lambda (y) (set-car! y 5) (display y))) (test x) ; prints (5 3 5 7) x ; gives (5 3 5 7)