Arc Forumnew | comments | leaders | submitlogin

I just tried it behind apache, and the fix is still in working condition. Can you check if you made an error in adding it?

Is your codebase someplace public? Feel free to email it to me (address in profile). Or paste in that section of your srv.arc into a comment here to get some more eyes on it.

Did you copy the fix from https://github.com/nex3/arc/commit/1f69b0edb9? Try using the current head: http://github.com/nex3/arc/blob/7f3a5a2979/lib/srv.arc


You can backup your database (Arc folder within your VPS), then upload this code https://github.com/rick2047/arc

You can do some optimization and customization on the code such as removing some Hackerstreet related stuffs.

I also run another test site at Amazon EC2 free tier VPS:

http://vietstudying.com

1 point by jwk 5015 days ago | link | parent | on: Any Ideas Why I am Getting 502 Proxy Errors?

So what should I do?

I use your code on www.geek.vn than switch to hackerstreet.in code. It is mostly similar but /whoami only. Your ARC code tunrs to 127 :-), not real IP.

Hackerstreet code helps me solve that tiny issue and also adds an "ask" tab on the top bar. I wonder how to add another one such as "blog" (so click on with access geek.vn/blog or about/contact etc...:-( Any help @akkartik. I am just an actual non-geek/coder :-)


Ah, you're right. I never remember /whoami.

I just check http://afritech.org/whoami and it returns as vuong at 127.0.0.1

Do the same at arclanguage.org/whoami you will see the difference. I think we need some further dig :-)

2 points by jwk 5015 days ago | link | parent | on: Any Ideas Why I am Getting 502 Proxy Errors?

I just implemented the abusive ip fix. Hopefully this should fix it. Now that I recall, I did this the very first time I set up the server and it ran fine for a loooooooong time. So long that I forgot to take that step again!

That's running on just 128MB? That's awesome.

I use nginx as the reverse proxy for http://www.geek.vn/

It runs smoothly unless the are too many connections (seldom). The reason is that I use a very low-end VPS (RAM 128 MB) :-).

I think you can create a "news" subdomain within your domain control panel (I use Cloudflare instead), then point to the IP of the server. Just my thought only.

I hope it works with you.


I think you might be affected by gotcha #3 at https://sites.google.com/site/arclanguagewiki/arc-3_1/known-... because you're using arc behind apache. Try one of the workarounds and report back?

I like the way Mezzo deals with memory using "ideas from affine type systems, separation logic, and systems based on regions and capabilities," but my enthusiasm is capped for two reasons.

One of the reasons is the same as one of David Barbour's criticisms of typestate.[1] Why should I care about Mezzo's state handling if it only permits reasoning about state metaphors within the program, and not external resources that are inherently stateful?

Two, this blog post focuses on how Mezzo can express programs without particular classes of errors, rather than with particular conveniences or desirable properties. Eliminating failure doesn't imply that success is easier.

[1] http://awelonblue.wordpress.com/2011/09/26/trouble-with-type...


Reminds me of the recent paper advocating a keyword for isolated rather than const: http://arclanguage.org/item?id=17148
2 points by Pauan 5027 days ago | link | parent | on: URLs separated by U+2002 become one

I think you're right, but for future reference:

http://en.wikipedia.org/wiki/Percent_encoding#Types_of_URI_c...

http://en.wikipedia.org/wiki/URI_scheme#Examples

1 point by akkartik 5027 days ago | link | parent | on: Remove all duplicates from a list

I understood what you meant, rocketnia ^_^
1 point by akkartik 5027 days ago | link | parent | on: URLs separated by U+2002 become one

Hmm, it was always defined in arc.arc, so I think it's intended for more than urls. Besides, why would bang be part of URL syntax? And wouldn't it also need ampersand? The original version seemed to include the characters for regular english punctuation.

Update an hour later: but I see where you're coming from; punc is only used in one function -- urlend.

Update two hours later: I found one regression in urlend: https://github.com/nex3/arc/commit/671c5ec916. We also have unit tests for markdown now, so any further regressions need only be caught once more.

2 points by akkartik 5028 days ago | link | parent | on: Remove all duplicates from a list

I like this idea!

It's too bad this suggestion also uses an operator char, though. Or maybe there's some way to describe keyword args as a macro?!

3 points by rocketnia 5028 days ago | link | parent | on: Remove all duplicates from a list

"It's a little confusing at the start to use colons in two different ways so close to each other, but [...]"

I was just thinking that. What would you think about keyword args that started with a hyphen instead of a colon?

  (uniqify (sort (<) cdr.ls) -and car.ls -into list:car.ls)
This way they look like shell command options, and the whole thing looks like a call to "uniquify-X-and-Y-into". Just an idea. :)
3 points by Pauan 5028 days ago | link | parent | on: URLs separated by U+2002 become one

I wonder if it'll cause any problems... in particular, Arc's "punc" is obviously not trying to be comprehensive, so maybe it was designed specifically for URL syntax?
2 points by rocketnia 5028 days ago | link | parent | on: Remove all duplicates from a list

Well, I always indent it in one of two ways, depending on how much room I have:

  (if 1  2
      3  4
         5)
  
  (if 1
    2
      3
    4
    5)
This style may have drawbacks, but I stubbornly use it anyway. :-p

  (list:if 1   ; misaligned condition
    (do a b c
      (d e f))
      (is x 0)  ; looks like part of the previous expr
    4
    5)
EDIT: Changed "I like it most of the time anyway" to "I stubbornly use it anyway." XD Somebody upvoted me before my edit....
3 points by akkartik 5028 days ago | link | parent | on: URLs separated by U+2002 become one

Thanks! I just updated anarki to use char-whitespace? and friends.
3 points by Pauan 5028 days ago | link | parent | on: URLs separated by U+2002 become one

For reference, here are the whitespace characters as defined by Unicode:

http://en.wikipedia.org/wiki/Whitespace_character#Unicode

And here's some Arc stuff to match them:

  (mac unicode-range args
    `(list ,@(mappend (fn (x)
                        (if (acons x)
                            (accum a
                              (for i (coerce car.x 'int) (coerce cadr.x 'int)
                                (a:coerce i 'char)))
                            (list x)))
                      args)))

  (= unicode-whitespace (unicode-range (#\u0009 #\u000D) #\u0020 #\u0085 #\u00A0 #\u1680 #\u180E (#\u2000 #\u200A) (#\u2028 #\u2029) #\u202F #\u205F #\u3000))

  (def whitec (c)
    (some c unicode-whitespace))
Also, Racket has a "char-whitespace?" function which after very minor testing seems to do the same thing:

http://docs.racket-lang.org/reference/characters.html?q=whit...

2 points by Pauan 5028 days ago | link | parent | on: Remove all duplicates from a list

For Nulan, my current thought is that multi-case "if" is too confusing with indentation, so the above would be written like this:

  if 1
    2
    if 3
      4
      5
3 points by akkartik 5028 days ago | link | parent | on: URLs separated by U+2002 become one

Thanks for the bug report. It is certainly good to know about, but I don't think the HN folks come by here much, and any fixes we come up with might well never make it back. You might want to inform them separately at info@ycombinator.com.

It looks like whitec[1] and therefore urlend[2] is not unicode-aware. I suspect that's true of all arc's string functions. I'll try to investigate, but I'm pretty ignorant of unicode; any help fixing this would be most appreciated. (Edit 25 minutes later: it turns out this was super easy to fix using racket's underlying unicode support -- https://github.com/nex3/arc/commit/052b560a2b)

[1] http://files.arcfn.com/doc/string.html#whitec; https://github.com/nex3/arc/blob/ca2b70213a/arc.arc#L1130

[2] https://github.com/nex3/arc/blob/ca2b70213a/lib/app.arc#L513

3 points by akkartik 5028 days ago | link | parent | on: Remove all duplicates from a list

Pauan already did a great job explaining my use of else; nothing to add there. But I'll show off how it would look in wart:

  def (uniqify ls into|result and|x)
    "Returns ls without duplicates; order unspecified.
    Only works for lists of numbers."
    if (no ls)
         result
       (no result)
         (uniqify sort:cdr.ls :and car.ls :into list:car.ls)
       (car.ls = x)
         (uniqify cdr.ls :and x :into result)
       :else
         (uniqify cdr.ls :and car.ls :into (cons car.ls result))
0. I can choose to skip some of the outer parens if that looks cleaner.

1. The function name for the def goes inside the param list to mimic the call being defined.

2. The '|' operator binds multiple names to the same argument, so that I can refer to the second arg as either result or into, etc. Multiple names might seem like a bad idea, but they allow me to reorganize the later recursive calls to uniqify to look more clean and mnemonic. If you're familiar with python's keyword args, this is the same idea.

(Though maybe I'm getting too clever in this case; if I ever try to use the and operator inside this function I'm liable to confuse myself.)

3. All params are now optional, like in javascript.

4. '=' is for equality, never assignment. And it can be infix.

It's a little confusing at the start to use colons in two different ways so close to each other, but here's how it looks with wart's syntax highlighting for vim: http://i.imgur.com/S7ZROtD.png. Since symbols with a colon at the start always evaluate to themselves just like literal numbers or strings, I highlight them the same as literal numbers or strings.

---

Feel free to ask us more questions regardless of what language you decide to use[1] for your side project. If it isn't one of the above, maybe you can teach us something.

[1] Nu is strictly superior to arc 3.1 in every way.

[Update: there's a bug in the above code. In my original and here I forgot that the call to sort requires a second arg:

  (sort (<) cdr.ls)
We need parens around the '<' to keep wart from parsing it as an infix op.]
3 points by akkartik 5028 days ago | link | parent | on: Remove all duplicates from a list

  (if 1    ; if
        2  ; then
      3    ; if
        4  ; then
      5)   ; else
Yeah, it's problematic how to indent the "5". The above way makes it look like a test rather than an action, and indenting it further makes it seem like part of the same block as 4.

You can tell that there's no idiomatic way to deal with this because the arc/HN codebase is schizophrenic, using both in different places.

1 point by akkartik 5028 days ago | link | parent | on: Remove all duplicates from a list

(Eek, accidentally clicked down when I meant to vote up.)
5 points by Pauan 5028 days ago | link | parent | on: Remove all duplicates from a list

"As I see it, the dot (car.ls) is syntactic sugar for applying a one arg function? Pretty clever!"

Arc has the following ssyntax:

  foo.bar     -> (foo bar)
  foo!bar     -> (foo 'bar)
  
  (~foo 1)    -> (no (foo 1))
  (foo:bar 1) -> (foo (bar 1))
  (foo&bar 1) -> (and (foo 1) (bar 1))
To be honest, I only use the ".", "!", and ":" ssyntax. Also, "~", ":", and "&" work even when they're not in functional position:

  (map ~foo ...)
  (map foo:bar ...)
  (map foo&bar ...)
---

"Use of iso. Don't know why I used is.. Question I had, can '=' be use as a comparison operator?"

The only difference between "is" and "iso" is that "iso" recursively checks lists:

  (is  (list 1 2 3) (list 1 2 3))  ; nil
  (iso (list 1 2 3) (list 1 2 3))  ; t
"=" is always used for assignment, never for comparison. The only built-in equality function is "is", and "iso" is defined using "is".

---

"Also I get your use of 'else, but not exactly sure how it passes."

Like most Lisps, Arc has a datatype called "symbol", which is roughly equivalent to an "identifier" in other languages. Normally, if you use "else" it will refer to the variable "else", but if you use quote, it will be the symbol "else":

  else   ; variable
  'else  ; symbol
The rule for booleans in Arc is that the symbol "nil" is false, and everything else is true. The symbol "else" is not equal to the symbol "nil", therefore it is true.

The reason why akkartik used "else" is a personal style difference. It's idiomatic to just leave it off:

  (if 1    ; if
        2  ; then
      3    ; if
        4  ; then
      5)   ; else
---

"Now, if I understood well, there are two major forks, one you are working on, that would be wart, and anarki (mistaken already?)."

wart isn't a fork of Arc, it's a different language which has some similarities with Arc.

You can find a bunch of Arc info here:

https://sites.google.com/site/arclanguagewiki/

In particular, anarki is a true fork of Arc, which has diverged a lot, so don't expect much compatibility with existing Arc programs. But if you want all kinds of new features, I'd recommend it. I haven't used it myself though, so that's about all I can say about it.

Arc/Nu[1] is a fork of Arc I created, which should be mostly compatible with Arc 3.1, but cleans up the compiler and adds in a few new things. Naturally I recommend using this if you want something similar to Arc 3.1.

Then there's various other implementations of Arc, such as jarc and Rainbow, and an incomplete C implementation of Arc called Arcueid.

---

* [1]: https://github.com/Pauan/ar

2 points by Pauan 5028 days ago | link | parent | on: Remove all duplicates from a list

"perhaps I'm trying too hard to avoid the afn :) I've never liked that idiom, perhaps because it's so hard to indent well."

That's why Arc/Nu provides alet and awith...

  (alet foo 1
    (self (+ foo 1))

  (awith (foo 1)
    (self (+ foo 1))
...which are equivalent to this:

  ((afn (foo)
     (self (+ foo 1)))
   1)
2 points by Mikechaos 5028 days ago | link | parent | on: Remove all duplicates from a list

Very interesting! Indeed, I had though about optional args (and that is what I had done first) but didn't want sort called at each rec. I like how you fixed it. Sort might be a bit obfuscated.. But I don't find it really bothering. It's use is straightforward and self explained!

As I see it, the dot (car.ls) is syntactic sugar for applying a one arg function? Pretty clever! It replaces really well the y, no doubt.

The differences are subtle, but it definitely feels better, my personal alarm gets a bit of rest.

Use of iso. Don't know why I used is.. Question I had, can '=' be use as a comparison operator?

Also I get your use of 'else, but not exactly sure how it passes. Does it count as an expression evaluated to true, so then (unique_list...) gets to be it's true clause/case? Or is is simply not counted at all (making (unique_list...) the false clause of (iso car.ls x). Not sure if I'm making my self clear here, so I'll try and rephrase a bit. A -> 'else gets to be an other if expression (if 'else) wich always evaluated to true -> following expression is the true clause of it. (what I think is happening) B -> 'else isn't counted as a full s-expr (not sure it's the right way of saying this) and so it just goes along with following (unique_list...) -> Makes it the false clause of (iso car.ls x) and not interpreted as an other if. (Then, I don't understand why!)

Finally, and that's really a bonus I'm asking, but since I'm looking into making my next side-project (wich could be a long-term project) in Arc-based lisp, it could get me closer, I'll ask it anyway. As of what I know, since PG's fully involved in YC, and so arc's development is in a semi-dead state, I'd better be at least looking at forks of it. Now, if I understood well, there are two major forks, one you are working on, that would be wart, and anarki (mistaken already?).

Would there be any difference in wart's implementation of the same alorigthm (since it shows a bit more use-case than pg's algorithm), or then, what would be wart's more natural form?

Thanks for the time! It's already more than I could ask!

1 point by Mikechaos 5028 days ago | link | parent | on: Remove all duplicates from a list

Ah! No breaking bubble! I searched for it and couldn't get it (there is no complete doc about all pre built function in arc, out there, heh? You just gotta read the source on and on till you get them all, I guess (wich is, in definite, not a bad thing at all!)).

I actually wanted to re-write it using a hash but couldn't get right away the semantics and syntax they had. This is perfect, It'll get me to discover how they actually work.

Thanks for the tip! It'll render better :)

Though, for the sake of learning (I am, for sure, studying PG's version and learning from it), could anyone quickly comment my code cause and what bad practices I'm doing (I may be a newbie in Lisp, but I still feel when things aren't elegant!).

Thanks to all

More