Arc Forumnew | comments | leaders | submitlogin

Yes. Version 372 was the last version which supported set-car! and set-cdr! for regular cons cells, so Arc 3 was locked to that version. However, Arc 3.1 overcame this limitation by using pointer manipulation to mutate cons cells anyway. This would sometimes fail, but this Arc 3.1 bug has been fixed in Anarki and Arc/Nu.

The /install page on this forum still refers to Arc 3, so this version dependency is a frequent point of confusion.


I guess the moral of the story here is that ,(...) evaluates the entire sexp, and puts the value there.

Yup! If your quasiquoted expression only contains unquotes, the expansion is simple. Basically,

  `(sexp1 sexp2 ... ,sexpn ...)
will expand into

  (list 'sexp1 'sexp2 ... sexpn ...)
This also applies recursively, so that

  `(sexp1 (subexpr1 ,subexpr2))
expands into

  (list 'sexp1 (list 'subexpr1 subexpr2))
With unquote-splicing, you can think of quasiquote expanding into cons, so

  `(sexp1 sexp2 ,@sexp3)
will expand into

  (cons (list 'sexp1 'sexp2) sexp3)
If you're interested, I encourage you to look over my implementation of quasiquote in Arc. It's actually pretty simple (175 lines with comments), and might help clarify how quasiquotation works.

I'll have to do more reading about macros.

I think you seem to have the mental model for macros down. And I've always said that macros aren't that magical, because they fall out as a natural consequence of the language. Hell, here's a simple Arc "interpreter" that shows how macros are handled differently from functions:

  (def interpret (expr)
    (if (acons expr)
        (let op (interpret (car expr))
          (if (isa op 'mac) (interpret (apply (rep op) (cdr expr)))
              (isa op 'fn)  (apply op (map interpret (cdr expr)))
                            (eval expr))) ; punt on special forms (fn, if, etc.)
        (maybe-lookup-name expr)))

  (def maybe-lookup-name (expr)
    (if (and (isa expr 'sym) (bound expr))
        (eval expr)
        expr))
Here, interpret is really just another name for eval. Macros are simply functions whose inputs are unevaluated code. They construct some other bit of unevaluated code, and that result gets evaluated.

Quasiquote is then just a nice way to construct lists, whether it's unevaluated code for a macro to return or whatever. Its syntax takes some getting used to, but it comes with practice. Happy hacking!

4 points by zck 4832 days ago | link | parent | on: Quasiquoting and understanding macroexpansion

Ah, fantastic! Thanks for the hint.

For some reason, I had in my head that, inside quasiquote in a macro, you need to unquote every variable you want to evaluate before returning the code to be executed. Note that all my examples have ,sym1 and ,sym2 (except fancy-combine4, but that's deliberately executing the code before the returned generated code).

I guess the moral of the story here is that ,(...) evaluates the entire sexp, and puts the value there. I'll have to do more reading about macros.

2 points by thaddeus 4833 days ago | link | parent | on: Help me customize news.arc

Assuming you're using 'GNU screen' you also have the option to re-attach to an existing session using the 'screen -r' command. Using 'screen -ls' will list out all the sessions should you not be sure, or have more than one.

That aside, most developers will do development changes on a local machine where they need not attach/reattach and this way you wouldn't need to troubleshoot your code and the host environment at the same time.

Then you create a stable deployment process. eg. Backup the old code, drop in the new code, re-attach to the existing session and either load your changes or restart the program if you're ok with some nominal downtime.

Hope that helps.

2 points by pier0 4833 days ago | link | parent | on: Help me customize news.arc

I eventually connected the problem with the multiple copies of Arc running with having a detached screen, so I stopped that and closed the terminal.

After doing so the news site was down, which I believe is what Thaddeus was recommending to happen.

Then I had to restart it and detach the screen and start the process again.

It is not ideal, but I think it works.


The error you're getting from fancy-combine2 is because you have a double-unquote. You neglected to remove the unquotes from sym1 and sym2. The correct form would be

  (mac fancy-combine (sym1 sym2)
    `(consume-symbol ,(generate-symbol sym1 sym2)))
It might help to have a user-land defined quasiquote macro, to see how it works. I implemented such a macro here: https://bitbucket.org/fallintothis/qq

Using qq.arc, we can see that my solution is to use this expression:

  arc> (macex1 '(quasiquote
                  (consume-symbol (unquote (generate-symbol sym1 sym2)))))
  (list (quote consume-symbol) (generate-symbol sym1 sym2))
On the other hand, your version is like this:

  arc> (macex1 '(quasiquote
                  (consume-symbol
                    (unquote (generate-symbol (unquote sym1)
                                              (unquote sym2))))))
  (list (quote consume-symbol) (generate-symbol (unquote sym1) (unquote sym2)))
Hence, you get an error about unquote being undefined, because Arc doesn't actually define quasiquote or unquote as macros. They're just special identifiers that are basically parsed away before evaluation (assuming quasiquotes/unquotes are balanced). However, loading qq.arc defines an unquote macro, so instead of the error you had, you'll get this:

  arc> (fancy-combine2 a b)
  Error: "unquote not allowed outside of a quasiquote: a"
which makes it a bit more obvious what the error is.
3 points by akkartik 4834 days ago | link | parent | on: Could not open a link in a new window

Ah yes, the legal attributes for different html tags are specified by the attribute macro in news.arc: https://github.com/arclanguage/anarki/blob/f17c3d2016/lib/ht.... Try adding a similar line:

  (attribute a target opstring)
Here's a more comprehensive fix I made in my repo: https://github.com/akkartik/arc/commit/d7f9b05463#diff-1. I'll update anarki later today or tomorrow, but feel free to send me a pull request :)

Update: it turns out this already works in anarki (thanks to Mark Huetsch): https://github.com/arclanguage/anarki/commit/8fb05f1383#html.... Where did you download arc from, codepapa? Please take a look at https://sites.google.com/site/arclanguagewiki for better-supported versions.

1 point by akkartik 4835 days ago | link | parent | on: Elm 0.9: reliable static typechecking

Yup! I looked for it a bit, couldn't find it, tried to post the top-level website, got caught by the dup detector, and ended up posting the thread that brought it back to my attention :)
2 points by rocketnia 4835 days ago | link | parent | on: Elm 0.9: reliable static typechecking

Oh yeah, you posted a topic about Elm 76 days ago:

http://arclanguage.org/item?id=17717

3 points by thaddeus 4835 days ago | link | parent | on: Help me customize news.arc

No problemo and yeah, in retrospect, I could have chosen better terminology and been much more descriptive, but that's one of the things you will enjoy about the arc forum... You just keep asking and, generally speaking, people are very helpful. After all, I learned how to program by just doing what you are, running the news app, reading the arc code and relying on this forum for help along the way.
2 points by akkartik 4837 days ago | link | parent | on: Help me customize news.arc

Great!

Out of curiosity, how do you stop the server once you start it?

2 points by pier0 4837 days ago | link | parent | on: Help me customize news.arc

I couldn't understand what you meant by "make sure its no longer running news" but now I know.

Basically I got a bad gateway error and the web page was no longer accessible until I reloaded news.arc

  arc> (load "news.arc")
  arc> (nsv)
Thanks thaddeus
2 points by pier0 4837 days ago | link | parent | on: Help me customize news.arc

I did as you suggested and found a second process running, Then I run this

kill $(ps aux | grep '[m]zscheme' | awk '{print $2}')

and it killed one. After it was just a matter of starting-restating Arc with the changes in news.arc.

And next is the logo. Thanks for your precious advice.

PS In the previous post I was starting to doubt that I'm not supposed to use mzscheme -f as.scm as a command to get to the Arc prompt

3 points by akkartik 4837 days ago | link | parent | on: Help me customize news.arc

No, you want to run:

  $ ps aux |grep mzscheme
ps doesn't know about news.arc, that's just one of the files loaded by mzscheme.

I didn't understand the second and third paragraphs. Can you tell me more about what version of arc you downloaded and how you're running it?

2 points by pier0 4837 days ago | link | parent | on: Help me customize news.arc

I used the command ps aux | grep 'news.arc' and it returned only one copy running, but I suspect that's not right.

And your comment about multiple copies also got me thinking that from the main Arc directory to go into the Arc prompt maybe I shouldn't have been using $ mzscheme -f as.scm

Was I supposed to use that just once to run news.arc for the first time?

2 points by akkartik 4838 days ago | link | parent | on: Help me customize news.arc

Yeah these are good suggestions. The "address already in use" error suggests that you might have multiple copies of arc running, so that you're making changes to the wrong copy. Use the commands 'ps' and 'kill' to look for the other copies and stop them.

http://stackoverflow.com/questions/3510673/find-and-kill-a-p...

4 points by thaddeus 4838 days ago | link | parent | on: Help me customize news.arc

Hmmm it's been a really long time since I looked at the code, but I would try two things.

1. Enter this-site* at the prompt to confirm the change took place.

2. Abort the session, I.e such that the arc prompt is killed. Then goto the webpage and make sure its no longer running news (just to confirm the abort occurred and/or is not somehow running a past instance), then reload arc again.

2 points by pier0 4838 days ago | link | parent | on: Help me customize news.arc

fallintothis,

thanks for your clear explanation.

I tried to put the entire expression into the arc> prompt and also tried to use simpler expressions, but I still can't get "My Forum" to change.

I've also reloaded news.arc several times and I'm not sure if it means anything, but when I go back to the arc> prompt and enter arc> (load "news.arc") I get nil

and only after loading news.arc a second time I get the "* redefining" messages

I remember that to run news.arc the first time I also used (nsv) so I tried that as well and for what is worth I got the following error:

  rm: cannot remove ‘arc/news/story/*.tmp’: No such file or directory
  load items:
  user break
  context...:
   /home/ubuntu/arc/ac.scm:1031:20
    gs1259
  user break
  context...:
   /home/ubuntu/arc/ac.scm:1031:20
    gs1259
  Error: "tcp-listen: listen failed\n  port number: 8080\n  system error: Address already in use; errno=98"
  arc>
4 points by fallintothis 4839 days ago | link | parent | on: Help me customize news.arc

Editing news.arc won't "reload" your changes. If you write the code to the file, it won't actually execute that code. Does that make sense?

You want to go back to the arc> prompt (where you started (nsv)) and do something to get that code to run. You could do this in a few ways. You could do:

  arc> (load "news.arc")
which will reload the changes you saved to the news.arc file. It might look crazy, because it prints out a bunch of messages that look like

  *** redefining logins-page
It'll do that because it's reloading the entirety (!) of news.arc, which includes a bunch of other code. Thus, there are warnings about "redefining" certain code. But as long as you didn't actually change the code in question, it should be fine.

At the end of the day, this is probably the best way to go, despite all the intimidating warning messages. Because if you edit the news.arc file, then the changes you make will be saved in case you ever need to restart the forum in the future.

But, for the sake of completeness, I'll explain how you can also just edit the variables by hand at the prompt. So, instead of changing news.arc to say

  (= this-site*    "Match Fixing Scandals"
     site-url*     "http://news.yourdomain.com/"
     parent-url*   "http://www.yourdomain.com"
     favicon-url*  ""
     site-desc*    "What this site is about."               ; for rss feed
     site-color*   (color 180 180 180)
     border-color* (color 180 180 180)
     prefer-url*   t)
and reloading news.arc, you could actually just put the entire thing above (called an expression) into the arc> prompt:

  arc> (= this-site*    "Match Fixing Scandals"
          site-url*     "http://news.yourdomain.com/"
          parent-url*   "http://www.yourdomain.com"
          favicon-url*  ""
          site-desc*    "What this site is about."               ; for rss feed
          site-color*   (color 180 180 180)
          border-color* (color 180 180 180)
          prefer-url*   t)
This will execute the code, thus modifying your settings.

You could also use simpler expressions---or, really, any Arc code you want. If you weren't a coder before, you are one now! :)

The expression above of the form (= a b c d ...) can be used to change the values of any number of variables (setting a to b, c to d, etc.), which will control how the site displays. So, you could do something like

  arc> (= this-site* "Whatever")
  "Whatever"
  arc> (= site-url* "google.com" parent-url* "wikipedia.org")
  "wikipedia.org"
whenever you want.

One of these settings you'll want to change is buried deep inside of news.arc (about 400 lines down), so it's hard to spot. But, you can change these variables, too:

  (= up-url* "grayarrow.gif" down-url* "graydown.gif" logo-url* "arc.png")
For your purposes, you can do something like

  arc> (= logo-url* "some-other-logo.png")
and make sure that some-other-logo.png is in your static/ directory.

Hope that helps!


Is Racket not an available package? Googling "yum install racket" gives the following instructions for installing Racket on Fedora:

http://cha1tanya.com/blog/2013/06/05/installing-racket-on-fe...

http://linuxg.net/how-to-install-drracket-on-fedora-18-and-f...

Otherwise, Googling "How can I install the Racket on CentOS?" gives:

http://lists.racket-lang.org/users/archive/2011-April/044979... (from 2011, so could very well be outdated)

http://racket-lang.org/download/ (all else fails)

2 points by rocketnia 4842 days ago | link | parent | on: Koding.com signup open to all

http://koding.com

Koding is a website that provides a limited amount of FTP-accessible storage (I think around 4GB? Maybe 2GB?) and a limited VPN to use for Web development. I think it supports SSH access, but I've only used the in-browser shell. Last I checked, long-running processes don't survive between shell sessions.

On the other hand, it supports CGI-style websites based on PHP, Ruby, and some other languages. These pages can stay online forever.

Koding was previously open-signup under the name Kodingen, but it didn't have any support for shell access at that time. Nevertheless, I successfully ran shell commands via PHP and Ruby scripts, and this was enough to test out Racket and Arc programs.

Not too long ago I removed my Arc installation from my Koding account. Racket was taking up too much disk space, and http://tryarc.org was enough for me. :) I'm pretty sure the potential is still there if someone's interested.


Thanks! You're absolutely right, I've had every single one of these problems, I just never focused on them. But I'd often comment out a bunch of tests in the middle of debugging just one.

(brianru also reminded me that arc has a whole new recent unit-test framework with suites: https://github.com/brianru/anarki/commit/b62a38ebcd via https://github.com/arclanguage/anarki/pull/15)

4 points by zck 4844 days ago | link | parent | on: Help debug some finite state machine code?

I'm going to have to go to bed soon, as I need to wake up in eight hours and twenty minutes, and I've promised myself I'm going to try to sleep enough, for once.

So I'll just explain what, in my mind, is the biggest difference -- how I want to use it. To run the anarki test-iso test, you execute the entire `(test-iso ..)` sexp. If you want to run a bunch of tests, you have to execute all the sexps.

That's kind of a hassle. Especially if you find a bug, have a bunch of tests that fail, then change a small thing in the function, and want to re-run all the tests.

In my unit-test.arc, all you have to do is call `(run-suites suite-name)`, and it'll run as many tests as you've got in `suite-name`. You don't have to copy a bunch of sexps into the repl or reload the file (and what if you want to run a subset of a file? You can't). Also -- and this is one of the features I'm currently working on (https://bitbucket.org/zck/unit-test.arc/issue/21/after-runni...), what if you run one hundred tests at once? Do you really want to parse -- with your eyes, like a bloody scribe -- every single line of output to find the seven tests that broke? And when you then make a fix, you're not going to want to parse them again, so you'll only run the seven that failed before. So if you broke something else, you won't find that out.

So, what falls out of my desire to run a set of tests easily and repeatably, and have summarized output? Some sort of grouping, with a single point of entry to run the tests -- that is to say, test suites.

Please correct me if I've missed any feature of Anarki's test framework. I did read its code and try it, but I didn't look into other files for supporting functionality.


That makes sense :) I'd love to hear more about what's fiddly about the existing version (I have different versions at http://github.com/akkartik/arc, etc.) and why you need the features (suites, nested suites, failure messages, anything else?)
4 points by zck 4844 days ago | link | parent | on: Help debug some finite state machine code?

Well, if it might be useful, let's do it. https://bitbucket.org/zck/unit-test.arc

Please let me know what you think -- email in profile, comment here, open bitbucket tickets, find me on the street^1, etc.

[1] Actually, after writing this, I read your profile, and found you're in Hacker School. I'm in nyc too -- we should meet up sometime. Shoot me an email.


Sweet. I had been wanting to play around with the unit test code too -- i'm excited to see what you've put together.

The oauth utility is also for the LISP contest -- we'll see how far I get over the next few weeks.

Either way I'm planning on uploading a few bits and pieces to Anarki or my own repos over the next couple of weeks. (spent some time on anarki's web.arc, the state machine stuff, oauth, some lazy evaluation stuff, etc...)

Once it's all up I'd love some help!

3 points by zck 4845 days ago | link | parent | on: Help debug some finite state machine code?

Honestly, there are some fiddly bits about the unit test framework I don't like, but mainly I wanted to write one.

I actually applied with it for Lisp In Summer Projects (http://lispinsummerprojects.org/), which is why I haven't announced it -- you're supposed to do the work yourself, without help. And people here like to help out and post code. :-p

Luckily, at this point it's got the main features I want, so I can actually use it.


But anarki has a unit test framework already: https://github.com/arclanguage/anarki/blob/7415f52cdc/lib/ar.... It also has some intermittent unit tests, e.g. https://github.com/arclanguage/anarki/blob/7415f52cdc/arc.ar...

Did you mean in some other language? It's easy to build a test harness, it's usually the first thing I do with a new language, and invariably just a few lines of code.

Here's my test harness in C++, for example: https://github.com/akkartik/wart/blob/cc70d66ee6/literate/00.... Even in C++ it's just 50 lines or so. Dynamic languages are often even shorter.

(It's not a normal C++ project. I use readable diff directives inside :(..) to add the test harness to the skeleton program at https://github.com/akkartik/wart/blob/cc70d66ee6/literate/00.... But now that this is done, any function I write with 'test_' is automatically run in test mode. Look at the makefile to see how I do that with minimal code.)

Anyways, tell me what language and I'm sure we can get you quickly past this hurdle.

2 points by zck 4846 days ago | link | parent | on: Help debug some finite state machine code?

Good luck. I could use one -- I've wanted to use it with Twitter for a while. I started writing one myself, then realized I needed a unit test framework, so I've been working on that. Oh, the perils of a language lacking libraries.

Would you like some help? As long as it's free software, I'd love to assist.


It works, thank you!

I'm trying to make an oauth utility and it seemed like a cool idea to use a state machine. Fingers crossed.

More