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] |
>>>>> "Chris" == Chris Bitmead <Chris.Bitmead@misys.com.au> writes: Chris> But if YOU know that you will never re-define it, then why Chris> opt for a generic mechanism like setf? Just use Chris> (set-foo... ) instead. If you don't think things should be Chris> looked up N times inside some loop, then I guess you don't Chris> like OO things in general, because it's all about Chris> dynamically looking up types at run-time. What do you mean by generic, here? Perhaps this is my CL experience confusing me, but when I hear generic in a Lisp setting I tend to think of generic function, and I see no dynamic dispatch here. Chris> I can't see too much point in having this wonderful generic Chris> mechanism if it's just pretending to be generic and in Chris> reality it is all static. Well, I'll take this from the CL side of things where it is static. setf existed in part because there were dozens of getter/setter pairs in CL that were mutually inconsistent; like set-car! and vector-set! but much worse. (what rplaca and car have to do with one another is subtle, but rplaca is ridiculous compared to e.g. get and put...) So, some unification of the names was needed, but the existing names couldn't go away. For whatever reason, (setf (foo)) was chosen as the counterpart to (foo), and things went from there. So, CL setf is in one sense just a way to rename things (although a particularly handy one) and doesn't serve any particular advantage over, say, set-foo! and foo. (psetf and setf in the presence of multiple values (which CLIM requires) are wrinkles on this, of course, but the core is the same.) In a sense, it's only really useful if there's an enormous library of getters/setters that are all different. Fine. But Scheme *has* an enormous library of procedures with getters/setters that are all different! Not just set-car! and vector-set!, but yasos has it's own idea of setters, a lot of slib omits the ! after destructive functions, slib's relational-database's insert et al. functions seem to correspond to no existing name standard, slib's byte package uses byte-set! rather than set-byte!, etc. I'm sure this gets even worse as time goes on and people examine packages other than slib; I know scsh has been relatively careful about ! but I have no idea what naming pattern they use. So a static setf would certainly be *useful*. The question is really whether a dynamic one would be more useful/pure, and this really hinges on what you think setf is. If you think it's a glorified naming convention, then a dynamic setf seems particularly useless. If you think it's more like Dylan's setters, then obviously you want something else and it's questionable whether you would want a (setf!) form at all for them. -- Graham Hughes <ghughes@cs.ucsb.edu> PGP Fingerprint: 36 15 AD 83 6D 2F D8 DE EC 87 86 8A A2 79 E7 E6