Arc Forumnew | comments | leaders | submit | nex3's commentslogin
3 points by nex3 6657 days ago | link | parent | on: "." not allowed in quasiquote?

Properly formatted:

  arc> (fn (name . args) args)
  #<procedure>
  arc> ((fn (name . args) args) 'a 'b 'c)
  (b c)
  arc> `(fn (name . args) args)
  Error: "map: expects type <proper list> as 2nd argument, given: (name . args); other arguments were: #<procedure:...v352/arc0/ac.scm:167:14>"
This does seem to be a bug, though.

-----

2 points by nex3 6657 days ago | link | parent | on: We Have Docstrings

That's exactly what I was hoping would happen once we added docstrings.

-----

2 points by nex3 6657 days ago | link | parent | on: Arrays

Why not use (= (v 0) 0) for setting an element?

-----

3 points by jivestgarden 6657 days ago | link

The = macro looks into a database of settable functions and there is no way to update the database at array creation. In order to use = I must either change let, with, and withs, or, introduce settable accessors, such as aref, but as I said, accesssors are not nice (I use arrays a lot in common lisp, and the accessors are driving me mad). The <- is actually a lot more general than =; it can set anything that returns its own setter, not just arrays. It is not suited for hash-tables, though, since they are likely to contain the key Xsetter.

-----

4 points by nex3 6657 days ago | link

Actually, with only a tiny modification of the core code and using tagging as a typing mechanism, you can set this sort of array in more or less the same way you set hashes:

  ; Added as line 454 of ac.scm:
  ((ar-tagged? fn) (ar-apply (ar-rep fn) args))

  ; Added to arc.arc
  (let old sref
    (def sref (com val ind)
      (if (no (isa com 'array)) (old com val ind)
        ((com 'setter) val ind))))

  ; Added at the end of your array code (or directly to make-array-wrapper)
  (let old make-array-wrapper
    (def make-array-wrapper (dim store)
      (annotate 'array (old dim store))))
If you don't want to patch that manually, I've added your array lib and my patches to the Anarkies.

-----

2 points by jivestgarden 6657 days ago | link

Patches are not a good thing since they breake the fundamental idea of arc: a language implmented in itself. Also you will soon run into trouble when introducing other array types, such are diagonal, bi-diagonal, tri-diagonal, upper-triangular, etc, and not to talk of foreign arrays, all requiring a new patch. (I can think 100 different array types, it should not require 100 patches.) However, it might be that a solution is to improve the arc type system itself, which seems over-simplified.

-----

3 points by nex3 6657 days ago | link

I disagree. If by "patch" you mean modifying the behavior of sref via Arc code, I think that's very much in tune with the fundamental principles of arc. I also think that working from basic principles - type, rep, and annotate (nee tag) - is a much more Arc-ish way to make a type system than having something deep and complex built in.

As for defining new accessors for every new type, it would be easy to modify sref to do a table like = does, and make defining accessors as easy as defset is now.

-----

1 point by jivestgarden 6656 days ago | link

I think we need to do both, both spawn functionality based on types, but also build more complex constructs at the the top of the simpler. The = and the <- do different things, the = depends on type, <- is a lot more general and depends on what the object itself returns. Arrays are higher order objects, and they depend on element-type, indexing, and, the physical store (currently only hash tables, but it should be raw memory segments for fast arrays) . So the true "type" of the array is a tuple of three (when i said 100 types I though about all the combinations. In reality there are infinitely many, but most them are not needed). In reality what I do in the library is to make a lexical type, that is created with the object, and is thrown away when its not needed anymore. However, a third possibility, is to make something like a template system. This is not easily done in CL, but should be possible in arc due to first class macros. How to actually do this, I do not know.

-----

3 points by nex3 6658 days ago | link | parent | on: List of Arc Functions and Macros

Very cool idea, dmdavis. Would you be willing to integrate this with the docstring support in the Anarkies? It would suck to have documentation in one place but not the other...

-----

1 point by dmdavis 6657 days ago | link

I changed my script that grabs the functions so that it will work with docstrings, but I thought it made more sense to be documenting the main branch rather than the git repo. What do you think?

-----

1 point by nex3 6656 days ago | link

The Git repo is pretty much a superset of arc0, except for a few bugfixes here and there. Plus if we're going to actually add docstrings to the code, the only way to do that would be to commit them to the repo.

I think it would make the most sense to just document the Git repo and make a note in the documentation that it's not identical to arc0.

-----

1 point by dmdavis 6656 days ago | link

Yeah, that makes sense. The page is now showing all info from the Git repo.

-----

1 point by nex3 6658 days ago | link | parent | on: Multi-var function literal shorthand

I thought about suggesting this as one of the prefix characters, but underscores just don't feel very prefixy.

-----

1 point by Xichekolas 6657 days ago | link

One thing about underscores is that they kind of stand out... but I agree, they are a bit weird. Other options could be (@, $, %, *, ?)

-----

4 points by nex3 6658 days ago | link | parent | on: Multi-var function literal shorthand

I don't like the idea of binding in the order they're used - it seems like it would make a lot of uses impossible (at least without making it more verbose than a fn would have been).

It seems better and more concise to somehow specify the variables with numbers, presumably with some sort of prefix:

  ([- $1 $2 $3] 3 2 1)
  ([- \1 \2 \3] 3 2 1)
  ([- #1 #2 #3] 3 2 1)
We could even bind the prefix character itself to the second argument, to make the two-arg case even shorter:

  ([+ _ #] 2 1)

-----

3 points by Zak 6658 days ago | link

I thought about using numbers like that too, but when I posted this I was too tired to remember why that might be a better idea. You're right - it would make more sense to use numbers, and if you're writing a function that's long enough that numbers would make it hard to read, use fn. Zero-indexed numbers with sigils to designate the place in the arg list are better.

  ([- $1 $2 $0] 1 3 2])
translates to

  ((fn ($0 $1 $2)
      (- $1 $2 $0))  1 3 2))
I don't like binding the sigil by itself to the second arg - it's starting to look like Perl. I'd even be in favor of eliminating the underscore and only using the sigil-number notation, with the special case that the sigil by itself is arg 0.

-----

1 point by dreeves 6653 days ago | link

That's what mathematica does:

(#1 - #2 - #3)&[3,2,1]

with # equivalent to #1.

(By the way, mathematica is all s-expressions (or rather, equivalently, McCarthy's m-expressions) underneath. You can call FullForm on any expression to strip away the syntactic sugar, eg, FullForm[a+b] => Plus[a,b]. Note the f[a,b] instead of (f a b). A nice thing about the commas is that you can throw in infix wherever it's convenient, like If[x>2+2, B, b] instead of If[Greater[x,Plus[2,2]], B, b]. The best lisp solution I've seen for that is curly sweet-expressions: http://www.dwheeler.com/readable/ )

-----

1 point by jimbokun 6657 days ago | link

([- (_ 1) (_ 2) (_ 0)] '(1 3 2))

What about that?

-----

1 point by Zak 6657 days ago | link

Adding parens to make it more "lispy"? I don't see the point, really. Also, why are you passing it a quoted list instead of the actual values you want?

-----

1 point by jimbokun 6657 days ago | link

Because this actually works in the current version of Arc. Maybe not quite as concise as the proposed syntax, but probably as close as you can get without adding syntax (at least that I can think of).

So you need to weigh the cost of adding more syntax to the language for the savings of "$1" vs. "(_ 1)".

-----

1 point by nex3 6657 days ago | link

Note that the latter is more than twice the size of the former, and that you'd also need to put the arguments to [] into a list prior to passing them into the fn. I'd say $1 is a pretty big win in terms of conciseness.

-----

1 point by nex3 6658 days ago | link | parent | on: Use Apache for static files?

Using a reverse proxy seems like the best solution with the code we've got.

-----

2 points by byronsalty 6658 days ago | link

Makes sense. Obviously this is better for something being released to the public but during testing I didn't know if (even inefficiently) asv could be used as a one stop shop (a la webrick).

thanks

-----

1 point by nex3 6658 days ago | link

That shouldn't be too hard to hack in, I think... just find some way to capture all /images/* URLs or something and open up a file and send the contents. You might have to be a little careful with MIME types and so forth, but it seems pretty straightforward.

-----

5 points by bogomipz 6658 days ago | link

Just take any URL that is not defop'ed to mean a file name.

Currently, if no op is defined, the server responds with "Unknown operator.". Replace that with the code for opening a file, and if this fails, respond with a proper 404 Not Found message.

-----

3 points by pg 6658 days ago | link

That should work for text/html files.

-----

2 points by bogomipz 6657 days ago | link

By throwing in a hash table which maps from file name extensions to MIME types, it could work for other files as well.

A byte array data type for buffering would do good for performance.

-----

4 points by nex3 6658 days ago | link | parent | on: This is probably a really bad idea.

This applies to any distributed revision control system, which is why I created a Git repo: http://arclanguage.org/item?id=809.

However, Subversion has the distinct benefit of practically everyone already having it installed. I think the current system works quite well: there are both Git and Subversion Anarkies, and they're kept as similar as possible.

-----

2 points by nex3 6659 days ago | link | parent | on: This is probably a really bad idea.

I'm not sure this is necessary, at least yet. People seem to be quite well-behaved so far - the only breakage is accidental (and that's mostly me anyway :-/).

-----

1 point by nex3 6659 days ago | link | parent | on: Unquoting

Or we could avoid the whole syntax round-robin and make quasiquote {}.

-----

1 point by oddbod 6658 days ago | link

Or <>, which implies 'template' (to a younger audience).

-----

More