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

1) It's hard to guess what you're trying to do, maybe you could do (let * foo (dumb 3)) : 'foo seems strange

for example : (let * + (dumb 3)) ==> 6 (let * '+ (dumb 3)) ==> error

In this example, + is a function and can thus be applied, but '+ is a symbol and cannot.

-----

3 points by sacado 6497 days ago | link | parent | on: Possible bug in using + for lists

nil is not equivalent to () but to '() : if you type (+ '(a b c) '()) everything is ok.

-----

5 points by dido 6497 days ago | link

arc> (iso nil ())

t

arc> (iso nil '())

t

arc> (iso () '())

t

How are they not supposed to be equivalent?

-----

4 points by sacado 6497 days ago | link

from ac.scm :

  ; rather strictly excludes ()
  (define (arc-list? x) (or (pair? x) (eqv? x 'nil)))

  ; generic +: strings, lists, numbers.
  (xdef '+ (lambda args
           (cond ((null? args) 0)
                 ((all string? args)
                  (apply string-append args))
                 ((all arc-list? args)
                  (ac-niltree (apply append (map ar-nil-terminate args))))
                 (#t (apply + args)))))
Obviously, () is not an arc-list (as defined above). Thus, the test (all arc-list? args) fails with (+ '(a b c) ()) : finally, (apply + args), which is the numerical + of scheme is applied, hence the error message.

You were right, this might be a bug...

-----


In fact, both were needed to optimize things. Mzscheme's doc says explicitly (though I can't remeber where exactly) that standalones are a little faster than interpreted code (there are a few more optimisations they can perform during compilation I guess). Running arc1.scm through mzscheme -f is a little slower.

-----

4 points by elibarzilay 6497 days ago | link

There is an initial overhead for byte-compiling the code and jitting it -- but that's not something that you'd be able to measure for such a small piece of code. Once that's done, it's the same code -- mzscheme (since a good while ago) on intel and ppc does not interpret code. Ever. Even on solaris, where the jit is disabled, it's "interpreting" byte-compiled code, so it is not an interpreter in any case.

-----


Well, it's on the git now. To have the executable, just run

  mzc --exe arc1 arc1.scm
If you feel adventurous, mzc --gui-exe arc1 arc1.scm might give you access to MrEd, the graphical library of MzScheme (a MrEd binding to arc could be a nice thing :) but I didn't try it.

-----

3 points by eds 6497 days ago | link

Very nice. Both your suggested commands worked for me (on Windows XP).

I like the GUI especially (it actually solves a bug I found with mzscheme that was stopping me from pasting code directly into the command line). Although I find it somewhat strange that I have to click quit twice in order to actually close the program.

-----

1 point by ryantmulligan 6497 days ago | link

does the first click close Arc and the second close MrEd?

-----

1 point by eds 6497 days ago | link

Yes.

  Use (quit) to quit, (tl) to return here after an interrupt.
  arc> (quit)
  
  [Exited]
Clicking close after this closes the window. Similarly, clicking close twice seems to first send a break signal, then close the window.

I kind-of understand why it is doing this, but it might be nice to have it quit immediately when the user enters (quit).

-----

2 points by sacado 6498 days ago | link | parent | on: The Factor Language

Well, maybe I didn't fully understand how to use it, but it is really too hard for me to write a code that looks like "dup rot- . * + dup dup < . if", even for low-level functions.

I find myself taking too much time thinking "let's see, the value I want is at the third position on the stack, I want to get it duplicated on the top, but without changing the order of the other elements, so I should do..." instead of really solving the problem I'm working on.

But maybe I'll give it another try later ?

-----

3 points by ryantmulligan 6497 days ago | link

Either you can make a word that takes the 3rd element from the stack while maintaining order, or there already is one.

-----

1 point by sacado 6497 days ago | link

But in other languages you don't even have to bother with that. Accessing the third element of the stack is easily feasible and you can even guess how to do it.

And the fact that my variables have no name (they're all called "first element on the stack", "second element", etc.) reminds me assembly code, but without the efficiency : I can understand that in a low-level language as Forth, but it doesn't look like Factor is one.

But I can be wrong, and anyway Factor is on my "try it again later" list.

-----

1 point by mst 6495 days ago | link

On the one hand, factor -does- have named variables.

On the other hand, once you start experimenting with stack stuff there's a moment where you go "aha" and it actually starts to make a lot of sense for temporary variables.

There are probably other aha moments further in that I haven't got to yet; I've not spent as much time with factor as I want to.

I dunno if I'll ever use it for "real stuff", but I think it's worth fighting your way through to the aha moments just like lisp and haskell are even if you never expect to use -them- for "real stuff".

-----

9 points by sacado 6498 days ago | link | parent | on: Reflection in arc?

add this to ac.scm :

  (xdef 'all-symbols
      (lambda ()
        (let ((result '()))
          (for-each (lambda (sym)
                      (let ((s-sym (symbol->string sym)))
                        (if (eqv? #\_ (string-ref s-sym 0))
                            (set! result (cons (string->symbol (substring s-sym 1)) result)))))
                    (namespace-mapped-symbols))
          result)))
After that, in arc, the call (all-symbols) returns you the list of all global symbols. Then it should be easy to get what you want...

-----

3 points by sacado 6498 days ago | link

(listtab:map [list _ eval._] (all-symbols)) then gives you the above as a table.

-----

1 point by sacado 6499 days ago | link | parent | on: Question on '() and nil in ac.scm

at first sight, quite a good idea...

-----

3 points by sacado 6499 days ago | link | parent | on: Infix Math

Yep, I think that would be great on the git :)

-----

3 points by eds 6499 days ago | link

After a little adventure getting git to work, I added my code to the git repo. (Being new to git, I didn't know you have to add before you can commit, and you have to commit before you can push....)

Everyone feel free to make improvements as you see fit.

-----

3 points by almkglor 6499 days ago | link

defsop would too ^^

-----


If I remember, the very first version of Python was 5 x slower than the next one, which was itself many times slower than the current ones. Well, obviously, Arc1 is much faster than Python 1...

And if you want good news, compare it with Groovy or Squeak...

-----

5 points by sacado 6502 days ago | link | parent | on: Using Arc at work

Well, the code (with a few explanations) is now available at http://my-arc-stuff.blogspot.com/

-----

2 points by almkglor 6502 days ago | link

Interesting. I suggest you add defsop to the arc-wiki.git

As for the process that does the archiving... if I remember correctly hacking through srv.arc shows that it will summarily kill any operations that take too long.

-----

1 point by sacado 6501 days ago | link

Ok, I'll add defsop to the git.

Well, concerning long threads... That's the reason why I fix threadlimit* at the beginning to 300 s. That's enough for archives 5OO MB long, and anyway, for even bigger archives, I wouldn't propose people to use this method...

-----

More