I have implemented generalized `set!` in Racket before, as a cute exploratory exercise, but I haven't found a sufficiently compelling benefit of generalized `set!`.

The closest I've imagined to benefit of generalized `set!`: let's say you had really terse but nice referencing syntax for complex objects (records, collections), and you wanted to make the assignment lvalue syntax look the same as the rvalue syntax. For example, how in some language we might have both of:
p = a[x][y]
a[x][y] = p
However, with Racket obviously coming from the Scheme tradition, Racket is not about the terse syntax (not until you get into DSLs, which is different). I don't see sufficient benefit to complicating the semantics of the language just to make `(set! (vector-ref v 0) 42)` equivalent to `(vector-set! v 0 42)`.

If you want to get into OO-like generalization, one could come up with a scenario in which generalized `set!` could be used, but offhand I can't think of an example that couldn't be done with a more conventional use of OO objects and methods.

If someone has a great scenario for how generalized `set!` wins, I'd be interested in seeing it. (For example, maybe there's a win in some scenario of syntax transformation, in which you wind up with a `(set! ACCESSOR VALUE)` pattern, and for some reason it's easy to get there but hard to get to `(SETTER-PROC OBJ VALUE)`? Just a bad speculative example; you'd need to go further.)

Neil V.

--
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 racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to