3 ms·
This is, of course, a problem with any language. Start naming functions pr and arg and everything quickly becomes unreadable. The other problem is that there
by jrockway 16y ago
This is, of course, a problem with any language. Start naming functions pr and arg and everything quickly becomes unreadable.
The other problem is that there is really no way for the reader to intuit that there is a continuation or that state is being captured and passed around. Using the word "lambda" in the onlink continuation might help in that respect.
Not storing the request state in the global environment would also help readability. One thing that shocks me about programmign is how few people realize that you can pass arguments to functions, and they can return values. Instead of:
(omg-magic)
Why not:
(send-response (handle-request req))
Hey, now we know that the parameter is a request and the result is a response. You wouldn't write:
(let ((a 2) (b 2)) (add-and-print-a-and-b))
You'd write:
(print (+ 2 2))
So why does this common sense go out the window when the problem is more complex than adding 2 and 2? I wish I knew...
- rincewind 16y agoThere is no continuation in the arc example I think. The request is also not a global variable (the aform macro stores a closure in a global hashtable, maybe you mean that).
- jules 16y agoDepends on what you mean by continuation. There is no continuation as in Scheme's callcc. But there is a continuation in (onlink "foo" X). X is the continuation. The macro probably wraps a lambda around that, the resulting closure is the continuation.
- chriseidhof 16y agoIndeed, the first continuation is [onlink "click here" (pr "you said: " (arg _ "foo")) and the second continuation is (pr "you said: " (arg _ "foo")