Arc Forumnew | comments | leaders | submit | jmatt's commentslogin
3 points by jmatt 6360 days ago | link | parent | on: Macro trouble

I think what you want is this:

  (mac meta(x . y) (+ x (car y)))
The way . works in parameters is that it is a list of the rest of the parameters that you are passing to the function/macro. This list could be empty/nil or contain one or more elements.

  arc> (mac meta (x . y) (prn x y))
  1(2)
  1
  arc> (meta 1)
  1()
  1
  arc> (is nil '())
  t
Don't forget that nil and the empty list are equivalent in arc.

EDIT: Added some explanation.

-----


I think there is a more pleasant way to view it by decompiling.The language looks like byte code to me.

From the manual http://www.basis.uklinux.net/ursala/manual.pdf

  $ fun --main="˜&nSiiDPSLrlXS" --decompile
  main = compose(
    map field((0,&),(&,0)),
    compose(
      reduce(cat,0),
      map compose(
        distribute,
        compose(field(&,&),map field(&,0)))))
EDIT: Reread the manual. It is a mangled perl like language. Seems useful if you are crunching equations and plotting.

-----

1 point by graindish 6360 days ago | link

The language is compiled to virtual machine code similar to what the listing shows, and is closer to the functional programming camp than to perl (ultra fp geeky features for defining your own fixed point combinators in section 7.5.3).

-----

4 points by jmatt 6361 days ago | link | parent | on: Cant get tutorial hello webapp to work

I got arc2 to work on linux and windows initially through searching the forums and finding bugs. It was an interesting exercise but overall I'd recommend arkani. arkani has more bug fixes and all sorts of interesting code to look at and/or use.

-----

1 point by jmatt 6361 days ago | link | parent | on: Cant get tutorial hello webapp to work

Yeah use Arkani.

http://www.arcfn.com/2008/02/git-and-anarki-arc-repository-b...

arc2 works fine on mac os x but has problems with linux and windows.

-----

1 point by jmatt 6361 days ago | link | parent | on: Learningcurve of LISP?

The learning curve is small if you have a math or cs education, if you've been exposed to another functional language or you naturally think in s-expressions.

If you are just a random python programmer and you looked at arc I could see it being challenging. The axioms of lambda calculus and functional programming are concise and simple but that doesn't mean the concepts they imply are also simple.

I agree The Little Schemer is a great book. Along with SICP, On Lisp, etc.

In the end it is worth the trouble to learn at least one lisp dialect. It'll improve your coding and make you question why you are writing imperative-language-001 all day long.

-----

4 points by wfarr 6361 days ago | link

Having come from Perl, Python, and Ruby I didn't have much trouble.

Granted, Ruby makes use of closures and anonymous functions more often than the other two.

I think the greatest learning tool I had was configuring my Emacs setup and writing extensions to do things I wanted in my workflow.

-----

3 points by jmatt 6361 days ago | link | parent | on: Learningcurve of LISP?

I ran into problems when I first started writing scheme. I think the learning curve seems steep because it is a different paradigm than python. Lisps are all functional languages. Most commonly used languages in the end are similar, they are imperative languages.

I'd expect it to take some time to get used to and learn this new style of coding. Variables in general are not needed especially outside the scope of a function or macro. Syntax is weird because there isn't much of it to begin with.

I'd recommend that you first read the entire tutorial and make sure you understand what's going on there. Then I'd recommend reading some of Paul Graham's "On Lisp". Even though it is in CL instead of arc - I think the philosophy is the same.

http://ycombinator.com/arc/tut.txt

http://www.paulgraham.com/onlisptext.html

-----

2 points by jmatt 6362 days ago | link | parent | on: OOP in Arc

If templates isn't feature rich enough, I imagine it is just a matter of time before someone implements a more complete OO system in arc.

In the meantime there are a bunch of schemes and lisps that support different object systems. You'll want to look for CLOS (Common Lisp Object System) and MOP (metaobject protocol) in the descriptions. I've used gauche scheme and had some good luck. http://practical-scheme.net/gauche/

-----


I think a macro solves the problem where (is 0 0.0) returns nil. I think the reason they are not equal has something to do with precision and the representation of 0 versus 0.0.

  ;allows equivalent ints to be equal.
  ;i.e 0 = 0.0, 1 = 1.000000, etc.
  (mac == (a b)
        `(if (and (is (type ,a) 'int)
                   (is (type ,b) 'int))
               (is (+ ,a 0.0) (+ ,b 0.0))
               (is ,a ,b)))
produces

arc> (== 0 0.0)

t

arc> (== 123 123.00)

t

arc> (== "a" "a")

t

arc> (== "a" "b")

nil

arc> (== 1 9)

nil

arc> (== 1 1.00000001)

nil

Interesting quirk. Glad I know that (is a b) may not always work.

-----

2 points by jmatt 6367 days ago | link | parent | on: Documentation of Arc's web server

Kens: Thanks. Your documentation is much appreciated and regularly used.

-----


I have wondered a few times why arc doesn't have keyword parameters. It is one of my favorite features in Gauche scheme. Other great features are clos like object system, module system and a thread system that supports preemption which is hard to find in scheme implementations.

In addition, I think keywords would make the library far more transparent. Right now I still have to root around and figure out what the heck I'm supposed to pass in.

-----

More