vsingh


6 points by vsingh over 2 years ago | link
cached 11 days ago

6 points by vsingh over 2 years ago | link | top
cached 11 days ago
This just made me notice something interesting.

This works:

    (eval (list 'oaf 1 2))
    2
But this does not:

    (eval (list oaf 1 2))
    Error: "Bad object in expression #3(tagged mac #)"
In other words, you can't evaluate a form in which the car is the actual macro object itself, rather than the name of a macro. If we could make that work, we could solve your problem by inserting the macro objects we want where we want, in effect telling Arc which version of 'oaf' we want in advance.

It would make macro expansions pretty ugly to look at, though.


6 points by vsingh over 2 years ago | link
cached 2 days ago

4 points by vsingh over 2 years ago | link | parent | top
cached 13 days ago
The negative index syntax doesn't work yet, but for the rest of your example:

    (map "foobar" (list 0 2 4))
    (#\f #\o #\a)

4 points by vsingh over 2 years ago | link | top
cached 11 days ago
"Where is macrolet?!"

Arc has first-class macros.


4 points by vsingh over 2 years ago | link | parent | top
cached 6 days ago
Your solution is not sufficiently general.

For example, it should keep working if the 'a' in (+ . a) is replaced with its actual value. In that case, we get:

    (+ . '(1 2 3))
which is the same thing as saying

    (+ . (quote (1 2 3))
which is equivalent to

    (+ quote (1 2 3))
which obviously doesn't do the same thing as

    (apply + '(1 2 3))
which is what you wanted.

4 points by vsingh over 2 years ago | link | parent | top
cached 2 days ago
Here's my Arc solution:

    (mappend [awhen (pfft _) (list (yo-mama (cons _ it)))] whatever)
The implementation of mappend in arc.arc is currently very inefficient, but it could easily be fixed to bring this code on par with the LOOP version.

4 points by vsingh over 2 years ago | link | top
cached 2 days ago
That looks like a bug to me. This works fine:

    (mac myfn body
        `(fn ,(cons 'frst 'rest) ,@body))

3 points by vsingh over 2 years ago | link | top
cached 2 days ago
Kenny Tilton submitted:

   (loop for y in whatever
         for py = (pfft y)
         when py collect (yo-mama (cons y py)))
The Arc solution is required to be roughly as efficient as the above code.

3 points by vsingh over 2 years ago | link | parent | top
cached 2 days ago
I got a little carried away with being clever in that version. But look at the canonical Arc version:

   (rev:accum collect
      (each y whatever
         (awhen (pfft y) (collect (yo-mama (cons y it))))))
This version is pretty straightforward in expressing my intent.

As for the scaling issue, I'm still thinking about your other example. I'm not sure it's a good thing that Loop allows more and more to be tacked on. Subroutines in imperative-style languages like C++ have the same agglutinative property, and we're all familiar with the results of that.