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

For 1, that's not what I mean. If + is defined this way :

  (def + args
    (if
      (all [isa _ 'num])
        (apply int+ args)
      (all [isa _ 'string])
        (apply str+ args)
      (all [isa _ 'cons])
        (apply cons+ args)
        (err "oops")))
We just have a formal definition for + that we don't have right now. (As a side note, this is close to the actual implementation of the '+ defined in ac.scm). How can we know it works for strings, lists ? Does it works on chars or not ?

The goal is not to get rid of, say, -, * and / and implement them in Arc. Their signification is obvious and no one would need to see how they are implemented. This is not a math class. But this is not true of +, because by opening the black box it is, we have :

- the possibility for alternative implementations of the arc compiler, as most of the language is defined in itself. Imagine I want to work on a Forth implementation to put Arc code into fridges or TVs ; or pg thinks it's time to move on a C implementation to have a super-fast Arc. The smaller these axioms, the easier it is to get compatible compilers or to avoid bugs from one version to another.

- the possibility to say "I now want to use + for hash tables, let's add it, how is that implemented ?",

- the possibility to say "I don't need + to work for strings or chars or anything, I just want numeric addition because I'm crunching numbers ; +int is the function in need".

Incidentally, if I want to write +int, the only way to do so currently is to do (def +int a b (- a (- b))), and we both agree to say that it's a bad idea.

-----

1 point by sacado 6490 days ago | link | parent | on: Arc omptimization, again

Well, that's actually what kept me from Ruby and made me stick with Python for a while. I needed a little speed. Not that much, but Ruby was just below the barrier.

-----

3 points by sacado 6490 days ago | link | parent | on: Arc omptimization, again

Yes,but no. Once you get in the code of ac.scm, you see that the code is great (really easy to understand everything) but that it can really be optimized in trivial ways.

We already talked about arc<. The original code was : if all the elements are numbers, apply numeric + to the args. If all are strings, apply string-append. If all are lists, apply append. Else, apply numeric + (again). The optimization is obvious there, and I don't think it can be called premature.

There was another one that was fixed by pg in Arc2 (for those interested, it deals with ar-funcall).

I know I wasn't clear. I don't want Arc as fast as light right now. What really bugs be is the fact that I have to wait 3 seconds before I get the prompt. When arc.arc and libs.arc are loaded. That's what I would like to see optimized, as soon as possible.

-----

1 point by sacado 6490 days ago | link | parent | on: Arc omptimization, again

I was wondering, about the delay during the initial interpretation of (load "arc.arc") and (load "libs.arc") everytime arc is invoked : is that possible to load (and eval) these files once in mzscheme and then save the whole memory in an executable, à la SBCL (maybe other CLs, too) ? I couldn't find it in mzc's doc or in mzscheme's functions, at least in the older versions. That will not solve the problems after loading, I guess, but this one is quite boring (I find).

-----

1 point by elibarzilay 6489 days ago | link

It is possible to byte-compile it, which will get rid of the delay. It is also possible to create an executable with the compiled files in.

-----

1 point by sacado 6490 days ago | link | parent | on: Arc omptimization, again

Obviously, the code of Arc2 in ac.scm has been rewritten in some places, leading to optimisations in some cases but to slowdowns in other places. For example, (fib 10) is about 5 times (!) slower, but (fib 35) is about 30% faster. Maybe there are still easy optimisations possible.

btw, pg's code has been replaced by the older's code on the git, I'll fix that later on.

-----

4 points by sacado 6491 days ago | link | parent | on: Hygienic Macros

"when we see people using "lst" in code they mention on comp.lang.lisp, we unleash the hounds who chase them over the fence to comp.lang.scheme where they belong" : be careful, it's not necessarily a schemer, it might also be pg, writing a function where both l and ls are already bound...

-----

4 points by kennytilton 6491 days ago | link

Excellent point, it might just be an Arc welder trying to save a char -- well, we checked with the hounds and they say a CL-style defmacro and (is nil #f) -> t don't mask the Lisp-1 scent, but they loved On Lisp and Ansi Common Lisp and ViaWeb being done in CL so pg is welcome any time.

-----

2 points by raymyers 6491 days ago | link

Well interestingly enough, li ls and lst don't appear in the non-Scheme source of Arc, except for lst in the borrowed mergesort.

What about xs and ys, do we get the hounds too?

-----

1 point by kennytilton 6491 days ago | link

Looks like my code when it's a three-liner and it really is a bit much to be coding (in my Algebra program):

  (loop for denominator in denominators...
You are right (guessing at the implicit): "list" is a terrible name for a variable unless someone really is writing a general purpose list manipulation function, but we do see "lst" quite a bit over on c.l.lisp.

btw, the real question is whether you see "list" as a variable name in the Scheme source.

-----

1 point by tel 6491 days ago | link

xs, ys, as, bs set off my Haskell alarm. They're pretty obvious and general, but something about pattern matching makes them unavoidable:

   interleve [] _ = []
   interleve _ [] = []
   interleve (x:xs) (y:ys) = x:y:(interleve xs ys)

-----

1 point by sacado 6491 days ago | link | parent | on: ccc : is that a bug ?

ok, never mind, silly me :) Thank you, btw :)

-----


Because, in K, "(w@" is a shortcut for "That's very interesting. Do go on."

-----

1 point by sacado 6492 days ago | link

and : is print. Well, I guess.

-----

4 points by sacado 6492 days ago | link | parent | on: arc-mode.el for emacs

Anybody interested in doing the same thing for vi ?

-----

7 points by lojic 6491 days ago | link

From what I've read, pg uses vi, so I expect he's developed a filetype for Arc. I was actually a heavy vim user for a couple years, but recently switched to Emacs in part because of the Lisp support. I was back to my vim productivity level in about 3 days, so maybe you could give it a shot :)

-----

2 points by prime2 6487 days ago | link

Might be of interest: http://arclanguage.com/item?id=685

-----


You know what ? I didn't like Lisp-2. Couldn't understand how that stuff could be useful.

That was before Arc. I named a table tab for once. That's also a macro's name, but I didn't know. Guess what happened when I did (tab 'foo).

-----

5 points by kens 6491 days ago | link

Am I the only person who keeps trying to use t as a variable name? It's the perfect name for a temporary, a table, a test value, ...

-----

2 points by kennytilton 6491 days ago | link

I have to be coding pretty fast and furious in CL but it has happened a few times over the years. Nice warning or error (I forget) from the compiler, tho.

-----

1 point by cooldude127 6491 days ago | link

also the perfect name for a true value :D

but yeah, i've done that in my CL code before. so annoying.

-----

3 points by nlavine 6492 days ago | link

That's an issue with variable bindings being messed up, not a Lisp-1 problem. That would work fine in Scheme, for instance.

-----

1 point by lojic 6491 days ago | link

Is that because Scheme doesn't allow you to use a data item as the first item in a form? Or does it have some other mechanism currently lacking in Arc to help with this problem?

-----

4 points by nlavine 6491 days ago | link

The reason (tab 'foo) doesn't work in arc is that ac (in ac.scm) effectively has a special list of macros, and when it compiles (tab 'foo), it looks up tab in the special list. What is really should do in a lisp-1 is look up tab in the same list that all the other variables are in, which is the list that (let tab (table) ...) will modify. (Yes, I know I'm simplifying. No, it doesn't matter in this case, unless you can think of a reason that it does.)

Also, there's only one list like this, and it has global scope, so you can't have local macros or anonymous macros.

-----

2 points by lojic 6491 days ago | link

Ok, so if it worked that way, then (tab 'foo) would work, but you would have shadowed the tab macro, and thus lost the ability to use it, which doesn't sound like a problem if you didn't know tab was a macro to begin with.

Anyone know if this is how Arc will work, or if the current behavior is by intent?

-----

3 points by cooldude127 6491 days ago | link

the problem that other people have stated is that because arc's macros are unhygienic, allowing local variables to shadow macros causes some pretty serious problems.

-----

More