Arc Forumnew | comments | leaders | submitlogin
2 points by lark 4954 days ago | link | parent | on: New version of Arc/Nu

Does Arc/Nu support file uploads?
3 points by rocketnia 4954 days ago | link | parent | on: What is the arity of [uniq]?

Oh, whoops. I forgot 'pushnew actually does traverse the input list to find out whether the element is new. I was thinking of 'push. XD

I disagree with the notion of membership you're using for dotted lists. If I 'pushnew nil onto (1 2 3 . nil), I want to get (nil 1 2 3 . nil), and it won't work that way if nil is already considered to be a member.

1 point by akkartik 4954 days ago | link | parent | on: What is the arity of [uniq]?

"What other list operations do you have in mind?"

Well, I've already changed reclist and some so things like this work:

  > (find 3 3)
  3
  > (find 3 '(2 . 3))
  3
  > (find 4 '(2 . 3))
  nil
More: https://github.com/nex3/arc/blob/76d078bcd0/arc.arc.t. I expect I've still missed some cases, and I'll keep tweaking them as I run into them until someone objects.
2 points by rocketnia 4954 days ago | link | parent | on: What is the arity of [uniq]?

"What do people think of this? Basically I want all list operations to treat atoms as degenerate dotted lists. Does this have any adverse implications for other aggregates (tables)?"

I don't see a problem, but I may not be the right person to ask. If it came down to it, I'd be willing to use 'table-pushnew, 'alist-pushnew, 'maxheap-pushnew, and so on. :-p

What other list operations do you have in mind? While 'pushnew makes sense to use with degenerate dotted lists, it's a very special case: It only clobbers the list at a finite depth, and that depth is actually zero. (Or zero in the unmodified list, anyway.)

2 points by akkartik 4954 days ago | link | parent | on: What is the arity of [uniq]?

Done: https://github.com/nex3/arc/commit/80571a42a6.

After some readability-golfing:

  (mac make-br-fn (body)
    (let args (rem '__ (dedup:sort > -mbf-argsyms.body))
      (if args
        (= (cdr lastcons.args) '__)
        (= args '__))
      `(fn ,args ,body)))
(https://github.com/nex3/arc/commit/a8a4008fed)

And after still more readability-golfing:

  (mac make-br-fn (body)
    (let args '__
      (each arg (dedup:sort > -mbf-argsyms.body)
        (pushnew arg args))
      `(fn ,args ,body)))akkartik/wart
(https://github.com/nex3/arc/blob/d03eed03f5/lib/make-br-fn.a...)

In the process, though, I've made some more backwards-incompatible changes. pushnew now behaves like push on non-lists or dotted lists.

  > (= x 3)
  > (push 2 3)
  (2 . 3)

  > (= x 3)
  > (pushnew 3 x)
  3
  > (pushnew 2 x)
  (2 . 3)
What do people think of this? Basically I want all list operations to treat atoms as degenerate dotted lists. Does this have any adverse implications for other aggregates (tables)?

All my changes, if you're curious: https://github.com/nex3/arc/compare/a8a4008fed...d03eed03f5

Update: As I expected, taking out the round-trip to table in the first version above saves us some consing. All the changes to get to the second version don't seem to result in any extra consing over the first.

  $ git checkout 80571a42a6
  $ racket -f as.scm
  arc> (load "cons.arc")  ; fallintothis's http://arclanguage.org/item?id=11122
  arc> ([+ _1 _2] 2 3)
  5
  arc> cons-count*
  20

  $ git checkout a8a4008fed
  $ racket -f as.scm
  arc> (load "cons.arc")
  arc> ([+ _1 _2] 2 3)
  5
  arc> cons-count*
  16

  $ git checkout d03eed03f5
  $ racket -f as.scm
  arc> (load "cons.arc")
  arc> ([+ _1 _2] 2 3)
  5
  arc> cons-count*
  16
2 points by cassano 4955 days ago | link | parent | on: Install hackernews Problem

Tks a lot ! it's ok thk U very much ! Welcome to Beijing ! but the air is not good
1 point by Pauan 4955 days ago | link | parent | on: Install hackernews Problem

Try this:

  mkdir arc
  echo "yourname" > arc/admins
You shouldn't be running Arc as root. Using sudo means you're running as root, so leave off the sudo.
1 point by cassano 4955 days ago | link | parent | on: Install hackernews Problem

Did not have the file arc/admins No such file or directory

I am a tiro for linux and my english is also bad I am chinese:)

1 point by Pauan 4955 days ago | link | parent | on: Install hackernews Problem

Please post the file permissions for arc/admins:

  ls -l -d arc/admins
1 point by cassano 4955 days ago | link | parent | on: Install hackernews Problem

sometimes no probelem but now have this problem

help:(

1 point by marcvs 4955 days ago | link | parent | on: Google Analytics inside news?

hey, it works! thank you.
2 points by dido 4955 days ago | link | parent | on: What is the arity of [uniq]?

Well, that would be helpful. After all the [...] syntax is meant to be a short-cut.
2 points by Pauan 4955 days ago | link | parent | on: New version of Arc/Nu

After some thought, I decided to stop half-assing it. What I've been trying to do is make a new implementation of Arc that is backwards compatible with Arc 3.1 but adds new features and fixes bugs.

The problem is that eventually I'll run into features I want to add, or bugs I want to fix, and I won't be able to do that without breaking compat with Arc 3.1.

This is very restricting, and part of Arc is about unbridled freedom. I thought about going the pg route and just saying "screw compat!" but if I did that I'd just end up with Nulan, so what's the point?

So instead, here's what I'm gonna do. There will be two separate languages implemented by the Arc/Nu compiler: Arc/Nu and Arc/3.1.

Arc/3.1 is the Arc you know and love. Unhygienic macros, dynamically scoped globals, and most of the warts and bugs and missing features.

Arc/Nu is a language similar to Arc, but with new features, bug fixes, and general cleanup. It has hyper-static scope and hygienic macros. It doesn't try to maintain backwards compat with Arc 3.1.

Now, you might be wondering, what's the point? I mean, we already have vanilla Arc 3.1 as implemented by pg, so why should Arc/Nu support Arc 3.1 at all?

The twist is that thanks to the magical power of booooxes, I can have Arc/3.1 and Arc/Nu running in the same namespace. This means Arc/3.1 can import Arc/Nu stuff, and Arc/Nu can import Arc/3.1 stuff.

And it all works correctly, so that if you define an unhygienic macro in Arc/3.1 and import it into Arc/Nu, it will behave unhygienically. And vice versa, if you define a hygienic macro in Arc/Nu and import it into Arc/3.1, it will behave hygienically.

And you can do things like import an Arc/3.1 library and mutate its stuff, or do the same to an Arc/Nu library. There's no restrictions between the two, because it all runs in a single namespace.

This means you can write new code with all the shiny features, yet still use old Arc/3.1 libraries. And if you just plain like using Arc/3.1 but there's some Arc/Nu library you want to use? You can.

And if pg ever releases Arc 4, I can just add it as a third language, which will let it interact with both Arc/Nu and Arc/3.1. This is all very very easy to do thanks to boxes.

2 points by Pauan 4956 days ago | link | parent | on: New version of Arc/Nu

By the way, if you want to write macros that work correctly in both Arc 3.1 and Arc/Nu, here's how.

Non-anaphoric macros should Just Work(tm).

Anaphoric macros (aif, awhen, etc.) need to be tweaked a bit. First, let's look at the definition in Arc 3.1:

  (mac awhen (expr . body)
    `(let it ,expr (if it (do ,@body))))
Now, there's two ways to make this work in Arc/Nu. First, you can unquote+quote:

  (mac awhen (expr . body)
    `(let ,'it ,expr (if ,'it (do ,@body))))
Secondly, you can use "w/sym":

  (mac awhen (expr . body)
    (w/sym it
      `(let it ,expr (if it (do ,@body)))))
I personally recommend "w/sym", since you can just slap it onto the front and be done, but it's up to you.

And that's it. Now your macros work in both unhygienic Arc 3.1 and hygienic Arc/Nu.

2 points by Pauan 4956 days ago | link | parent | on: New version of Arc/Nu

https://github.com/Pauan/ar/commit/d3971088cdf3160124d9affa7...

Arc/Nu now uses hyper-static scope and hygienic macros by default. This means I had to change "02 arc" in the following ways:

* Rearranged things so that they are always defined before they are used.

* Fixed some code duplication (e.g. alist now uses acons).

* Fixed some places where macros were supposed to use gensyms but didn't.

* Fixed unhygienic macros (like aif) so they work in the new hygienic macro system.

* The various defining macros (def, mac, etc.) all use "var" now rather than "assign".

* The "defs" macro has been changed a bit and now has an actual use.

* Added in a few new macros, like redef, remac, w/sym.

For the most part, though, I tried to change it as little as possible.

Thanks to this, I also found a few typos in the Arc/Nu libraries.

By the way, I made sure to change it in such a way that it works correctly whether hyper-static/hygienic-macros is turned on or off.

And of course, the Arc/Nu compiler can still load Arc 3.1's "arc.arc" unmodified, if you want to do that.

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

The reason it does that is so that things like [+ _ 1] work. Under your suggestion, you would have to write [(+ _ 1)] which looks ugly.

Rather than using [(prn ...)] you can just use [prn ...]

---

Incidentally, using Arc/Nu, it's easy to make the square brackets behave the way you want them to:

  (mac square-brackets args
    `(fn (_) (do ,@args)))
I believe Anarki has something similar as well.
1 point by lark 4956 days ago | link | parent | on: How do you http redirect in Arc?

Thanks. I understand one should write:

  [do (prn "...")]
I support one shouldn't. The do should be implicit.
3 points by Pauan 4956 days ago | link | parent | on: New version of Arc/Nu

New version:

https://github.com/Pauan/ar/commit/30aa79bbd1082bf182e07d86f...

Now files only export the boxes they create. Which means...

  ; foo
  (def foo ())

  ; bar
  (import foo)
  (def bar ())

  ; qux
  (import bar)
  (prn bar) ; works
  (prn foo) ; error
Basically, "qux" imported "bar" which imported "foo", but "bar" only exported the boxes it defined, thus it didn't export "foo".

This is not only cleaner (and faster), but it opens up the possibility of having two separate Arc versions operating side by side, in the same namespace, able to communicate with each other.

That's important because I really want to have Arc/Nu use hygienic macros and hyper-static scope by default, but that would break Arc 3.1 compatibility. But now I can have Arc/Nu and Arc 3.1 operating at the same time. This was possible before, but was very difficult. Now it's easy.

2 points by akkartik 4956 days ago | link | parent | on: What is the arity of [uniq]?

How do you feel about tossing out arity checking altogether in this instance? I could just add a rest arg so extra args never throw errors.
3 points by rocketnia 4956 days ago | link | parent | on: What is the arity of [uniq]?

"Frankly, I think that bracket functions should always have at least one argument permitted."

Groovy does this. The Closure syntax { ... } is shorthand for { it = null -> ... }, which is a one-argument Closure whose argument "it" defaults to null. When I moved from Groovy to Arc, I missed this.

3 points by rocketnia 4956 days ago | link | parent | on: What is the arity of [uniq]?

"Well, how did the change not break setforms in arc.arc? Was the original definition for make-br-fn silently overwritten somewhere?"

Yes. The [...] syntax is redefined in make-br-fn.arc after arc.arc is loaded.

I described my opinion of this at https://github.com/nex3/arc/commit/957501d81bafecab070268418.... It did break my code, but I don't mind breaking changes these days (maybe because I'm hardly a user!), and I think a:b syntax is already more useful than either version of [...].

2 points by dido 4956 days ago | link | parent | on: What is the arity of [uniq]?

Well, how did the change not break setforms in arc.arc? Was the original definition for make-br-fn silently overwritten somewhere? Last I checked there is still a (let argsyms (map [uniq](cdr expr) ...) inside of the definition of setforms in arc.arc even in the latest versions of Anarki. This will not work with the change to bracket functions that has been made.

Frankly, I think that bracket functions should always have at least one argument permitted.

2 points by akkartik 4956 days ago | link | parent | on: What is the arity of [uniq]?

Yes, I remember this aspect was quite subtle when I last poked at it a year ago, until rocketnia set me straight:

https://github.com/nex3/arc/commit/f311b3879c15a27518bbe0fad...

1. Arc 3.1 uses a kludgy uniq that doesn't actually guarantee unique symbols. I hooked it up with racket's infrastructure at some point, which happens to permit an optional arg.

  $ racket
  > (gensym)
  'g25
  > (gensym 'tmp)
  'tmp26
2. Also, anarki generalizes arc 3.1 by permitting any number of args to [], including zero:

  anarki> ([prn "abc" _1 _2] 34 35)
  "abc3435"
This is indeed incompatible with arc 3.1 in one way:

  arc3.1> ([prn "abc"] 34)  # Must provide one arg, but ok to not use it.
  "abc"
  anarki> ([prn "abc"] 34)  # Must provide exactly as many args as expected.
  Error: .. arity mismatch ..
Is this bad?
1 point by akkartik 4956 days ago | link | parent | on: Install hackernews Problem

Send me your id (my email is in my profile).
1 point by cassano 4957 days ago | link | parent | on: Install hackernews Problem

gtalk?
3 points by Pauan 4957 days ago | link | parent | on: Install hackernews Problem

Looks like you installed Arc as root, and then tried to use it when not as root. I would suggest installing and running it as a normal user.
1 point by cassano 4957 days ago | link | parent | on: Install hackernews Problem

please help me ths
3 points by rocketnia 4957 days ago | link | parent | on: How do you http redirect in Arc?

The examples at arcfn say [do (prn ...) ...] and [w/link (pr ...) ...]. At some point you changed one of these to [ (prn ...)] for your example.
1 point by lark 4957 days ago | link | parent | on: How do you http redirect in Arc?

I see the following:

  arc> ([(prn "You entered " _)] 34)
  You entered 34
  Error: "car: expects argument of type <pair>; given ()"
That's good investigation. Note the work described in this thread uses Arc 3.1, not Anarki.

Btw do you mean there's something wrong with defop, or that the example I wrote is incorrect? I had gotten that example from: http://arcfn.com/doc/srv.html

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

I just ran the following at the repl:

  arc> ([(prn "You entered " _)] 34)
  You entered 34
  Error: "...urces/arc/ac.scm:974:33: arity mismatch;\n the expected number of arguments does not match the given number\n  expected: 1\n  given: 0"
Do you see something different? I think your defop expression is also incorrect. It just happens to have the right side-effect before it runs into the error. You probably have errors at the server -- that aren't visible on the browser.

Edit: I kept having this feeling I'd already pointed this out to you -- and I just found it :) http://arclanguage.org/item?id=16356

More