If you want to display a string without the quotes, use "disp" instead of "write".
If you want to convert a string into an S-expr, use "read", and then if you want to evaluate that expression, use "eval".
(eval (read "(cons (cons 1 2) 3)"))
But I'm pretty sure you don't want to do either of those in this case. If what you want is nested lists, generate the nested lists - Lisp is good at that. Don't try to piece together your code out of parentheses. The following code will more-or-less generate the nested lists you asked about:
(def xw (n)
(let l '()
(for x 1 n
(= l (join 'w/link (list l))))
l))
However, the other problem with your approach is that even if you get xv working, it will pass a quoted expression to defop instead of an expression, and defop won't work right. To generate code, you need a macro, not a function. Here's a macro that will solve your original problem:
Strings vs symbols has caused me problems; using symbols as immutable interned strings seems like a hack (in the bad sense).
Some of my complaints: I never know if something expects a string or a symbol, e.g. keys into the req structure. Symbols sometimes require quotes and sometimes not, interacting confusingly with macros. (To make a hash with key foo and value bar: (obj foo 'bar) - bar needs a quote and foo needs no quote.) Symbols have their own strange syntax, e.g. to define a home page, you use the mysterious (defop || ...) because || is the empty symbol. Using symbols as strings makes the code more confusing; is passwd being used as a variable or as a string-like token? I think it's nice that strings have a consistent syntax: if it's got quotes around it, you know it's a string.
The big advantage of symbols over strings in Lisp is they are interned, so you can compare two symbols for equality in constant time, unlike strings which take O(n) time. But it seems that you could use interned immutable strings.
I agree with you that Arc's marginally mutable strings aren't very useful; being able to only modify individual characters gives you the worst of both worlds.
While I'm complaining about strings, it would be very nice to have something like Python's triple-quote """ that can be used to define a string that contains single and double quotes. To generate my documentation, I'm constantly creating strings that contain double quotes, and it's a big pain to go through and make sure all the backslashes are correct.
Overall, I'd like to see symbols used as symbols and strings used as strings, rather than symbols sometimes used as strings. But maybe I'm missing the goodness of using symbols as strings.
One day a student came to Moon and said, "I understand how to make a better garbage collector. We must keep a reference count of the pointers to each cons." Moon patiently told the student the following story-
"One day a student came to Moon and said, "I understand how to make a better garbage collector...
How do you organize your directories for arc2c? In particular, where does Anarki go relative to arc2c? Do you overlap the git repositories? And then what directory do you start arc in? (I can't get the paths to work for the loads.)
I'm not sure I fully understand your question, but you are supposed to put all the arc2c files at the root level, where arc.sh lives, then load arc2c.sh and finally call (compile-file "foo.arc"). Tell me if I didn't answer your question or if you still get something wrong.
$ ls
arc2c/ arc-wiki/
$ cd arc-wiki/
$ cp -r ../arc2c/* .
$ ./arc.sh
Use (quit) to quit, (tl) to return here after an interrupt.
arc> (load "arc2c.arc")
nil
arc> (compile-file "t.arc")
<lots of stuff>
Yes, that's what I was looking for: where to put arc2c in the tree.
My next arc2c problems are a) gc.h is missing; do I need to download it somewhere? and b) ‘QUOTE_CONSTANTS’ undeclared - I can't figure out where it gets declared. I'm trying to compile simply "(+ 1 1)".
How do I push changes to the git? "git push" gives me "fatal: The remote end hung up unexpectedly". I set up a ssh public key. Do I need to get authorization from you guys? (I've never done a git push before, so assume I may be doing something stupid.)
I'll step back and ask what you're trying to do with fork. If you do a genuine fork, you'll end up with two mzscheme interpreters running, which may or may not be what you want.
You asked about doing a wait; you pass the child's pid to wait.
Returning to your original example, Mzscheme supports calling continuations from another thread, as documented at http://download.plt-scheme.org/doc/mzscheme/mzscheme-Z-H-6.h...
That page also describes the continuation barriers. The issue is that you can't have a new thread call a continuation in the main thread, since then you'd have two main REPL threads, which doesn't make sense.
What you need to do is run your example in yet another thread:
prints 0, 1, 12, 25, 102, 205, 822, 1645, which much larger than the expected 1, 2, 3, 4, 5, 6, 7, 8 because all the threads update the same global variable
Thanks for the information on continuations and threads. Your suggestion worked perfectly for me.
And if you have to know, I am trying to port a program entered in the 5th annual Obfuscated Perl Contest (http://perl.plover.com/obfuscated/). It was originally implemented using fork(), but I was experimenting with using continuations and threads just to see if it would work.
I took a look at the Perl program. Just a warning: Arc doesn't have real pipes, so if you try to synchronize on pipes like the Arc program, you're in for trouble. Also, if you implement real forks and fork 32 mzscheme interpreters in parallel, you better have a bigger computer than mine :-)
I've interviewed a lot of people who have experience with Lisp, and I ask them if they think learning Lisp is worthwhile. Almost all of them reply with some variant of "Why on earth would you do that?" I've received a couple "Yes, definitely" replies from people who are hard-core Lisp hackers. So empirically it seems that most people who learn Lisp don't find it particularly rewarding.
I've talked to many fewer people than you, but my impression has been slightly different. Broadly speaking, the engineer-type programmers tend to dislike Lisp, and the computer-science-type programmers tend to like it. (Those two classes cover, in my [albeit limited] experience, two of the principle ways of thinking about programming.)
Eh. It's attitude, not job description :) And anyway, you should probably take that with a relatively enormous grain of salt, as small sample sizes aren't conducive to accurate data.
"On Lisp" section 10.4 discusses recursive macros. The brief explanation is that the recursion must be something that can be computed and terminated at compile time.
I've been thinking too that there must be a better way to deal with all these "(name (...args...) . body)" macros, although I've been approaching it from a different direction. The "macro for decorating body" design pattern is happening so often, it makes me feel something is wrong.
For instance, in srv.arc, 15 out of 16 macros are of the form "... ,@body ..." Macros seem a heavyweight way of doing this sort of #define-style replacement. Another thing that bothers me is that it's impossible to tell without examining the macro what gets evaluated immediately, what gets evaluated as part of the macro expansion, and what gets evaluated at some later time, for example in:
(w/link-if (prn 1) (prn 2) (prn 3) (prn 4))
There's no way to tell when these four expressions are evaluated without digging through the w/link-if code. There's also no way to tell which expressions are logically grouped together.
Arc has several innovative new syntaxes. It seems as if there must be some better new syntax for handling body macros, and Arc should provide it. Surely Lisp's syntax isn't the 100-year answer.
as far as I can tell, `(insert your macro code here ,@body) is the generalized solution form of that design pattern. Just template the code: insert this part here, insert that part there.
The nice thing about templating is that you reasonably arbitrarily insert various bits of code:
Of course, Arc does indeed try to provide specific, shorter solutions for the most common cases, such as single-argument functions ([... _ ... ] syntax), single-variable 'let (let syntax), and anaphoric macros.
Perhaps we can define mac-sym?
(mac-sym foob
'(insert your code here))
(foob
niaw
woof
arf)
==
(insert your code here
niaw
woof
arf)
(mac mac-sym (name . body)
(w/uniq m-body
`(mac ,name .m-body
(join (do ,@body) ,m-body))))
Or is what is bothering you something else entirely?
I'm not sure I understand your RSS feed question. If you want to create date stamps in the proper RSS / RFC822 format, I think what you want to use is SRFI-19: http://srfi.schemers.org/srfi-19/srfi-19.html
The require statement loads SRFI-19 into MzScheme. The string with ~'s specifies the output format.
Instead of (current-date), you can use (make-time time-utc 0 1207956960), using whatever seconds since 1970 time you want in place of 1207956960. There maybe needs to be a time zone correction in there.