Fork me on GitHub

Do any "modern" languages use dynamic scoping as their primary scoping method?


Ouch. I don't usually write complex enough shell scripts to run into that. Thanks for the link!


You can run into that even in Clojure, with the unhygienic macros. :) That's why we end variables in macros with #.


Do macros count as dynamic scoping if they run at compile time? 馃く


time to check Let Over Lambda again...


The behavior would be that of a function, but the name, "unhygienic macros", is different. I still think the concept is pretty much the same, but I may be wrong.


Seems like variable capture with macros works like you'd expect dynamic scoping to one way, but not both It can "shadow" a symbol within the lexical environment it's evaluated into but calling the macro won't alter the value of any bindings in outer scopes.


That's because you cannot alter a binding in an outer scope at all in Clojure, unless you explicitly call something like alter-var-root. I don't think it has anything to do with lexical or dynamic scope. May be wrong myself though.


Dynamic scoping is so un-intuitive to me!


And most of the languages don't support it for a good reason. :)


I use carmine to work with Redis and I have a bunch of workers that all do the same thing - receive a message, run some task, write results to the database. Now I need to not write the results anywhere but to send them via an open WebSocket connection to a client. One approach that I can think of is to give each task a specific ID and make workers write the result to a different queue along with the ID - that's exactly what sente does for WebSocket communication. But maybe there are better approaches? Maybe something Redis- or carmine-specific?


It doesn't seem to offer anything related to my problem in particular, does it? How would it differ in my case from just queuing a message and pub/sub?


well the problem description was kind of vague


IDK what the workers are


but I don鈥檛 see how Redis is needed in this equation when you are working with Websockets


It's not as vague if you know about carmine. :) It uses worker terminology. A worker is just a dependent node deployed somewhere that consumes Redis messages and runs some code on that input. I mentioned WebSockets just for the context. The important part is that I need to be able to access the response from a worker as close as possible to the scope where the initial message from the main host has been sent.


#find-my-lib sounds like I've hidden my library and there's a prize if you find it. Find my lib: it solves the halting problem generally


OK, seriously though - where did you hide this one?


There is a prize if you find/create that one. It will be a big hurdle explaining why the proofs of impossibility were wrong.