Arc Forumnew | comments | leaders | submit | sjs's commentslogin
2 points by sjs 6290 days ago | link | parent | on: Odd behavior with some HTML-work

It's a clever hack but I'm not crazy about the inline CSS and JS in news.arc. I would just serve static files and as a bonus you'll get all the benefits of the CSS and JS modes of your text editor while editing the stuff. Perhaps pg just wanted to keep the arc dir tidy and doesn't actually do that on news.yc.

-----

2 points by sjs 6291 days ago | link | parent | on: Arc2.tar

You can use git as a frontend to an svn repo but I haven't heard about doing it the other way. Because git is a superset of svn it may be possible but a quick search turns up nothing. Setting up cygwin is a snap. I am still a git noob. After an hour or two of reading you'll be able to use the git basics and after a few hours more reading you'll be able to use the basics and actually know wtf is going on underneath.

http://robsanheim.com/2008/02/22/learn-git-10-different-ways...

-----

9 points by sjs 6292 days ago | link | parent | on: arc-mode.el for emacs

Me neither, but I gave it a shot. I use it and it works, there may be bugs though. Maybe an Emacs guru will be kind enough to point out the errors I may have introduced while adapting cmuscheme.el.

http://samhuri.net/inferior-arc.el

In my dot-emacs:

  (setq arc-program-name "~/src/anarki/arc.sh")
  (load "~/.emacs.d/inferior-arc.el")
Then go ahead and do run-arc, arc-send-definition{,-and-go} (C-c C-e, C-c M-e) arc-send-region{,-and-go} (C-c C-r, C-c M-r), etc.

-----

5 points by nex3 6292 days ago | link

I've added this to Anarki. I'm working on making a few improvements.

-----

1 point by cooldude127 6292 days ago | link

i look forward to seeing what you come up with

-----

1 point by cooldude127 6292 days ago | link

it's a good start. the bugs i see immediately are it lets you erase the prompt and the prompt appears when results are printed too. i might see if there is a way to solve these problems.

-----

1 point by raymyers 6292 days ago | link

I think Slime lets you erase the prompt too. I wonder if there is a good reason for that...

-----

1 point by cooldude127 6292 days ago | link

just tried it. emacs says "text is read-only". which is what it should do. i haven't the slightest idea how it pulls this off, though.

-----

1 point by nex3 6292 days ago | link

Turns out it's just a simple option: comint-prompt-read-only. I've set it in Anarki.

-----

1 point by cooldude127 6292 days ago | link

that was far too easy. i wonder if it is possible to make it pretty print.

-----

1 point by nex3 6292 days ago | link

I think it just outputs whatever Arc sends its way. So this would really involve getting Arc to pretty-print its output.

-----

2 points by cooldude127 6292 days ago | link

that might not even be that difficult, but my main problem is arc's pretty printing (in "pprint.arc") is rather flawed.

-----

1 point by cooldude127 6292 days ago | link

the latest changes in anarki for the --no-rl option fix the problem with the repeated prompt. so now it's just that the prompt can be deleted, which is a really minor issue.

-----

1 point by sjs 6292 days ago | link | parent | on: Hello web app broken again on Linux

This code can be simplified a little bit:

    (let val (tostring (system 
                        (string "date -u "
                               (if  (is (uname) "Linux") "-r @" "-r ")
                               time " \"+%Y-%m-%d\"")))
But it's still fragile and non-portable so go with kens suggestion.

-----


As long as he wasn't just waking up... ;-)

-----

3 points by sjs 6296 days ago | link | parent | on: Docs?

If you get the git "wiki"[1] (open commit access) there are docstrings for many fns & macros, and the docs can be accessed from the repl using (help <name>), fns matching a prefix can be listed, e.g. (fns "m").

As a bonus, if you fire up (asv) and browse to http://localhost:8080/help there's some online help that links the bracketed "see also" [[names]] in the docstrings to their documentation.

[1] http://arclanguage.org/item?id=809

-----

2 points by almkglor 6296 days ago | link

Another note: you can search through the docstrings by using (help "<string>"). Note that (help ...) differentiates by the quotes on the string. So

  (help string)
returns the docstring for the function 'string, while

  (help "string")
prints a list of functions whose docstrings contain "string".

-----

2 points by sjs 6297 days ago | link | parent | on: Templating language or MVC-style arc?

You just do your own separation of logic & design, using Arc as the template language. I know it sounds PHP-esque but in practice it seems rather elegant so far.

e.g.

  ;; the controller-ish part
  (defop problems req
    (display-probs (get-user req)))

  ;; the view-ish fn
  (def display-probs (u)
    (mypage  ; a layout-ish macro
      (each id (keys probs*) (display-prob u (probs* id)))))

  ;; a partial-ish fn
  (def display-prob (u p)
    (tag (div class "prob")
      (tag (span class "pid")  (pr (p 'id) "."))
      (tag (span class "text") (pr (p 'text)))
      (tag (div class "links")
           (let bar* " &bull; "
             (w/bars
               (link "details"
                     (string "http://someurl/foo?bar=1&id=" (p 'id)))
               (link "solve" (newsolnlink (p 'id)))
               (link "solutions" (solnlink 'p (p 'id))))))))

-----

1 point by sjs 6298 days ago | link | parent | on: Syntax for optional/keyword args

How about something like this:

  (def kw args
    (listtab (pair args)))
That makes it pretty easy to pass around kw args, and with a macro you could make it a little more sugary by allowing unquoted keys.

-----

5 points by sjs 6298 days ago | link | parent | on: Automatic .arc reloading in background

This is great, thank you. If I have to wait any time I get antsy so I changed the interval to 3s. I also changed map to each and got rid of the "* redefining foo" noise.

  (def reload-check (paths (o mtimes (table)))
    (sleep 3)
    (each p paths
      (if (no (mtimes p))
           (= (mtimes p) (mtime p))
	  (isnt (mtimes p) (mtime p))
           (do
	     (= (mtimes p) (mtime p))
             (tostring (load p)))))
    (reload-check paths mtimes))

-----

4 points by sjs 6299 days ago | link | parent | on: Monadic-like macro

Interesting. I might be able to use this.

  (mac w/ (val . forms)
      ((afn (x f)
         (if (no f)
            x
            (self `(let _ ,x ,(car f)) (cdr f))))
       val forms))

-----

1 point by applepie 6299 days ago | link

Sorry about the bugs. I transcribed it from paper :$

-----

More