Arc Forumnew | comments | leaders | submit | conanite's commentslogin
2 points by conanite 372 days ago | link | parent | on: Running Java in Arc

Rainbow has an implementation of tetris and a text editor, both are full of examples of using swing. What specifically do you want to do?

-----

4 points by conanite 437 days ago | link | parent | on: Onions in the varnish

I agree, the vertical-bar symbol-syntax is a very smelly onion. And as far as I could tell the last time I checked, the only place arc really depends on it is in webserver code, to define a handler for the application root uri ( "/" ) - this path is defined by the empty symbol, which is represented as ||

You could get away with totally ignoring vertical-bar symbol-syntax, and add this somewhere before you define your webapp:

  (assign || (sym ""))
Hindsight is great. I wish I had thought of this before writing all those vertical-bar tests :)

-----

3 points by akkartik 437 days ago | link

Alternatively, we could make handler names start with the leading '/', so you say "defop /" instead of "defop ||".

Do people consider srv.arc to be 'part of arc' for compatibility purposes?

---

Or we could define the root handler using "defop nil".

  wart> (sym "")
  nil

-----

2 points by Pauan 436 days ago | link

"Do people consider srv.arc to be 'part of arc' for compatibility purposes?"

I would consider any Arc program to be "part of Arc" for compatibility purposes because any Arc program is supposed to use only the core and things defined in arc.arc (along with its own libraries, of course).

Obviously all bets are off if it uses the $ macro to drop into Racket, but then you're not really writing Arc code anymore, so I'm ignoring that case.

---

"(assign || (sym ""))"

That's a pretty good way of solving that one particular use-case, but it won't help in general because there might be some Arc program that actually does use the |...| notation more extensively.

However, I suspect such programs are quite rare, and with good reason. So I don't think it's a major deal if an Arc implementation chooses to not implement the |...| notation. However, such incompatibilities should be documented, so people using your implementation know what works and what doesn't (and why it doesn't work).

And in that case, it would probably also be a good idea to have your implementation throw an error if a program ever uses the |...| notation. That makes it easy to figure out which programs are broken, and makes it easy to pinpoint where the problem is so it can be easily fixed, rather than failing silently or at a later step in execution.

-----

1 point by akkartik 436 days ago | link

"I would consider any Arc program to be "part of Arc" for compatibility purposes.."

I don't understand. If I write a hello world arc program, are you saying that's part of arc?

"..because any Arc program is supposed to use only the core and things defined in arc.arc."

I'm not sure what this means either. I think my question boils down to, "what do you consider to be the core of arc?"

-----

1 point by Pauan 436 days ago | link

"I don't understand. If I write a hello world arc program, are you saying that's part of arc?"

For the sake of compatibility with Arc, yes. An implementation claiming compatibility with Arc should be capable of running programs designed for Arc 3.1.

---

"what do you consider to be the core of arc?"

We were discussing what constitutes "part of Arc" for compatibility purposes. "srv.arc" is not a part of the core of Arc, nor are any libraries written in Arc. But it is still "part of Arc" for the sake of compatibility, in the sense that a compatible implementation of Arc must be capable of running them, warts and all.

Unfortunately, that means that certain programs may end up relying on things inherited from Racket, such as the |...| syntax. I think it must be decided on a case-by-case basis whether compatibility with Arc 3.1 is worth it or not. In the particular case of |...| I don't think it's worth it. But I'm not the one implementing Arcueid: that's up to dido to decide.

-----

1 point by thaddeus 436 days ago | link

That's my vote -> (defop nil ...)

-----

1 point by dido 435 days ago | link

Strangely enough, Arcueid manages to run the web server code just fine while being unable to handle the vertical bar symbol syntax. shrugs

-----

1 point by akkartik 435 days ago | link

I just tried it, and the '/' url isn't recognized. It's just not throwing an error on '||'.

-----

4 points by conanite 451 days ago | link | parent | on: Unit testing Arc

Implementation-neutral arc tests from rainbow are here:

https://github.com/conanite/rainbow/tree/master/src/arc/lib/...

It's safe to use these as a specification.If you fire up an arc3 repl within the rainbow src directory you can run the same tests to verify you get the same behaviour.

Rainbow-specific tests are in another directory.

-----

2 points by dido 450 days ago | link

Hmm, core-evaluation-test.arc seems to hang Anarki, as well as Arc 3.1.

Well, I've tried to run the tests that do work fine with 3.1 and Anarki under Arcueid and find a lot of issues. For starters, I had no idea that Arc treats symbols with |'s specially. Looks like more accidental behavior inherited from MzScheme/Racket. Scheme48 says that '|abc| contains illegal characters. Guile creates a symbol |abc|. I don't see anything in R^6RS that mandates any of this behavior. Heh, looks like I've got a lot of work to do!

Apparently the bars in symbols is a sort of convention when it comes to case sensitivity of symbols in Scheme. It seems that Arc, in its current implementation anyway, is unintentionally inheriting a lot of onions from MzScheme...

-----

1 point by conanite 925 days ago | link | parent | on: Arc Conference

an arc conference would be très cool

1. Anywhere; Europe is more convenient

2. What should the core language be; macro design; libraries; implementations and interopability

3. I hope I can think of something to say about rainbow

4. no

5. as projectileboy mentions, we would need to find a conference space large enough to fit ... a dozen people?

-----


  arc> (tuples (range 0 19) 3)
  ((0 1 2) (3 4 5) (6 7 8) (9 10 11) (12 13 14) (15 16 17) (18 19))
tuples is defined in arc.arc:

  (def tuples (xs (o n 2))
    (if (no xs)
        nil
        (cons (firstn n xs)
              (tuples (nthcdr n xs) n))))

-----

1 point by hasenj 935 days ago | link

Thanks!

Interestingly, it's smaller than 'pair' even though it does more.

-----

3 points by akkartik 935 days ago | link

I first encountered this idea in a theorem-proving class - that if you have a hard time proving a theorem, often a really good approach is to find a more general 'lemma' to try to prove. Stronger theorems are often easier because they let you assume more in the induction step. Recursion has a similar 1-1 correspondence with inductive proofs.

http://www.cs.utexas.edu/users/moore/classes/cs389r/index.ht...

-----

1 point by hasenj 935 days ago | link

Actually I just realized, 'tuple' uses 'firstn' and 'nthcdr', where as 'pair' sort of inlines these concept and has to deal with nils.

-----

3 points by conanite 947 days ago | link | parent | on: A better syntax for optional args

Two problems with (o arg default) - you need to remember not to use 'o at the start of a destructuring list (and not get confused when you see (def handle-request ((i o ip)) ...) ), and as akkartik says it's paren-inefficient, a single keyword to delimit required/optional args would mean fewer tokens.

The first problem is easy to fix though - use a symbol that's less likely to be an arg name to identify optional args. How about '= ?

  (def myfun (a b (= c (something)) ...)
it has the advantage of similarity with ruby:

  def myfun a, b, c=something
disadvantage: looks silly when you don't supply a default value:

  (def myfun (a b (= c) ...)

-----

4 points by conanite 947 days ago | link | parent | on: A better syntax for optional args

(a) might look funny when you want to evaluate an expression for the default value of an optional arg

  (def foo (a b '(c (defaults 'c x y z)) ...
To the untrained eye, (defaults 'c x y z) looks like it should not be evaluated because it's quoted

(c) makes parsing harder ... the assumption of only one element after the dot may be built into the parser

  arc> '(a b c . d e)
  Error: "UNKNOWN::8: read: illegal use of `.'"
It could be some privileged symbol instead of "." though ...

-----

1 point by akkartik 947 days ago | link

Great points. I realized c was breaking the metaphor of '.'; I didn't realize it would actually refuse to parse.

It doesn't make sense to quote forms that may have expressions to evaluate, so b is better than a.

-----

2 points by conanite 956 days ago | link | parent | on: More Jarc and Rainbow bugs

Quick note on destructuring behaviour: arc3 doesn't verify parameter counts in destructuring arg lists.

You can see this in the wild in 'parseurl in srv.arc:

  (let (type url) (tokens s) ...)
(tokens s) returns a 3-element list (it's tokenising "GET /foo HTTP/1.1").

Here are two examples destructuring a 3-element list into a 2-element arg, and into a 4-element arg:

  arc> (let (x y) '(a b c) y)
  b ; no error
  arc> (let (x y z nothing) '(a b c) nothing)
  nil ; no error

-----


fixed

-----


(stdin) and (string '("")) are fixed now in rainbow, as well as 'writec returning nil. Other bugs ... are noted ...

What is the issue with [] in rainbow? This works:

  arc> ([* _ 2] 3)
  6
Do you have an example?

I added macex1 as an arc fn (it's a builtin in arc3) -

  (def macex1 (expr)
    (let macro car.expr
      (if (and (isa macro 'sym)
               (bound macro)
               (isa (eval macro) 'mac))
        (let mac-impl (rep:eval macro)
          (apply mac-impl cdr.expr))
        expr)))

-----

2 points by rocketnia 957 days ago | link

What is the issue with [] in rainbow? ... Do you have an example?

I think you'll find it's a very simple example. :-p

  arc> []
  rainbow.parser.ParseException: Encountered "]" at line 1, column 2.
As for 'macex1, there's definitely one inconsistency, which is that it doesn't work unless car.expr works. I also briefly worried about ssyntax, but I'm not sure it's a problem; official Arc lets (assign a.b nil) cause (bound 'a.b) to be true, but I don't blame Rainbow for not emulating that.

-----

1 point by conanite 956 days ago | link

aha ... fixed []. Changed a "+" to a "*" to allow empty bodies ...

-----

More