|
|
|
|
|
by msoloviev
1940 days ago
|
|
> As soon as you wrap code in a function for reuse, the proximate call site no longer has anything to do with the widget ID. That's a good point. (a) hash the entire call stack (though that might produce false negatives, i.e. consider two UI elements that should be the same distinct?)? (b) put the burden on the reusable function to mark itself as such by pushing/popping an identifier of its own call site on the ID stack? > The real hack is implicit IDs, not the ID stack (which is just a way of implementing a hierarchical namespace like file system paths or URLs). The fact that implicit IDs just work 99% of the time and only require manual intervention 1% of the time is a false siren song into letting you believe a 100% solution is desirable (you have to consider the marginal cost of what it would entail). Well, this is just the standard problem of library design, isn't it? You always have to figure out the appropriate tradeoff between supporting rare cases and making common ones easy. (Of course, you can often do both; in this case, you probably could both give "explicit ID" and "call site ID" versions of each UI element API.) |
|