If it's not exactly what I wrote, it's still probably the correct version to use. I pushed my code to anarki but rntz handled the porting of most libraries to arc3. Any changes are probably for the better.
This seems to complement 'help, 'sig, and 'src fairly well.
If I remember correctly though, this will only work for global variables (such as globally defined functions and macros, and variables used on the repl). Local variables are handled by scheme lsmabdas, and don't actually undergo any symbol transformation.
How hard and useful do you think it would be to try and get it to work for local vars as well?
I would normally use 'apropos when I'm sitting at the REPL trying to remember the name of a function (or, more rarely, a global variable bound to a hash-table or something). For 'apropos to work on local variables, I assume you would have to use 'apropos within the lexical environment in which the variable exists. I.e. you would go
(let thingamajig 2
(do-stuff)
;hmm, what was that variable again? thing-something.
(aps thing))
Which seems a bit useless to me, as the local variables are printed right there within the block of code you're currently writing. I suppose one could have some macro that creates a huge lexical environment, or something... am I missing your meaning? At any rate, 'namespace-mapped-symbols appears to be blind to local variables:
Any idea how hard it would be to port the forum app to web.arc? It would give us an interesting comparison of the two systems.
I'm partly interested because I've been working very slowly on creating an fcgi interface for arc. I wanted to run it on a shared host that allows arbitrary scripts to be run, but only as long as they don't open their own network sockets.
Unfortunately, while I got the fcgi interface to work (not fun by the way; fcgi is horrible), and simple "hello world" scripts running directly on srv.arc work fine, more complicated things like the forum have mysterious bugs. It could easily be that something is wrong with my code, but given the extreme lack of debugging tools, and the mysteriousness of the bugs, I wonder sometimes if it isn't something wrong with the arc app stack itself. It would be awesome if switching the forum over to your web stack would make it more stable.
Btw, you should also put your code in a more permanent location, like the anarki repo.
The main reason is that I already have a shared host, so I figured I might as well run arc on it, instead of pay for separate vps. Especially if I can get better performance/reliability than running it locally.
Also, I figured that there might be some other people interested in doing the same thing.
I'm not sure that either of those are what he's looking for. Both seem to be different ways of displaying the upload form to the user, but neither seems to change the way that the back end handles the file.
It sounds like he wants a way for arc to receive an uploaded file in an http request, and do something with the data, rather than a way to display an upload form.
Thus, instead of doing (defop r), it's kind of like we're doing (defop (eval r)). That is, instead of expanding into
(defop r req (rpage 'r))
we're expanding into
(defop 10a req (rpage '10a)) ; when r == '10a
(defop 10b req (rpage '10b)) ; when r == '10b
; etc
We could've done the eval inside the macro, too, but that's often a sign you're doing something wrong --- macros are usually there to not evaluate their arguments. So we should probably use a function.
However, defop itself is a macro, so the first parameter (the op's name) won't be evaluated regardless. We still need eval.
Since this approach seems to require eval regardless, we should just look for a better solution. aw's works nicely.
Some other nitpicks over your rewrite (hey, you asked!):
1) Unless you need strings for some reason, you can probably default to symbols (they're a bit easier to use).
; Instead of
(= routes* '("10a" "10b" "15a" "20a" "20b" "30a" "30b" "30c" "40a" "59u"))
; we could use
(= routes* '(10a 10b 15a 20a 20b 30a 30b 30c 40a 59u))
2) Proper spacing & indentation saves lives. :)
; Instead of
(defop shuttle req
(each r routes* (link r)(nbsp)))
; why not
(defop shuttle req
(each r routes* (link r) (nbsp)))
; or even
(defop shuttle req
(each r routes*
(link r)
(nbsp)))
3) Though using symbols renders this point moot, fromstring is unnecessary to simply (read) from a string, since Arc's definition of read is
(def read ((o x (stdin)) (o eof nil))
(if (isa x 'string) (readstring1 x eof) (sread x eof)))
So, instead of
(fromstring rs (read))
you can use
(read rs)
If your goal is just to turn a string into a symbol, you should use
(sym rs)
This is an important distinction. e.g.,
arc> (sym "abc")
abc
arc> (read "abc")
abc
arc> (sym "(a b c)")
|(a b c)|
arc> (type that)
sym
arc> (read "(a b c)")
(a b c)
arc> (type that)
cons
Very instructive. Thank you for doing such a thorough analysis.
',r from your snippet
(mac rdefop (r)
`(defop ,r req (rpage ',r)))
was a realization for me. Never thought of quoting a comma'd symbol in a backquoted expression before, but I like knowing it's possible. Do you find yourself doing this much, or is there usually something simpler like aw's solution available to make it unnecessary?
Getting better repl tools, and language integration with the repl, are two of the main things I'm interested with in arc.
I've only gotten as far as 'src and 'ppr, but I was hoping to get to the point where arc automatically documented it's current code (i.e. the stuff actually running) and made it visible through both web and repl interfaces. In theory, 'src could be used to solve the repl -> editor -> file problem. If arc kept track of the original source files, and the current 'src associated with each of those functions, then it could possibly display the diff and even update the files if you wanted it to. Heck, why not give it a git interface, so that you can add and commit changes from the repl as well.
The reason I like arc is that the language is very easy to change, and I'm hoping to change it to make it the language that is most "aware" of itself, and its current source code.
Making a better repl is certainly something I'm interested in.
I was under the (possibly mistaken) impression that arc didn't support the recent versions of MzScheme because their variables aren't. Has that been changed?
At this point, I think that more posts is probably a good thing, even if they're only slightly related to arc.
A lot of people like me probably don't check all that often because there isn't much going on. If we can increase the number of comments/submissions to a slightly higher level, it will probably encourage more return visits, and better community interaction. Sure, the quality should be kept high and this is the arc forum. But by all means, submit "other" posts, if only so that there's a reason to check more frequently. That would give the arc community a greater appearance of life, and allow the posts and questions that "really matter" to get more attention as well.