;; Cut and paste this code into your favorite editor, or ;; perhaps into the Wraith Scheme Input Panel. ;; FUNCTIONAL PROGRAMMING ;; Some people like to write code in a style known as "functional ;; programming", in which the values assigned to variables are never ;; changed, or perhaps changed only at top-level in the program's ;; environment. ;; This code disables the R5 Scheme procedures that end with a "!" ;; (and shows by example how to disable other procedures as well). ;; Disabling these functions goes a long way toward making Wraith ;; Scheme a functional-programming language. The procedures disabled ;; are: ;; set-car! ;; set-cdr! ;; string-fill! ;; string-set! ;; vector-fill! ;; vector-set! ;; set! ;; Once the procedures are disabled, they are gone for the remainder ;; of your Wraith Scheme session. You will have to quit Wraith Scheme ;; and restart to get them back again. ;; The code requires that "set!" be the last procedure disabled: It is ;; used to disable all the rest of them. Bear that in mind if you ;; wish to disable additional procedures. ;; Wraith Scheme does have other procedures that change state. ;; Most of them involve I/O in some way. They include: ;; e::clear-permanent! ;; e::load-world! ;; e::set-current-directory! ;; e::set-input-port! ;; e::set-list-print-depth! ;; e::set-list-print-length! ;; e::set-permanent! ;; e::set-tag! ;; e::set-vector-print-depth! ;; e::set-vector-print-length! ;; The procedure "define" also may change program state, in that you may ;; re-"define" a variable that already has a value. I didn't have an easy ;; fix for that one, so "define" is still there. For that matter, the ;; standard Scheme "load" procedure may change state, as will other ;; procedures that bring in code from a file. ;; Yet what's here may help keep would-be functional programmers honest. ;; A note of WARNING, however: If you use this stuff, disable the ;; Wraith Scheme compiler -- it uses "set!" internally, and will become ;; confused by its absence ... ;; To use this code, copy it directly into the Wraith Scheme Input ;; panel, or cut-and-paste it into another file and work from there. ;; Here comes the actual code ... (e::clear-permanent! 'set-car!) (set! set-car! ') (e::clear-permanent! 'set-cdr!) (set! set-cdr! ') (e::clear-permanent! 'string-fill!) (set! string-fill! ') (e::clear-permanent! 'string-set!) (set! string-set! ') (e::clear-permanent! 'vector-fill!) (set! vector-fill! ') (e::clear-permanent! 'vector-set!) (set! vector-set! ') (e::clear-permanent! 'set!) (set! set! ')