Arc Forumnew | comments | leaders | submit | CatDancer's commentslogin

Normally Arc will flush all output for you. Thus if you say

  arc> (do (repeat 5
             (pr ".")
             (sleep 1))
           (prn))
you will see a dot being printed every second.

However, it can be inefficient to writing every little string constantly. If you'd prefer to call flush yourself, you can say:

  arc> (declare 'explicit-flush #t)
now Arc won't call flush for you. If you run the above example again, you won't see one dot per second; instead you'll see nothing for five seconds and then all the dots will be printed at once.

Since noisy-each might be called with explicit-flush on, it calls flush to ensure that the dots are printed as it runs. This does no harm when explicit-flush is off.

-----

1 point by thaddeus 5883 days ago | link

I see. Thanks! T.

-----

2 points by CatDancer 5883 days ago | link | parent | on: Port of Arc to PLT 4 (but it's slow)

Do you have any benchmarks you use with rainbow? It'd be interesting to compare plt3 with the rainbow and plt4 ports and see how they all compare...

-----

1 point by conanite 5880 days ago | link

I've been working a bit on rainbow optimisation lately, mostly to get welder up to an approximately usable speed. The bottleneck in welder is tokenising arc source code, so the tokeniser in parser.arc has been the target of my benchmarks.

On my mac, arc3 performs about 3 times faster than rainbow, which itself is now performing 5 times faster that it was a few weeks ago.

I used to use a prime-number generator to compare ... curiously rainbow performs slightly better for small numbers (find all primes under 10000, 413ms vs 465), but worse for large numbers (find all primes under 100000, 8.4s vs 7.4s). This particular generator uses continuations; there are probably other ways of writing it to exploit weaknesses in either java or scheme to get different results.

-----


This might be the time to fork off a new MzScheme, if anyone is up for that.

Are there any bugs or deficiencies in MzScheme 372 that we'd like to fix if we keep using it?

-----

1 point by rocketnia 5883 days ago | link

Wouldn't it be simpler just to fork from 4.2? Making immutable pairs not-really-immutable shouldn't actually break any existing PLT-based code, since that code won't modify them. ^_-

It might break some low-level optimizations in PLT Scheme itself (which could be fixed in the forked version), it might break compatibility with other projects that dig into the PLT code, and it might annoy some library writers who really didn't want careless users to shoot themselves in the feet or expose security holes, but that's all the trouble I can think of offhand.

-----

1 point by CatDancer 5883 days ago | link

Simpler in what way?

Breaking the PLT Scheme optimizer by mutating pairs it thinks are going to be immutable and then going in and figuring out which optimizations to fix doesn't sound very simple to me... but, assuming that it was easy to do, what does starting from 4.2 do for us?

-----

1 point by rocketnia 5883 days ago | link

I guess I just see "Take the newest MzScheme and implement not-so-immutable conses again" as a conceptually easier task than "Take the fork and implement feature A and feature B as inspired by the newest MzScheme." Of course, the more objections we have to MzScheme changes, and the more features of our own we want to include, the harder this becomes.

-----

2 points by elibarzilay 5883 days ago | link

There are a lot of new features, as well as more and better optimizations in v4.2.

-----

2 points by CatDancer 5884 days ago | link | parent | on: Afn with

Very nice! For example, my "many" parser combinator uses 'afn:

  (def many (parser)
    (fn (p)
      ((afn (p a)
         (iflet (s2 r) (parser p)
           (self s2 (cons r a))
           (return p rev.a)))
       p nil)))
using 'afnwith:

  (def many (parser)
    (fn (p)
      (afnwith (p p a nil)
        (iflet (s2 r) (parser p)
          (self s2 (cons r a))
          (return p rev.a)))))
I like having a form in which I don't have to use the double parentheses.

-----

1 point by CatDancer 5884 days ago | link | parent | on: Port of Arc to PLT 4 (but it's slow)

Try it for yourself... you really need to be running timing tests against code that you want to run, since different code may end up being faster or slower.

-----


New patch available: http://hacks.catdancer.ws/plt4-port.4.patch

This update gets ac.scm back into being a module, so to run Arc using this patch go back to using "mzscheme" as the command to run:

  ~/plt-4.1.5/bin/mzscheme -f as.scm
but no "-m", as that option has changed in plt4.

Getting ac.scm back into a module makes this version almost twice as fast as the last version of the patch. Unfortunately that's still not very good: it's taking 3.5 times as long to get to the Arc REPL prompt with this patch using plt4 as it does with the unmodified Arc using plt3.

-----


There are some amusing moments that happen when I work on the porting project... here's the Arc compiler, running as normal in plt3:

  > (ac '(fn () 3) '())
  (lambda () 3)
and the Arc compiler running in a module where I forgot to import unquote and unquote-splicing:

  > (ac '(fn () 3) '())
  (lambda ,(let ((a (ac-denil args))) (if (eqv? a 'nil) '() a))
    ,@(ac-body* body (append (ac-arglist args) env)))
The fix (import unquote and unquote-splicing) was both obvious and simple once I figured it out, but in the meantime I was quite bemused: how did I manage to do that?! :-)

-----

1 point by CatDancer 5887 days ago | link | parent | on: Ask Arc: inst or filltbl?

Have you tried listtab?

-----

1 point by thaddeus 5887 days ago | link

I think adm wants to create a named table. Correct me if I am wrong adm.

otherwise rntz's function, in the post, already returns a table:

  (def filltbl (tbl keys vals)
      (or= tbl (table))
      (map (fn (k v) (= tbl.k v)) keys vals)
      tbl)

-----

2 points by rntz 5887 days ago | link

Actually, there is already a function 'fill-table - I don't know how I missed it - that does most of what's wanted.

    (def filltbl (tbl keys vals)
      (fill-table (or tbl (table)) (mappend list keys vals))))
However, I honestly don't think this is a useful or general enough function to go in arc.arc, especially as we already have 'fill-table, 'listtab, etc.

As for "creating a named table", er:

    (= foo (table)) ; I'm unclear on what's difficult about creating a table.

-----

1 point by thaddeus 5887 days ago | link

I think the difficult part is passing in an arbitrary name to a function, for which the tables 'name' becomes set to, but I am just guessing that's what he wants...

and I agree I don't see a whole lot of need for the function to be part of the arc release..., since there are probably better ways to accomplish the same end result.... a good example of which is news.arc's storage of story records.

-----

1 point by fallintothis 5887 days ago | link

I think the difficult part is passing in an arbitrary name to a function, for which the tables 'name' becomes set to, but I am just guessing that's what he wants...

I rather doubt that's the issue, as it's easy to do with a macro.

  arc> (mac filltbl (tbl keys vals)
         `(= ,tbl (fill-table (table) (mappend list ,keys ,vals))))
  #3(tagged mac #<procedure: filltbl>)
  arc> (filltbl blah '(a b c) '(1 2 3))
  #hash((c . 3) (a . 1) (b . 2))
  arc> blah
  #hash((c . 3) (a . 1) (b . 2))

I think it's just a request for a convenience function to zip together a list of keys with a list of values into a table, since the existing methods for creating tables center around having alternating key/value pairs.

-----

1 point by thaddeus 5887 days ago | link

Agreed, it was only a wild guess given he was already given a good solution, yet...

   "Am I missing anything here?"
So I don't know what the deal is, but I don't plan to spend any time thinking about it :)

-----

1 point by adm 5876 days ago | link

only difficulty was creating a list of pairs which can be used an an arg for fill-table or listtab.

  (mappend list keys vals)
is precisely what I wanted. Sorry for the caused confusion.

-----


Right now getting to the "arc>" prompt is 6.2 times slower, but that could be from not loading the Arc compiler as a module yet or from using the r5rs library.

-----

1 point by CatDancer 5893 days ago | link | parent | on: Why is 'copylist necessary?

Ah yes, that's a simpler way to get an observable difference ^_^

-----

1 point by conanite 5893 days ago | link

What's the difference between nil and () ?

They both appear to have the same behaviour for car and cdr (return nil), and for scar and scdr (not allowed), and on top of that

  arc> (is () nil)
  t
Couldn't we drop one of these?

-----

1 point by CatDancer 5893 days ago | link

What's the difference between nil and ()

Arc lists are terminated by 'nil, Scheme lists by '(). Because Scheme lists sometimes appear in Arc, the Arc runtime (such as 'is) treats '() like 'nil.

Couldn't we drop one of these?

http://hacks.catdancer.ws/nil-impl-by-null.html ^_^

-----

1 point by conanite 5893 days ago | link

sounds like an onion to me :)

-----

More