This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Jim Blandy <jimb@red-bean.com> writes: > If an operation is going to do something weird and expensive, it > should be syntactically apparent; it could look like a function call, > for example. This is perfectly reasonable. The trick is not letting people accidentally change the value without running the code. It seems valuable to have a standard. > I don't see a major advantage to writing: > > (set! parameter value) and parameter > > instead of > > (set-parameter! value) and (parameter) > > especially since it's clear that the latter might do significant > work. The payoff isn't worth the ugliness it adds to the language. It's worth coming up with a standard, convenient way to do this. (define PARAMETER-gizmo (lambda (what value) (begin (define PARAMETER-internal-value (if #f #f)) (cond (((equal? what 'get) PARAMETER-internal-value) ((equal? what 'set) (set! PARAMETER-internal-value value))))))) (define set-PARAMETER! (lambda (value) (PARAMETER-gizmo 'set value))) (define PARAMETER (lambda () (PARAMETER-gizmo 'get #f))) If I understnad internal defines correctly, this should make the value of PARAMETER inaccessible from PARAMETER-gizmo... Anyone have a better suggestion? Andrew