3 ms·
This was great! I wish there were more case studies like this. I think you're selling it short, this is a truly novel "third way" of managing state, after lexi
by akkartik 11y ago
This was great! I wish there were more case studies like this.
I think you're selling it short, this is a truly novel "third way" of managing state, after lexical scope and dynamic scope. The key idea is the hook into the function signature that allows overriding without the push/pop dynamic that characterizes lexical and dynamic scope.
I'm curious, does your system raise a warning if a function uses a thread-global variable without declaring it in the function arguments? Do you still feel the need for directly using the anywhere in the HN codebase?
- dang 11y agoWe don't raise a warning, and we do use raw 'the' in a couple places, mainly because the notation doesn't play nicely with 'apply'. Also, some macros need it.
- jcr 11y agoI have no idea why this came to mind... "The The - Infected" https://www.youtube.com/watch?v=tx-cglxj3II https://www.youtube.com/watch?v=tx-cglxj3II
- jcr 11y agoDan's implementation is fascinating, but I'm unsure if it qualifies as "truly novel" since I _think_ I've seen something like this before. I wish I could remember where, and a few quick searches have turned up no results. As he mentioned, thread-local-storage (the other "TLS") in CommonLisp is provided by dynamically scoped variables [1], but this similar functionality is being accomplished elsewise. Though this way of getting TLS may lack some of benefits of full dynamically scoped variables, I've got a wild, unsubstantiated hunch that this way may have better performance than full blown dynamic scoping due to less overhead. The fun part is, this way of doing things (i.e. without dynamic scoping built in) is essentially doing "user-directed scoping" that is vaguely similar to things like "SoftTyping" [2] and "SuccessTyping" [3,4] which are basically "user-directed typing". [1] https://en.wikipedia.org/wiki/Thread-local_storage#Common_Lisp_.28and_maybe_other_dialects.29 https://en.wikipedia.org/wiki/Thread-local_storage#Common_Li... [2] http://c2.com/cgi-bin/wiki?SoftTyping http://c2.com/cgi-bin/wiki?SoftTyping [3] http://www.it.uu.se/research/group/hipe/publications.shtml http://www.it.uu.se/research/group/hipe/publications.shtml [4] http://www.it.uu.se/research/group/hipe/publications.shtml http://www.it.uu.se/research/group/hipe/publications.shtml
- akkartik 11y agoThanks for those links. Could you check #4? After I posted my comment I connected up this idea with https://en.wikipedia.org/wiki/Google_Guice https://en.wikipedia.org/wiki/Google_Guice
- jcr 11y agoThe #4 link is fine, but the person who posted it failed miserably. ;) I wanted to give you the direct link to the SuccessTyping paper listed on the url given in #3 and #4. http://www.it.uu.se/research/group/hipe/papers/succ_types.pdf http://www.it.uu.se/research/group/hipe/papers/succ_types.pd...