open-output-file: cannot open output file: "C:\User\Programming\Arc\arc-wiki\arc
/logs/srv-2008-02-26" (The system cannot find the path specified.; errno=3)
=== context ===
srvlog
gs1086
handle-request-thread
If I instead manually create a directory arc/logs before attempting (asv), everything works fine.
It looks like (asv) calls (serve port), which calls (ensure-dir logdir* ), which would seem to be our culprit
arc> (ensure-dir logdir* )
The syntax of the command is incorrect.
nil
since ensure-dir calls directly out to mkdir and Windows breaks on the forward slashes in the command. Changing that part of the definition of ensure-dir from
(system (string "mkdir -p " path))
to using the convenient definitions in files.arc
(mkdir path)
should do the trick.
EDIT: Verified that the fix works with both (asv) and (nsv); pushed to Anarki. This should resolve web server problems on Windows.
I was working on this, too, and I got rid of your commit and added mine (sorry!). There are some complications with just using make-directory - specifically, it doesn't create parents directories. We need make-directory* to do this, and that sets the sticky bit on directories in Unix. So my solution was to use system on Unix and make-directory*.
I got the snapshot he posted and it won't even load in mzscheme:
G:\Anarki\arc-wiki>mzscheme -m -f as.scm
compile: bad yntax; function application is not allowed, because no %app syntax transformer is bound in: (quote nil)
=== context ===
G:\Anarki\arc-wiki\ac.scm:978:0: aload1
>
It'll only load in DrScheme but then I get:
arc> (load "news.arc")
nil
arc> (nsv)
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
The syntax of the command is incorrect.
load items: Error: "directory-list: could not open \"G:\\Anarki\\arc-wiki\\arc\\news\\story\\\" (The system cannot find the path specified.; errno=3)"
arc>
Anarki was briefly incompatible with the latest MzScheme. The snapshot may have been made then. The latest revision should be better, though, at least with respect to MzScheme syntax errors.
I get the following on the latest from arc-wiki (Tue Feb 26 10:33:26 PST 2008):
Use (quit) to quit, (tl) to return here after an interrupt.
arc> (defop hello req (pr "hello world"))
#<procedure:gs1657>
arc> (asv)
The syntax of the command is incorrect.
ready to serve port 8080
'uname' is not recognized as an internal or external command,
operable program or batch file.
make-string: expects argument of type <non-negative exact integer>; given -1
=== context ===
cut
date
memodate
srvlog
gs1078
handle-request-thread
Are you sure ac.scm is in the directory "C:\Tools\MzScheme\"? I get the same error when I intentionally try to load arc in an incorrect directory. So if you aren't in the directory where you put arc, cd to that directory before calling mzscheme.
(You may also want to note that you want to load as.scm, not ac.scm, because as.scm starts the toplevel. But I don't know if that is part of your problem or not.)
First of all, let me say that I think lexicons look pretty cool.
Second, in Lexicons.pdf, you write the following about hygiene:
"The solution, in a nutshell, is: Within a backquote, precede any function call that you want to be non-shadowable with a comma."
I find this rather ironic considering all the ado on the forum about hygienic macros. (If this works then why did people both writing all those posts about hygiene? Not that I'm saying it doesn't...)
but if I am not mistaken you can't do the same for macros because
(mac baz args `(prs "baz:" ,@args)) ; would do this in a let if macros were first class
(mac bad args `(,baz ,@args))
gets you an error. (I've heard this could be solved with first-class macros but I have yet to see any implementation of said first class macros in arc.)
And if this is the Right Way to fix hygiene, should macro writers be expected to do this for every single macro they ever write?
Doesn't work in Arc2, but works in Anarki. Also doesn't work with macros, as you say. Macros aren't as big a deal however, because they cannot be shadowed by let or def, only by other macros with the same name.
Personally I think this is a pretty good answer to the hygiene issue. Probably not necessary in every single macro you write, but good if you intend lots of other people's code to use it.
If I understand this correctly, `(,foo ...) embeds the foo function into the s-expr returned by the macro, IOW the car of the s-expr is the function.
While I find this an interesting approach, one problem I see is that this only works as long as Arc is an interpreter. Embedding foo into the s-expr mixes up runtime values (the function foo) and expand-time values (the s-expr).
In a compiler, you would have one runtime in which foo exists, and another runtime (the expand-time, at a higher "meta level") in which the s-expr exists, and the two runtimes can never meet -- they exist on different levels of the reflective tower.
(I am not entirely sure of this, and in any case it does not apply to Lexicons.)
It turns out that the current implementation has a serious bug, so at the moment the answer is no, it doesn't. But the situation appears to be salvageable.
> If this works then why did people both writing all those posts about hygiene?
Well, this is (a form of) hygiene. But it's not complete. As others have observed, it doesn't work for macros (though once the bug is fixed it will) and you still have to put in gensyms (a.k.a. uniqs) manually to avoid downward capture.
I know compose works on macros... but I'm not sure you are straight on, because compose uses apply as well. And the macro expansions look exactly the same.
arc> (macex '(compose no litmatch))
(fn gs1639 (no (apply litmatch gs1639)))
arc> (macex '(complement litmatch))
(fn gs1641 (no (apply litmatch gs1641)))
arc> ((compose no litmatch) "a" "aston")
nil
arc> ((complement litmatch) "a" "aston")
Error: "vector-ref: expects type <non-negative exact integer> as 2nd argument,
given: \"a\"; other arguments were: #3(tagged mac #<procedure>)"
except calls to compose are optimized away in the interpreter. they are treated specially. look in the `ac' function in ac.scm. i'm guessing this is the reason.
Now, what to do about the other case... there's still no reason it should bug out, it seems to me. Or rather, it should be implementable in such a way that it shouldn't.
Yes, we do. But if I recall (and I can't test, because the git "wiki" broke for later mzschemes again), apply does work for macros, except it evaluates all the arguments first, which breaks things like and. Someone should test that, though; as I noted, I can't.
I saw, that's how I was able to test. Thank you for setting it up, by the way! And if you fixed it, thank you for that; if someone else did, thank them for that.
The answer is probably obvious... but could you explain exactly what special forms you are talking about (are you talking about things like if and fn, or something else entirely)? And what can you use special form objects to do?
My solution calls the first parameter as a function when the object in the functional position is a number or symbol. The math operators are then overridden in infix.arc to do infix evaluation when they get a function in their parameter list.
This eliminates the need for explicit infix and prefix macros (the sqrt call below uses prefix notation in the middle of the infix expression):
(3 + 4 * 5 - (sqrt 36))
If we had first class macros we might even be able to convert the expression at compile time rather than run time.
I definitely think there is a lot to improve on, and your version of the infix macro has some features mine doesn't (e.g. associativity).
I don't know if my version would work for comparison logic... The program actually switches when the functional position is a number or symbol, and since t and nil are symbols, it would theoretically work.... But point is, my current version is not very extensible.
I'd seen your post so I was hesitant to post mine, but I think it's worth it because we're using two different approaches.
I'm trying to let the user specify what is/isn't infix, which is why I detect operators rather than numbers. I want the macro to have uses beyond infix arithmetic e.g. parsers expressed in BNF.
Also, mine is written entirely in Arc, so it's a good demonstration of what Arc can do, not to mention good practice for me.
I fully support what you are doing, people might not want implicit infix math all the time. It also looks like you are thinking more toward how to let the user define infix operators, which my version doesn't do a good job with.
I actually rewrote my version in arc, except for 2 lines in ac.scm (one which implemented something pg was already thinking about, and one which allowed (eval (list + 3 4))). I posted a comment about it on my original post, but I think it got buried so far down that no one ever saw it.