I'd love for you to use it and to have your feedback. Of course, it's still unstable, poorly documented, etc. Please open lots of issues and send me emails to the tune of "Why the hell <x>?". I'll always try to give you a personal response.
Also, if you're interested in working together on it, or just forking it and changing a bunch of stuff, that could be really neat! :)
Thanks, it seems like my brain was scrambled last night. _0 and _1 (or _a and _b) are the appropriate pieces of code. But the real problem was that I was operating out of an arc directing that was lacking a load/ directory. Thus I was missing the make-br-fn.arc file. Fixed now. Thanks guys!
If the behavior were in a different utility named 'v+ or something, you wouldn't have a "two libraries extending the same case" conflict (just a "two libraries defining the same variable" one :-p ), and you'd also be able to have (v+ '(1 0 0) '(0 1 0)) be '(1 1 0) without conflicting with Arc's existing result of '(1 0 0 0 1 0).
Using 'extend generally also has the drawback that existing code that expects to get an error from something like (+ 1 '(1 2 3)) won't get that error anymore. This is less of a problem when using a tagged type that people are very unlikely to be using already, but numbers and lists are especially common.
I had a pearson function of my own lying around, which I just pushed. I personally think mine is a little shorter and easier to see the connection between it and the original mathematical function on which it is based. I also have a matrix version and some nearest neighbors functions I wrote a while back.
Thanks a lot, for taking care of the anarchy I caused in the Anarki!
From now on I'll commit to my fork and if there was any thing of general interest you can pull it to master later.
I noticed you mentioned "it would be better if matrix was its own type" I agree with that. Is there any way to communicate this with pg (or anybody else who has a say on such basic matters) and see if matrix could be implemented as its own type?
As you know I am an absolute newbie in arc/lisp but I find it quite refreshing to solve (or re-solve) problems the arc/lisp way.
Actually, do you mind pushing to Anarki instead (unless you have some really risky code that could break a lot of stuff)? Totally up to you, but I'm of the opinion that if we're all hacking in the same repo, our community will be stronger.
A growing set of files in lib/ doesn't really hurt anyone, and if someone really hates your or my code, they're free to rewrite it, or just not load that library.
It's pretty obvious that people like aw, shader, and fallintothis (off the top of my head) are much better scheme hackers than I am, but I don't think I've stepped on their toes too much, and if I think I'm going to, I'll ask the forum about pushing something.
Regarding implementing matrix and vectors as their own types, if you can do it and have the time to do so, you don't need to wait for PG's permission. For my needs at least, Anarki is the more useful tool and PG, while he is the original creator, is just a periodic contributor like the rest of us (although he doesn't push to github - one of us ends up merging his stuff).
Oh, and your variable capitalization style (is duck typing the name? I can't remember) is a little out sync with the community style. Just a heads up :)
Since we're talking about vectors and matrices - one of the things I've been wanting to do is define + as a generic (see iso). There's been some discussion about the pros and cons of overloading + for strings (http://arclanguage.org/item?id=12347) but for mathematical entities it should be fine.
A more intense project is to come up with some nice way to extend coerce without needing to modify ac.scm each time. Was there ever a way to do this in anarki, does anyone know? Maybe in the arc2 branches?
For example, here is an extension to + to combine tables:
(extend + args (isa (car args) 'table)
(listtab (apply + (rev:map tablist args))))
arc> (+ (obj a 1) (obj b 2) (obj a 3 c 4))
#hash((b . 2) (c . 4) (a . 1))
I know you've been working a bit with generics, which I'm not familiar with. I really haven't looked into your code (except to note that you have something in arc.arc which throws me redefinition messages whenever I start up arc), do you have an easy way to create a vector and matrix type? Seems like aw's "extend" and a "vector" method which allowed me to create something that returned type 'vector would be sufficient to get the ball rolling.
rocketnia had a nice comparison of extend with defgeneric in the original thread: http://arclanguage.org/item?id=11779. aw chimed in as well: "If there's a facility that does what you need, use it, but if there isn't, use 'extend ^_^" :)
(Thanks for the pointer to coerce, rocketnia)
My experience since then has been that the efficiency of a hash-table lookup is irrelevant. But I really like the conciseness and readability of being able to say:
(defmethod foo(arg1 arg2) type-of-arg1
"you have something in arc.arc which throws me redefinition messages whenever I start up arc"
If you're just concerned about having the type 'vector, you can use Arc's (annotate type representation) function to give a value a wrapper with a custom type, and you can use the (rep wrapper) function to unwrap it.
If you're actually talking about vectors in the Scheme sense (arrays), there'll be a few more hoops to jump through, but that's not really what you mean, right?
Sorry guys, would somebody summarize this discussion on vectors and matrices? I mean after all is there any merit in defining a generic matrix type for everybody to use or people better define their own for their specific job. I am still trying to read the documentation, this is all new for me.
Looks like garply is putting together a library which deals with matrices and vectors and wants to be able to say (isa x 'vector). The 'annotate and 'rep functions make that happen. Anarki also defines 'defcall so that new types like these can be given special behavior when used as functions.
In one sense, garply's defining a matrix type for every Anarki user to use. In another sense, it's only a matrix type specific to the purposes of that library. But in any case, if this type doesn't look good to someone, they can just follow the same process to define their own type and forget this one exists at all. :-p
Realistically, I think efficiency is one of the things at the top of people's minds when they're trying to do computation with matrices, and with all due respect to garply, I doubt the project is going to get to the cutting edge of matrix efficiency anytime soon. >.> So I actually do expect someone to decide to define another matrix type later on. Nevertheless, garply's contributions could certainly help that person along. ^_^
You're absolutely correct. I would go so far as to say that Arc itself is too slow to do any serious matrix computations (maybe if you made this just an interface to some Racket matrix libs you could work around it). I'm really not going to bother thinking about efficiency much at all. What I have done before in Arc is prototyped some algorithms on very small test sets. Once I got those working and figured out what I actually wanted, I rewrote everything in C++ or C, with a very close eye to efficiency.
I used to use this strategy all the time with an R / C combination, but I greatly prefer writing in Arc. Lush is kind of the best of both worlds, except the last time I pulled the bleeding edge version there appeared to be some crippling, hard-to-find bugs. Plus it's nice to just be able to build quick prototypes when you're already in Arc.
I do wish PG would spend more time making his language better and it does feel a bit like he's abandoned it. If Clojure compiled to C instead of sat on top of Java, I would probably jump ship. Having a community is a valuable component of a language and PG's in a great position to really market Arc (we already have proof that he can build a community due to HN), but he just doesn't. My conclusion is that running YC has caused him to strongly deprioritize Arc.
While I still hack in Arc constantly because I'm always tweaking HN, I haven't made dramatic changes to the language itself lately. I only seem to be able to work on 2 things at once, not 3. Since YC is a given, that means I have to choose between hacking and writing. Lately I've mostly chosen writing.
I should release a new version though. News.arc is greatly improved since the last release.
That would be great. Seeing others share code - even tools that I don't currently use - makes me want to push code as well. When I push code and no one else does, I feel a bit like my work is unappreciated and want to stop sharing. I suspect there is type of momentum at work in the formation of vibrant programming communities. Seeing Arc 3.2 would be motivational.
iirc all reported bugs fixes were incorporated by the arc3.1 release. (Releases haven't always incorporated all fixes reported up to that point, the atomic-invoke fix was particularly alarming and took several releases to make it in).
The only bug I'm currently aware of off the top of my head in arc.arc is readline, which was reported after the arc3.1 release.
There are a couple of known issues with the Arc runtime (i.e. the queue bug you found which seems likely caused by unsafe mutation of immutable cells, nested quasiquotation) which have prospective fixes, but neither tested throughly enough that I'd personally say, "oh, why yes, you should go ahead and switch HN over today".
Thanks for taking the time to dissect the downsides of what I'm increasingly convinced is a bad idea. I agree with your reasoning, particularly with regard to the scenarios involving hashtables and lists.
Nonetheless, variable negation is something I imagine we all encounter with relative frequency, what do you guys think of a negation symbol equivalent to "no." (i.e., ¬)?
Since "!" is used elsewhere, "^" strikes me as a natural choice, probably because I associate it with set complements for POSIX regular expressions.
I make heavy use of + for concatenation throughout my code. I prefer it for a few reasons:
1. I find myself concatenating lists frequently and I prefer that frequently used functions be short. join has 4 chars to +'s 1
2. I also find ++ convenient for modifying a list variable. What would you use for the equivalent for join? In Racket's style, it would be join!, but I don't see a good analogue in arc for your proposal.
With regard to (2), to destructively append the list '(1 2 3) to xs, you can:
(zap join xs '(1 2 3))
"zap join" is several characters longer than ++, but zap has general utility.
I use the string function to concatenate strings. It seems to work identically to +, as long as the first argument is a string. I do give heterogeneous arguments to string usually, and I like seeing that they will clearly be coerced into a string.
I have a couple of ideas.
1. It would be little problem for me if Arc provided + as is and provided a "plus" function that worked only on numbers and allowed me to simply go (= + plus) and proceed normally. Unfortunately, that would break all the functions in arc.arc and so forth that use + to concatenate lists (which includes, among other things, the setforms function, which is used in expand=). It would be really nice if one could "freeze" the variable references in those functions, so that changing the global value of + wouldn't change what "+" in the bodies of those functions referred to.
2. If you use concatenation so much, perhaps we could allocate an ssyntax character for concatenation. & is currently used for andf (experiment with ssexpand to see). We could boot out that usage, or perhaps have "&&" become andf. Good/bad idea? (Precedent: my memory tells me the TI-89 uses & for string concatenation.)
Regarding your second suggestion, we could also use . instead of &, as that's what Perl and PHP do - feels a little more natural to me. But . might cause me a little mental friction in differentiating between the different uses of . in (. "a" "b") and (do (= a '(1 2)) a.0).
To be honest, I'm still not crazy about the idea simply because I don't need the speed boost and + doesn't seem to cause me to use extra mental cycles when reading my code. I'd be open to it though if the community really wanted it that way.
We could vote and also ask PG what he thinks and then make a decision.
I find thinking about whether or not I have to escape the "@" character is distracting
I find this is easier with proper syntax highlighting. My arc.vim ftplugin can detect if you have (declare 'atstrings t) and, if so, highlights the escaped parts of strings. That way, you know if @ is escaped just by glancing. But I don't mean to shamelessly plug, haha. I don't use atstrings either, but my reason is far lazier: in the middle of writing code, it's less effort to just use + than it is to declare then go back and start using @s.
What other goodies does your arc.vim plugin have? Is your editor at all integrated with the arc repl? Lack of a repl that I could easily send arc code to was the reason I switched to emacs after years of using vim. These days, using emacs with viper (vim emulation mode), I don't miss vim at all.