Arc Forumnew | comments | leaders | submit | conanite's commentslogin
1 point by conanite 5889 days ago | link | parent | on: Starting up with Arc

Hey, I live in Paris ... are any of you nearby? Who wants to meet up in the real world?

-----

2 points by edeion 5888 days ago | link

In Paris too, and I'd be glad to meet some other lispers. Especially since I'm still in the early process of learning Lisp. But I guess we should find another way of dealing with IRL meetings than the forum...

-----

1 point by conanite 5888 days ago | link

to borrow an idiom, (prn "conan" #\@ "conandalton.net")

-----

1 point by palsecam 5888 days ago | link

Mine is in my profile.

-----


I was also happy to find rainbow doesn't have this issue either ... but I'm putting that down to luck :))

small world indeed

-----


Aha, I am enlightened, that explains why 'map doesn't complain.

It's still a mystery (to me) how ac manages to substitute unquote b because it's not a proper unquote. At some point, the x in

  (map (lambda (x) (ac-qq1 level x env)) x))
will be bound to the symbol 'unquote, so the compiler should never see (unquote b) ...

clearly, the only logical explanation is magic :)

-----

2 points by rntz 5891 days ago | link

The answer is that arc quasiquotation gets compiles down to scheme quasiquotation, and mzscheme's quasiquote handler understands (... unquote bar) to be equivalent to (... (unquote-splicing bar)). Since the arc compiler doesn't understand unquotes of this style, you'll only get the correct results when the expression unquoted is the same in arc and scheme - ie: it's either a literal, or it's a local variable. For example:

    ; this works because the local 'x in arc is compiled to 'x in scheme as well
    arc> (let x 0 `(a . ,x))
    (a . 0)
    ; this works because '+ in scheme adds numbers just as in arc
    arc> (let x 0 `(a . ,(+ x 1)))
    (a . 1)
    ; the following examples do not work
    arc> (let x '(b) `(a . ,(join x '(c))))
    Error: "reference to undefined identifier: join"
    arc> (let x '(b) `(a . ,(+ x '(c))))
    Error: "+: expects type <number> as 1st argument, given: (b . nil); other arguments were: (c)"
    arc> (= x '(b))
    (b)
    arc> `(a . ,x)
    Error: "reference to undefined identifier: x"
It's funny how a surface bug turns out to lead to something deeper in this way. I feel like Alice down the rabbit hole.

-----


I used slightly longer examples to show the difference when the list members were unquoted. I don't understand at all why it works, because as far as I can tell, the same code branch (that maps over the quasiquoted list) is invoked in both cases.

-----

1 point by conanite 5899 days ago | link | parent | on: New ppr function

Can you post an example?

-----

2 points by conanite 5899 days ago | link | parent | on: Afn with

don't forget the name parameter to w/rfn in w/afn

  (mac w/afn (withses . body)
    `(w/rfn self ,withses ,@body)

-----

1 point by absz 5899 days ago | link

Whoops, you're right. My bad.

-----

1 point by conanite 5904 days ago | link | parent | on: Arc vectors?

Scheme uses #n( ... ), where n is the size of the vector.

You can see it when you create a tagged object (tagged objects are represented by a scheme vector)

  arc> (annotate 'foo 'bar)
  #3(tagged foo bar)
  arc> do
  #3(tagged mac #<procedure: do>)
But you're right of course, it doesn't have to be implementation-dependent, there are lots of other options.

The big question is whether vectors are really fundamental or "just an optimisation". Hint: the use of built-in representations for numbers and strings are already considered an unfortunate compromise for the sake of performance :)

<goes away to find reference ...>

-----

1 point by tc-rucho 5904 days ago | link

Yeah, maybe they are just an optimization but they are definitely going to be present in production implementations and I think they should be standarized beforehand, and since they are already available in the underlying mzscheme, I think it shouldn't be too problematic to get vectors in Arc.

Again, I suggest {...} for vectors, since they stand out (so to avoid confusing them with lists) and because they remind of array oriented languages.

  ({a b c d} 2) => c  ;; This couldn't be better :D

-----

2 points by conanite 5904 days ago | link

I'm sure there will be heated debates about the trade-offs between the "hundred-year" aspect of arc and the need to deploy reasonably fast applications. Here are some quotes from http://www.paulgraham.com/hundred.html

"Having strings in a language seems to be a case of premature optimization."

"Logically, you don't need to have a separate notion of numbers, because you can represent them as lists: the integer n could be represented as a list of n elements. You can do math this way. It's just unbearably inefficient."

So arc already deviates from the ideal minimal language; it might well deviate some more, I don't know. In a perfect world, the underlying VM should be able to figure out the most efficient implementation for each particular list you want to represent, and we would never need to bother ourselves with such details.

For comparison, "primitive types" in java are a performance compromise that (a) seriously mess up the language, and (b) are less and less relevant with each iteration of Moore's law.

Notwithstanding any of the above, I have shamelessly used

  (mac fpush (thing place) ; a very primitive, naive, fast 'push
    `(assign ,place (cons ,thing ,place)))
because the standard 'push uses 'atomic-invoke internally which slows some things down intolerably. Hence ... heated debates.

-----

2 points by shader 5903 days ago | link

I always thought the universal symbols for arrays were [], and {} were for hash tables ;)

-----

1 point by conanite 5903 days ago | link

it's true that CatDancer's hash-table syntax uses {k1 v1 k2 v2} ... http://hacks.catdancer.ws/table-reader-writer.html ... but I'm sure it's hackable so you can use alternative delimiters :)

-----

2 points by shader 5903 days ago | link

The only problem with using standard array notation for arc is that [] are already tied up for anonymous functions.

However, I think that too much syntactic sugar like this will end up damaging arc. Partly due to aesthetic reasons, but mostly due to the fact that each user has a different view on aesthetics, and adding too much will just exacerbate the "everyone has their own version" problem.

-----

1 point by CatDancer 5899 days ago | link

hmm, come to think of it, I've never used my table literal syntax {...} myself in a program. I wrote it so that I could write out and read back tables, which I use all the time, but that would work just as well with some long syntax like (literal-table k1 v1 k2 v2 ...) which doesn't use up precious syntax characters like { or #{.

-----

1 point by tc-rucho 5903 days ago | link

How about #{...} for hash tables and {...} for vectors?

-----

2 points by conanite 5905 days ago | link | parent | on: Plot complex functions using arc/rainbow

If you're on ubuntu or similar,

  sudo apt-get install ant-optional
should fix the ant config issue. On a mac, I think ant-optional comes with the Developer Tools. I should add this to the readme, thanks for pointing it out.

what color theme are you using?

On the spiral app? "theme" is too dignified a term for my crude CSS :) ... I found white dots on a dark background were easier to look at, so I set up the rest of the page in a similar way - dark bg, bright text. Did I understand your question correctly?

-----

2 points by tc-rucho 5904 days ago | link

Yay, I've solved the ant problem emerging some stuff related to the ant package, thanks for pointing that out :D

I'm excited about having java libs available in arc, although it would be nice to have an obvious way to disable tests on startup (now that I know it's fully functional I would like to speed the initialization up).

About the color theme: I meant the color theme used in the arc code. I bet you took those colors from an editor. Anyway, it doesn't matter at all..

-----

1 point by conanite 5904 days ago | link

Oh, the syntax highlighting, yes, welder (arc editor that comes with rainbow) can htmlify arc code so that it's easy to paste into a blog or other web page; then it's just a matter of a little CSS to decide what colour you want for different kinds of tokens.

You can just comment out the (run-all-tests) line in rainbow-libs.arc, but you're right, it should be optional somehow.

Let me know how you get on with accessing java libs, I've tried to make it as simple and concise as possible, so that your code still looks like arc code and not some outrageous contaminated half-blood hybrid monstrosity ...

-----

2 points by conanite 5913 days ago | link | parent | on: Anyone get Arc running on mzscheme 4.x?

The SheevaPlug supports java, might rainbow work for you?

-----


I don't see how to inject request-scoped variables - it seems you can only call functions in the global namespace. In other words, how would you render

  <span>hello, @(current-user)</span>
for multiple concurrent users?

A separate, and totally subjective, observation: one advantage of having prs all over the place is that output gets sent directly to the client, rather than getting buffered on the server (caveat: depending on how the stream is implemented I suppose). Writing to a string and then printing that string might be more resource-intensive; only an issue for high-volume sites though. The big win I've had with prs all over the place is that when something goes wrong (and arc isn't always very helpful when something goes wrong), you can "view source" in your browser and see where output stopped, and then hopefully make a guess as to where the error is in your code.

-----

1 point by coconutrandom 5908 days ago | link

True and true, current-user would have to be passed to a function to do something with it.

Interesting about buffering the output. Lots to learn still.

-----

More