cooldude127


9 points by cooldude127 over 2 years ago | link
cached about 1 year ago
I took a very small amount of time to translate On Lisp's scheme implementation of choose and fail into Arc. It is quite elegant, I must say. Here it is:

  (= paths* ()
     failsym* '@)

  (def choose (choices)
    (if (no choices)
        (fail)
        (ccc (fn (cc)
               (push (fn ()
                       (cc (choose (cdr choices))))
                     paths*)
               (car choices)))))

  (= fail nil)

  (ccc (fn (cc)
         (= fail
            (fn ()
              (if (no paths*)
                  (cc failsym*)
                  ((pop paths*)))))))
One problem: instead of returning the failsym when all possibilities fail, it gives this error:

  Error: "read-char: input port is closed"
Not sure what that's all about.

7 points by cooldude127 over 2 years ago | link | parent | top
cached 2 days ago
also, i find myself not using clos or defstruct all that much in my cl code. i tend to use ordinary data structures like lists and arrays.

my recent example (an excerpt from which i already showed) was a sudoku solver. i wrote one version in CL, then thought i'd do it in arc for fun. in CL, the puzzles were simply arrays (in Arc, they were lists do to the lack of an array type).

However, i didn't want my code to use the array (or list) accessors built into the language to access values in the puzzle, because that is not abstract enough. so i defined a function called pval that takes the puzzle and an x and y, giving the value in that square. that way, my code deals with puzzles, not arrays.

Then I wanted to be able to set the value in a square using the same pval accessor. Trivial in CL, but Arc made it a little difficult. This comes up rather often for me.

That point might not have justified such a long explanation. Whoops.


6 points by cooldude127 over 2 years ago | link | top
cached 3 days ago
it's a good idea, but i'm not sure i'm big on borrowing the unix syntax. it just looks kinda ugly and unlispy to me.

6 points by cooldude127 over 2 years ago | link | top
cached 1 day ago
thing that annoys me is there is nothing for arc that is anything close to what slime is for cl. i would settle for an inferior arc mode. my emacs skills are not good enough to take this into my own hands, i'm afraid.

5 points by cooldude127 over 2 years ago | link | parent | top
cached 23 days ago
yes it is. i didn't realize that table was different in anarki. well, there is always listtab, but seriously, table should work like the anarki version.

5 points by cooldude127 over 2 years ago | link | parent | top
cached 14 days ago
yes, there are those people who program purely for hobby.

5 points by cooldude127 over 2 years ago | link | parent | top
cached about 23 hours ago
well considering the real live sites arclanguage.org and hacker news are deployed with news.arc, i would say you can deploy a real live site with it.

4 points by cooldude127 over 2 years ago | link | top
cached 6 days ago
one problem with #4: the main purpose of a destructive implementation is that they can use a more efficient implementation by working in-place. This entire benefit is negated by just using the functional implementation.

4 points by cooldude127 over 2 years ago | link | parent | top
cached 5 days ago
partial application is something I always miss in lisp. I often find myself writing anonymous functions that would be much shorter with partial application. here are a few examples from some of my own CL code (pay attention to the second let binding):

With anonymous function

  (defmethod do-step ((w world))
    (let* ((locs-to-check (all-cells w))
           (actions (mapcar (lambda (x) (act w x)) locs-to-check)))
      ...)
With an explicit curry macro:

  (defmethod do-step ((w world))
    (let* ((locs-to-check (all-cells w))
           (actions (mapcar (curry act w) locs-to-check)))
      ...)
The way it should be (built into the language):

  (defmethod do-step ((w world))
    (let* ((locs-to-check (all-cells w))
           (actions (mapcar (act w) locs-to-check)))
      ...)
It might seem small, but do it enough times and you appreciate the succinctness.

4 points by cooldude127 over 2 years ago | link | top
cached 2 days ago
one suggestion: remove the outer set of parentheses to match a regular let. so do:

  (maclet (myassign x y) `(= ,x ,y)
    (let z 1
      (prn "z before: " z)
      (myassign z 42)
      (prn "z after: " z)
      z))
also, changed the name to maclet to match 'mac' for definitions. if necessary, also define a macwith like the regular with.