Arc Forumnew | comments | leaders | submitlogin
1 point by lark 4957 days ago | link | parent | on: How do you http redirect in Arc?

It might be better if [ "foo" ] expanded to:

  (fn(_) (do "foo"))
rather than

  (fn(_) ("foo"))

EDIT: On second thought, I doubt that's what [ "foo" ] expands to:

[ ... ] expands to (fn(_) (...))

Because you can already write aform submission code that looks like:

  (defop said req
    (aform [ (pr "You entered " (arg _ "foo"))]
      (input "foo") 
     (submit)))
If that's what [ ... ] expands to, aform wouldn't even work so far because it would be trying to call:

  (fn (_) ((pr "You entered.")))
That would be a function call to a function call: (( on the call to pr.
1 point by akkartik 4958 days ago | link | parent | on: How do you http redirect in Arc?

I wasn't aware of aformh before, but yes it's not supposed to redirect. But arformh is.
1 point by akkartik 4958 days ago | link | parent | on: How do you http redirect in Arc?

[ ... ] expands to (fn(_) (...))

So [ "foo" ] expands to (fn(_) ("foo")), which fails because you're trying to call a string like a function.

Just use (fn() "foo").

1 point by thaddeus 4958 days ago | link | parent | on: How do you http redirect in Arc?

Why not just pass a session id/key to the second URL* and allow that new page to retrieve the data you don't want exposed?

*or use a hidden field on a form submit.

BTW the limitations you're hitting have nothing to do with Arc or Closures, but rather are just limitations of Browser/HTTP technology (which are by design).

1 point by lark 4958 days ago | link | parent | on: How do you http redirect in Arc?

All this redirecting still doesn't get me what I want.

I would like this second link to be what shows up on the top of the browser as the new url. -- but I would also like that page to be initialized with parameters I could express so far only with a closure.

I don't want to pass those parameters to the second link, because then they'll be visible.

So now I need to first save these initialization parameters somewhere (much like saving a closure) and modify the second link to check if there are any scheduled parameters to initialize itself with for a particular user. Some sort of defop-init.

(Am I missing something?)

Down the drain go closures when combined with redirection.

What a hack.

1 point by lark 4958 days ago | link | parent | on: How do you http redirect in Arc?

Well, there is a syntax issue. Using square brackets to express fn fails:

  (defop arf rq (arform [ "foo" ] (prn "Click:") (submit)))
2 points by lark 4958 days ago | link | parent | on: How do you http redirect in Arc?

The documentation at http://arcfn.com/doc/srv.html reads: "The callback function f must return the redirect target."

The following works:

  (defop arf rq (arform (fn (req) "foo") (prn "Click:") (submit)))
So it is only arform that redirects, not aformh or arformh.
1 point by lark 4958 days ago | link | parent | on: How do you http redirect in Arc?

Great so far. Now... how would you redirect after submitting a form?

  ;; aformh doesn't do it
  (defop prove-it1 req
    (aformh [ (pr "peekaboo") ]
            (pr "do something1 ")
            (submit)
            "/some-fancy-url"))

  ;; Neither does arformh
  (defop prove-it2 req
    (arformh [ (pr "peekaboo") ]
            (pr "do something2 ")
            (submit)
            "/some-fancy-url"))

  (defop some-fancy-url req (pr "Yeii!"))

I didn't know screen allowed you to keep a running log file. Had I known that before I probably could have solved a few head scratchers a little easier.

That was useful, thx.


good tutorial on screen: http://www.rackaid.com/resources/linux-screen-tutorial-and-h...

http://www.arclanguage.org/item?id=17479

Also check out http://arclanguage.org/item?id=4708 for making changes to a running server.


will do

OK - now how do I get it to run unattended? It is running from the console right now so disappears when I close the terminal.

http://geoengineeringnews.bitnamiapp.com:8080/news

2 points by Pauan 4959 days ago | link | parent | on: Trying to get Arc News running for HN clone

When akkartik said "the Nu branch", he meant this:

https://github.com/Pauan/ar

I too recommend using it rather than vanilla Arc. It has many bug fixes and new features, yet is still backwards compatible.


racket -f as.scm works! moving forward ...

Weird. Can you try running the main branch of anarki with just:

  $ racket -f as.scm
? We're trying to move away from legacy mzscheme. Let us know if the error persists.

In general, the instructions we've been steering newcomers toward are at https://sites.google.com/site/arclanguagewiki/getting-starte..., which we try to keep up-to-date. If that helps in this case.

(Once you resolve this issue I'd also recommend switching to the Nu branch described in the above link. It's a much more clean and modern implementation.)


tried running it as sudo. No change. There are 23 characters in the first line of as.scm and I am getting the error message

read failed to read all 23 bytes from file mzscheme


I just upgraded to 5.3.3 but that didn't fix it. Still getting the same error.

I am wondering if there is a permissions problem. It sounds like mzscheme is trying to read as.scm but failing.


did you install the latest version of racket? there's an updated version since nicholas published his tutorial. i followed his instructions and everything worked fine.
3 points by thaddeus 4960 days ago | link | parent | on: Google Analytics inside news?

Note though, while votejs* may be appropriately placed in the page header section, my understanding is that you want your google analytics script tags to occur after your body section (or at the end of your body section) such that the page display doesn't have to needlessly wait.
3 points by akkartik 4960 days ago | link | parent | on: Google Analytics inside news?

Look for votejs* in news.arc, how it's defined and where it's used. You can insert arbitrary javascript by similar means, including the analytics code.

Does that make sense?

3 points by lark 4961 days ago | link | parent | on: How do you http redirect in Arc?

w/rlink was what I was looking for. Thank you!
2 points by akkartik 4963 days ago | link | parent | on: How do you http redirect in Arc?

There's actually something called w/rlink :)

You might find http://arcfn.com/doc/srv.html useful.


Fun fact: if you used boxes, it would be really easy to associate the "withs" form with its expanded form, since the boxes would be the same.

The Nulan IDE already incrementally macroexpands as you're typing, and syntax-highlights boxes different colors depending on their scope. So this would be fairly trivial to add in.

1 point by lark 4963 days ago | link | parent | on: How do you http redirect in Arc?

Thanks, I'll try it.

How would you redirect when executing a closure created with w/link?


"Whoa, how do you mean?"

If we syntax-highlight (withs ...) this way, since it expands into several (fn ...) forms it'll give a different color to each of its variables. But that's assuming we're able to perform some amount of macroexpansion frequently enough to be useful as the programmer edits, and it also assumes we can relate the original syntax to the transformed version returned by the macro.

It would be interesting to see a macro system tailor-made for purposes like these. Some hygienic macro systems might already apply, but I wonder what the options are here. I think Reactive Demand Programming would be an effective ingredient for this kind of incremental program visualization, but that's not a complete plan on its own.

2 points by akkartik 4964 days ago | link | parent | on: How do you http redirect in Arc?

See defopr: https://github.com/nex3/arc/blob/2762cc15fe/lib/srv.arc#L203

You could also define the op for the first url to render a meta refresh tag: https://en.wikipedia.org/wiki/Meta_refresh#Examples


"I wonder how the pursuit of this feature could impact the design of a language's macro system."

Whoa, how do you mean?

One idea I've been thinking about a lot is to attach metadata to code. We can do a lot to code (pretty-print, optimize, ...) besides just eval it, and metadata might help with those without affecting eval.

My favorite use for this idea is to give functions levels:

  def (foo x y) :(level 3)
    34
(This is the 'other idea' for colons I referred to at http://www.arclanguage.org/item?id=17358, but I suck at surprises ^_^)

This can be used in a variety of ways by different tools. You could flag as errors any calls from a lower to a higher level, so that level 3 functions could only call functions in levels 1-3. You could tell tracers to trace everything until level x, not below. You could tell debuggers to automatically step past calls below level x and step _into_ calls above that level. In gdb I often accidentally hit 'next' when I meant 'step', and now I have to restart and laboriously try again from scratch.

You could syntax-highlight calls within a level to be more salient to calls to lower levels. We've all seen open source projects with this structure.

  void main() {into 
    ...  // lots of option parsing crap
    if (doSomething()) { // the actual app code
       ... // more crap
    }
    ... // more crap
    return -1;
  }
Here wouldn't it be cool to be able to highlight the doSomething() compared to all the other calls?

In general, syntax highlighting sucks[1] because we simply highlight the things it's easiest to infer. Metadata might help reduce the inference burden and open up new uses for color.

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


Wow, this makes a lot of sense, and I don't think I've ever heard of it before. I wonder how the pursuit this feature could impact the design of a language's macro system.

Less optimistically, I wonder whether it'll distract too much from meaningful patterns that span across nesting levels (e.g. imperative code in continuation-passing style).

1 point by Pauan 4964 days ago | link | parent | on: New version of Arc/Nu

By the way, if you use "parameter" and can't be bothered to change to the new system, you can use this macro:

  (mac parameter (x y)
    (w/uniq (var body)
      `(do (var ,x ,y)
           (mac ,(sym:string "w/" x) (,var . ,body)
             `(w/ ,',x ,,var ,@,body))
           ,x)))
Why didn't I just include it in Arc/Nu? Because I think the new system is better, so in the long run I really do want people to switch to the new system.
More