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

this would suck without tail call optimization. lol

-----


i actually don't really want local variables without a let. i prefer the explicit scoping of a let binding. i often wish i had it in other languages.

-----

2 points by cooldude127 6080 days ago | link | parent | on: (/ 0 0.0) = 0

screwy floating point arithmetic!

-----

2 points by cooldude127 6081 days ago | link | parent | on: Idioms for programming in Arc

arc has lambda, it's just renamed to fn (same as clojure).

clojure lacks car and cdr because it also lacks cons cells. there are other collections, but the little pairs we've come to know and love are gone.

-----

2 points by sacado 6080 days ago | link

yeah, we know, we were just kidding :)

However, seriously, clojure looks really interesting, being a cool language on the JVM and being purely functional. But does anybody know if it is possible in this language to make (easily) funny structures like circular lists, graphs, etc. ? AFAIK, that's the problem when you don't want to use set-car & set-cdr in Scheme (that's a problem in NewLisp too, for example) : you loose them. Did clojure manage to overcome this problem ?

-----


AKA C-x b

keyboard FTW

-----

1 point by cooldude127 6082 days ago | link | parent | on: defmacro mac?

except you wont be able to use arc's cool dotted list syntax for arguments. instead of

  (def my-fun (a . rest)
    ...)
you have to use CL's &rest syntax

  (def my-fun (a &rest rest)
    ...)

-----

1 point by schtog 6082 days ago | link

but using def and mac with these definitions:

  (defmacro mac (&rest body)
	  `(defmacro ,@body))

  (defmacro def (&rest body)
	  `(defun ,@body))

is EXACTLY the same as writing defmacro and defun?

-----

1 point by cchooper 6081 days ago | link

yep

-----

1 point by wfarr 6082 days ago | link

Personally (and this may well just be me) I prefer the latter.

-----

1 point by dreish 6082 days ago | link

What does it buy you, other than four more steps toward carpal-tunnel syndrome?

-----

1 point by cooldude127 6086 days ago | link | parent | on: having a parenthesis in a list?

the parenthesis means you have a list nested in a list.

-----

1 point by globalrev 6086 days ago | link

yes and i dont want to, is there a way to get around this.

(car '(( 1 2)) and have ( returned. u cant do some trick here?

(car'("(" + 1)) returns "(", how do i get rid of the ""?

-----

4 points by kens 6086 days ago | link

If you want to display a string without the quotes, use "disp" instead of "write".

If you want to convert a string into an S-expr, use "read", and then if you want to evaluate that expression, use "eval".

  (eval (read "(cons (cons 1 2) 3)"))
But I'm pretty sure you don't want to do either of those in this case. If what you want is nested lists, generate the nested lists - Lisp is good at that. Don't try to piece together your code out of parentheses. The following code will more-or-less generate the nested lists you asked about:

  (def xw (n)
    (let l '()
      (for x 1 n
        (= l (join 'w/link (list l))))
      l))
However, the other problem with your approach is that even if you get xv working, it will pass a quoted expression to defop instead of an expression, and defop won't work right. To generate code, you need a macro, not a function. Here's a macro that will solve your original problem:

  (mac xw args
    (if (is (len args) 1)
          `(pr ,@args)
          `(w/link (xw ,@(cdr args)) (pr ,(car args)))))

  (defop wc req (xw "Wel" "come" "to" "Sweden" "!"))

-----

2 points by conanite 6086 days ago | link

are you looking for something like

  (prn (list #\( 'foo #\)))

?

-----

3 points by cooldude127 6124 days ago | link | parent | on: Defining Setable Forms

yay! i wrote that def= macro. i too would like it CL style integrated into def. i simply didn't feel like rewriting def to accomodate it.

-----

2 points by cooldude127 6131 days ago | link | parent | on: Map et al arguments are backwards

i think this makes map confusing when applying to multiple lists. where does the function argument go? at the end? after the first list? it just makes more sense if the lists are last.

-----


well, you could always just use pairs to turn the interleaved list into an alist.

-----

1 point by bogomipz 6133 days ago | link

Yes, with the overhead of the operation plus a let form.

My suggestion only really applies if pg decides against adding keyword arguments to Arc.

-----

2 points by cchooper 6133 days ago | link

Exactly. It's basically a roundabout way of adding keywords into the language. A better idea would be to just add them, and then list-functional notation could be used for something more generally useful.

-----

More