You can change the images used by replacing them in the app-root/repo/static directory.
I'm not sure where the copyright message you're referring to is. To replace it, you'd have to figure out where in the anarki code it's being generated, and override it in main.arc.
"Do we actually need the mzscheme dependency? Any reason we couldn't switch to a full racket base?"
There's always a reason, but these days Anarki has broke all my code enough times that that shouldn't be a concern. :)
I think this would be a positive change.
---
"...the reason you're using lists is so that 'nil is interpreted as no value, while '(nil) is interpreted as intentionally passing the value 'nil? How does the function know the difference?"
Arc doesn't support nil as an element of a table. Setting a table entry to nil removes it. Therefore '$kw-apply will only see non-nil values anyway.
As pg says: "In situations where the values you're storing might be nil, you just enclose all the values in lists." http://arclanguage.org/item?id=493
When I was using Arc heavily, I defined a utility (sobj ...) that was just like (obj ...) but it wrapped everything in a singleton list. That may have been the only extra utility I needed.
I could write (each (k (v)) tab ...) in place of (each (k v) tab ...). I could write tab!key.0 in place of tab!key. I could write (iflet (v) tab!key ...) in place of (iflet v tab!key ...).
It was surprisingly unintrusive, even pleasant.
---
"Normally, I would expect the purpose of the data interaction layer to be separating the implementation details from the code, so that if changes need to be made to what backend storage system you can just trade it out."
I like the sound of that, but I think it's always a bit leaky, unless the result is a full database design that lets people happily forget there's another database underneath.
Do we actually need the mzscheme dependency? Any reason we couldn't switch to a full racket base?
---
Interesting. I'll have to play around with that. And study it a bit more to figure out how it works. If I understand your description correctly, the reason you're using lists is so that 'nil is interpreted as no value, while '(nil) is interpreted as intentionally passing the value 'nil? How does the function know the difference?
---
Interesting opinion. Unless I misunderstood you, I would have felt the opposite way. Normally, I would expect the purpose of the data interaction layer to be separating the implementation details from the code, so that if changes need to be made to what backend storage system you can just trade it out.
Maybe that is what you mean though, and that's supposed to be a distinction between the "driver" and an additional abstraction layer. Though your comment about ORMs including sugar confuses that a bit. I don't really want sugar per se, just abstraction away from how I'm actually storing the data, within reason anyway.
Oops, I think you've been seeing something I wasn't seeing.
It turns out I'm getting much different results on a local setup than I was getting in tryarc.org. Since Arc 3.1 and Anarki use (require mzscheme), all sorts of things are replaced with doppelgangers that doesn't support keyword args, including the function application syntax #%app. In fact the lack of keyword arguments is one of the only things (require mzscheme) is good for. This is something tryarc.org changes, apparently.
"So, what's the right way to hack on arc to support calling racket functions with keyword args?"
I wouldn't say it's "the right way," but we could put the functionality of Racket's 'keyword-apply in a function that takes an Arc table, and then we'd pretty much never need to worry about keywords other than that.
I have an implementation for this, which I should be able to commit with some unit tests now that I know what's going on with MzScheme.
...Actually it might take me a few days to get around to that, so here's the code if anyone wants to use it right away:
(def $kw-apply (func kwargs . posargs)
; Convert the last element of posargs (the first-class list) into a
; Racket list. If posargs is completely empty, pretend the last
; element is an empty list just like Arc's 'apply already does.
(zap [rev:aif rev._
(cons (apply $.list car.it) cdr.it)
(list:$.list)]
posargs)
(let (ks vs)
(apply map list ; Transpose.
(sort (compare $.keyword<? !0)
(map [list ($.string->keyword:+ "" (or _.0 "nil")) _.1.0]
tablist.kwargs)))
(apply $.keyword-apply func (apply $.list ks) (apply $.list vs)
posargs)))
I'm using a table of singleton lists so that we can pass the symbol 'nil as an argument value.
---
"Or would it be better to make a more arc-idiomatic mongo driver, and how?"
I actually have some opinion about "the best way" for this. :)
I think Arc-idiomatic approaches serve no particular purpose, since Arc is a tool for general-purpose computation.[1] I would want a database driver to be idiomatic only for the database itself, so that it serves the more specific purpose of storing data. This can then be accompanied with sugary helper utilities, as long as they're optional.
It seems many ORMs want to bake the sugar into the interface, or they make sugar that has tiny escape hatches for poking at the underlying interface. If sugar is the only thing a programmer (usually) sees, I look at it as though it's a full-on database design of its own... which is rarely favorable since it usually inherits most of the complexity and obligations of the original.
[1] Well, while Arc is a general-purpose tool, it's specifically a language, so Arc-idiomatic approaches serve the particular purpose of making features more accessible to language users.
You should only have to restart it once. Calling 'load-userinfo from the repl is redundant, unless you want to check the value of the admins* table to see if it worked or not.
Which arc directory are you putting it in? There's the one that is the anarki installation under app-root/data, and the other which stores web app data in app-root/repo. You need to put the admins file in the app-root/repo/arc directory, or it won't be found by the app server.
That's probably not the right place to keep it, but I haven't bothered to redirect all of the arc server directories, so that's where it goes for now.
thx.but how to arc>? i stop the app ,cd arc, echo “admin” > arc/admins,,,arc> (load-userinfo) ,,,,and arc> (load "lib/news.arc"),,,rhc app-start news...what wrong?still cant find admins privilege in my page.
It looks like you have to restart the app server in order to get it to reload the user information. If you have repl access though, you can just run (load-userinfo)
I do think that we need a way to connect to the repl of the running service, as well as update the code without requiring a full restart, as that takes >20s most of the time.
I tried on my site with the url "http://google.com, and that worked. However, doing just "google.com" does not, so it's apparently filtering for fully qualified urls.
As for your error message when run from the command line... I get the same "rm: cannot remove..." message, followed by "load items" and "ready to serve port..." all of which are correct. The only real error is after that part, but I'm not sure why you're getting it. That error looks like something that might happen on a timeout or broken connection with the client.
What were the results on the client side? Did you get a blank page?
i got it done....and i check ur and my site find that both of us cant submit a simple url like(www.google.com but http://google.com works) with a title ,but only can submit a textwith a title...that's a new problem...if u could tell me what is the right step after the 8step as ur instructions as well.that will be great!---best wishes!
It seems to, though much of that is the ODBC layer, which I'm not sure I like anyway. It generates some constructors and getters and setters that use keywords, and I don't think that fits particularly well with the arc style.
Unfortunately, some of the database options are also keyword based, but maybe wrappers could be made for the few cases that matter? Sadly, I am also a beginner with mongo, so I don't really know what I need or how to do it.
My original goal was not to shave characters off of '#:key. I apparently misunderstood how they were supposed to work, and thought that arc wasn't compatible with them. I ended up doing the cosmetic change as part of my process of figuring out how to hack it onto arc.
If what you're saying about '#:key vs #:key is true though, then my test cases were incorrect and I was trying to make something work that shouldn't have.
So, what's the right way to hack on arc to support calling racket functions with keyword args? Or would it be better to make a more arc-idiomatic mongo driver, and how?
Since I copied it from RayRacine's rackos, it had accidentally said to add the remote as 'rackos', which makes the following lines incorrect. Maybe that wasn't your issue though. Any more details?
As for your repl test, you are directly calling '(nsv), which defaults to binding on port 8080 for all ips, which is against the OpenShift policy. What you want instead is:
(nsv '("127.8.109.xxx" 8080))
Where 127... is your OPENSHIFT_DIY_IP. You can see how it works if you look in main.arc. You may need to correct your current directory as well.
Another alternative would be to just load main.arc from the terminal, which would automatically start the server exactly as the post-deploy script does, but in a way that lets you see all of the errors:
(thread:load "../repo/main.arc")
Of course, you'll have to change the path depending on where you're running the arc interpreter from.
arc> (= k-idfn ($:lambda (#:k v) v))
#<procedure:zz>
arc> (k-idfn '#:k "hello")
Error: "struct procedure:zz: expects 0 arguments plus an argument with keyword #:k, given 2: #:k "hello""
This function expects 0 positional arguments and a #:k keyword argument. However, we've passed it 2 positional arguments, one of which is #:k and one of which is "hello". We haven't passed it any keyword arguments at all, let alone one with the keyword #:k.
We pretty much have two ways to call this function successfully.[1] First, we can write the function call itself as Racket code, taking advantage of Racket's function call syntax compiler to parse the keywords:
(Here I've used ($.list ...) as a way to construct ()-terminated instead of nil-terminated lists.)
Note that keyword-apply requires the keywords to be given in a specific order based on their UTF-8 bytes.
If we do a lot of this in the code, I'm thinking we could benefit from one of three things:
- An Arc function that takes an Arc table like (obj k (list "hello")) and calls Racket's 'keyword-apply it to the sorted keywords it expects.
- An Arc macro that looks like a function call, e.g. ($kw-call k-ifn #:k "hello"), but finds any occurrences of keywords and generates the appropriate Racket function call.
- A patch to Arc's own function call syntax so that it parses Racket-style keyword arguments.
I think these solutions would be more effective than shaving one or two heiroglyphics off of '#:k.
---
Not even Racket allows #:k as an expression by itself. It has to be written '#:k. After all, even if #:k evaluated to itself, (list #:k "hello") would not give you a list containing #:k and "hello", since it would try to pass a keyword argument instead.
You might wonder why Racket chose a design with such hoops to jump through. Well, I can't speak for them, but personally I'd give several shallow and hand-wavy reasons:
- It aligns with a certain mental model where positional args are an ordered list and keyword args are an orderless map. (This is the mental model I learned a long time ago in Groovy, so I like it.)
- It lets Racket treat (foo #:a 1 #:b #:c 3) as a compile-time error.
- It lets Racket treat missing/extra keyword args and missing/extra positional args as the same kind of error.
- It means keyword args don't have to be described in terms of positional args. It would be possible to design a lisp that only has Racket-style keyword args, with no positional args whatsoever.
- It means when a programmer wants to get a procedure's arity information dynamically, the result can include information about the keyword args it supports, rather than just the positional args it supports.
---
[1] Hmm, maybe there's a third way to call it successfully:
thx,bro,u really rock...so i rebuild a new site http://news-tvvocold.rhcloud.com and i can sign up and login in...but i can't submit still...why that? follew ur instructions i cant push (stuck at 5th step)so i use this
arc> (nsv)
rm: cannot remove"arc/news/story/*.tmp": No such file or directory
load items:
ranking stories.
tcp-listen: listen failed
port number: 8080
system error: Permission denied; errno=13
context...:
zz
/var/lib/openshift/53755de6500446c100000b1a/app-root/data/arc/ac.scm:1227:4
and i repeat again :arc> (nsv)
rm: cannot remove"arc/news/story/.tmp": No such file or directory
load items:
ranking stories.
user break
context...:
/var/lib/openshift/53755de6500446c100000b1a/app-root/data/arc/ac.scm:1084:20
recur
recur
user break
context...:
/var/lib/openshift/53755de6500446c100000b1a/app-root/data/arc/ac.scm:1084:20
recur
recur
tcp-listen: listen failed
port number: 8080
system error: Permission denied; errno=13
context...:
zz
/var/lib/openshift/53755de6500446c100000b1a/app-root/data/arc/ac.scm:1227:4
if u update the full instructions that will be great and grateful,,,thx very much!
(add this will be helpful
Interesting. Well, I can push what I currently have, and if necessary remove it later.
Also, one issue is that after adding ssyntax support, :symbol is printed as #:symbol, since they're the same. Should I be adding a special case for that?
After hacking on this for a bit, I determined that adding ((keyword? s) s) to the primary ac cond was necessary either way. So, after adding that the #:symbol syntax works as well, since we're mostly just using the racket reader.
Still, I think that the :symbol syntax is a little cleaner and also matches common lisp. Any reason I shouldn't add it?
Would anyone mind if I changed ssyntax so that ':symbol expanded into the same thing as #:symbol? ":" currently doesn't mean very much as the first character of a symbol. In fact, I think that currently ':symbol == 'symbol.
That's a bug I'm currently fixing. It happens because arc uses the pattern of creating a temporary file and then moving it, instead of directly writing to an existing file. The only problem is that the /tmp directory on the rhcloud gears is not on the same file system. So it fails to move the file.