ccc is certainly way to go, but just in case: mzscheme does not use continuation passing style so the ccc can work much much slower than just a function call because it copies the stack.
Actually I didn't do the profiling so maybe there is nothing to worry about.
> "how would that help me write programs more concisely?"
Ok. This is after all the most relevant question.
But my point is although it's not necessary to worry about the difference between outport and outfile from the user's point of view, it's certainly impossible to ignore them when you implement these functions. You kind of have to since you need to know whether or not inside is allowed for a particular object. Whether to make this information visible for the user is another question.
Yes --- that's the best part! For instance, the example aif I gave uses a mixed quoted/unquoted lambda list.
For an example of the exact form you gave:
(def f ('a b) (print a) (print b))
(f (list 1 2) (list 3 4))
Outputs:
(list 1 2)
(3 4)
Any combination of quoted and unquoted arguments is valid. Those that are quoted act like macro arguments, and those that are unquoted act like functional arguments.
I don't understand how there cannot be lookup in both cases. The only difference I can guess is that in case of hashes you might have used strings as keys and when using symbols the lookup is done only by pointers. But that's the same in scheme if use use symbols as keys in hash table.
zhtw, your profile says you're building a lisp compiler, so I'm taking the liberty of exposing the innards of rainbow a little, it might be helpful:
public class Symbol {
String name;
ArcObject value;
// ... etc
}
Pieces of arc code contain direct references to these Symbol objects. For example, (car x) is implemented by something like this:
class Invoke_Sym_Lex {
Symbol fn; // points to the "car" symbol
LexicalSymbol arg;
public void invoke(...) {
fn.value.invoke(arg);
}
}
there is no lookup. The symbol is baked into the code. Lexically-bound symbols are more complicated, but they don't use hashes for lookup either.
As far as I can tell, this approach will support namespaces without any performance penalty, except perhaps at read/compile-time. Assuming arc gets namespaces one day ...
If you're interested here is my startup script. It defines "import" macro which is the same as "load" but path is treated related to arc base prefix. "arc" is the startup script itself. Options -l allows to load arc-file before prompth. "boot.scm" is my replacement for as.scm.
arc:
#!/bin/sh
mzscheme=/usr/local/mzscheme372/bin/mzscheme
pkgbase=/home/avl/pkg
prog=""
while [ "$#" -gt 0 ]; do
if [ "x$1" = "x-l" ]; then
shift
[ -f "$1" ] || { echo "No such file ($1)"; exit 1; }
loadstr="$loadstr (load \"$1\")"
shift
else
[ -f "$1" ] || { echo "No such file ($1)"; exit 1; }
prog="$1"
shift
fi
done
if [ -z "$prog" ]; then
( echo "$loadstr"; cat; echo " (quit)" ) |
( "$mzscheme" -m -f "$pkgbase/arc/boot.scm"; echo )
else
( echo "$loadstr"; echo "(load \"$prog\") (quit)"; ) |
exec "$mzscheme" -m -f "$pkgbase/arc/boot.scm"
fi
; import is the the same as load but path is threated related to pkgbase
(def namechain->path (l)
(tostring (each x l (pr "/" x))))
(mac import namechain
`(load (string pkgbase (namechain->path ',namechain) ".arc")))
; (import sys stream) -- that's my personal stuff.
So you just need to substitute /home/avl/pkg/arc with the path where your arc3 dir is placed.
And one last thing. If you install rlfe it's convenient to rename "arc" to "real-arc" and start it by "/usr/bin/rlfe real-arc" from "arc".
Nice. Thanks.
I think that's Russian correct? (pardon if I got it wrong).
I'm just curious. Although I don't use hacker news much (can't relate to the topics as much) - I can see how the layout and usage is much better than most sites I visit. And I can see a mutlitude of uses for it - not just news. So I am just surprised I haven't seen more of them. I was thinking about starting one up for my industry peers (not the hackers).
Just wanted to see what other members experiences were.
T.
The really good idea would be to rewrite all the code from the book in Arc. I love the book and I don't know Common Lisp. The book would be much clearer with examples written in Arc. For example generalized variables: I didn't even read examples from the book, I read the Arc source instead.