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

Hey Evan,

What's the status of your arcscript? Do you have something usable? I'd love to use it if you feel like sharing.

-----

2 points by evanrmurphy 4859 days ago | link

Thanks for asking! It's in active development at https://github.com/evanrmurphy/SweetScript. I just added some install and run instructions so give it a go!

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! :)

-----

1 point by garply 4859 days ago | link | parent | on: Multi-arg anonymous functions broken?

It works, although I'm still not sure exactly where the _0 _1 or _a and _b components are implemented.

-----

1 point by garply 4859 days ago | link | parent | on: Multi-arg anonymous functions broken?

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!

-----

1 point by garply 4885 days ago | link | parent | on: Share your useful functions/macros

I've got an identical "rand-pos" in my code. Any opinions on which is more correct? I never know when to hyphenate.

-----

1 point by akkartik 4885 days ago | link

I think that's up to our discretion. I don't have a hyphen because it seems like a frequent token in readwarp.

-----

1 point by garply 4906 days ago | link | parent | on: Arc Conference

I would love to meet you all in person, but I'm in Asia and will be for the next few years. I'll probably only drop by SV very sporadically.

I am in favor of this type of stuff though - seems like it would be a good way to promote the community.

Speaking of remote conferencing, do we even have an IRC channel?

-----

2 points by shader 4905 days ago | link

Yes, I believe it's at irc.freenode.net #arc. Unfortunately, it's generally pretty inactive.

-----

2 points by garply 4935 days ago | link | parent | on: Extending + to do int plus list

I suggest you make this a method that only works on vector and matrix types.

-----

2 points by akkartik 4935 days ago | link

I don't follow. Excluding what? And why?

-----

2 points by rocketnia 4934 days ago | link

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.

For fun, here's an implementation. ^_^

  (def v+ (first . rest)
    (iflet (second . rest) rest
      (apply v+ (v+binary first second) rest)
      first))
  
  (def v+binary (a b)
    (err:+ "Can't " (tostring:write `(v+ ,a ,b))))
  
  (extend v+binary (a b) (and number.a number.b)
    (+ a b))
  
  (extend v+binary (n xs) (and number.n alist.xs)
    (map [v+ n _] xs))
  
  (extend v+binary (xs n) (and alist.xs number.n)
    (map [v+ _ n] xs))
  
  (extend v+binary (xs ys) (and alist.xs alist.ys
                             (is len.xs len.ys))
    (map v+ xs ys))
  
  (extend v+binary (xs ys) (and single.xs alist.ys (~single ys))
    (v+ car.xs ys))
  
  (extend v+binary (xs ys) (and alist.xs (~single xs) single.ys)
    (v+ xs car.ys))

  arc> (v+ '((1 0) (0 1)) '((2 0) (0 2)))
  ((3 0) (0 3))
  arc> (v+ 1 2 '(10 20) '(100 200) '(20) 1)
  (134 244)

-----

2 points by garply 4943 days ago | link | parent | on: How do you use arc in real world?

Hi Ali,

Thanks for pushing code to Anarki!

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.

-----

2 points by alimoeeny 4943 days ago | link

Hi There,

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.

Cheers, Ali

-----

3 points by garply 4943 days ago | link

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 :)

-----

2 points by fallintothis 4942 days ago | link

is duck typing the name? I can't remember

Hehehe. Well, it has to be something with an animal! :) I think you mean camelCase.

</useless contribution>

-----

2 points by alimoeeny 4942 days ago | link

Great,

I'll push to Anarki, I like the idea of sharing the same code pool when people are free to load a library or not.

My free time is a random variable with large variance but this seems to me a small but lively community which boosts the motivation.

Thanks for the tips, Ali

-----

2 points by akkartik 4942 days ago | link

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?

-----

2 points by garply 4942 days ago | link

aw wrote a mac named, oddly enough, "extend" which I put into extend.arc in the anarki libs.

From: http://awwx.ws/extend0

  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.

-----

2 points by akkartik 4940 days ago | link

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"

Ack, guilty as charged; I should fix that..

(update: fixed http://github.com/nex3/arc/commit/f8717f9dc3a13e4a6222120533...)

-----

2 points by rocketnia 4942 days ago | link

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?

-----

2 points by garply 4942 days ago | link

Thanks! I pushed a little bit of progress to lib/statistics.arc. I'd also like my vectors to function like lists.

  (= a (vec 1 2 3))
  type.a => 'vector
  (a 0) => 1
The list index referencing w/o first calling rep seems like it would require hacking ac.scm, right?

-----

2 points by rocketnia 4942 days ago | link

In Anarki, the hacking has already been done. ^_^

  (defcall vector (vec i)
    rep.vec.i)
The original 'defcall post is way back here: http://arclanguage.org/item?id=3743

Since then, it's been redefined in terms of [coerce _ 'fn] and an extensible implementation of 'coerce. http://arclanguage.org/item?id=9828 (Here you go, akkartik!)

Rainbow also supports 'defcall, but in the more direct way rather than through extensible coercion.

-----

1 point by garply 4942 days ago | link

This is great, thanks!

-----

1 point by alimoeeny 4941 days ago | link

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.

-----

2 points by rocketnia 4941 days ago | link

Well, what is there to summarize, hmm...

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. ^_^

-----

1 point by garply 4941 days ago | link

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.

-----

7 points by pg 4947 days ago | link

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.

-----

2 points by garply 4947 days ago | link

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.

-----

3 points by akkartik 4946 days ago | link

Yeah. I have this hazy sense that people submit lots of bug reports on this forum, but no idea if any of them are ever integrated.

-----

2 points by aw 4945 days ago | link

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".

-----

1 point by hasenj 4945 days ago | link

> I should release a new version though. News.arc is greatly improved since the last release.

Just curios, do you have a public git repo, or anything like that?

-----

1 point by bhoung 4948 days ago | link

I suppose I submitted the link to try and gauge how accurate you guys thought the comments on Reddit were.

-----

1 point by garply 4948 days ago | link

I don't think he's trying to distance himself from it, nor do I think he will shut the language down or port HN. But he's also clearly not developing it very quickly.

-----

3 points by pg 4947 days ago | link

Kind of correct. It depends on the degree to which you count news.arc as part of the language. I work quite actively on that.

-----

2 points by bhoung 4946 days ago | link

Thanks for the replies.

-----

1 point by garply 4954 days ago | link | parent | on: ~ applied to variables

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.

-----

3 points by garply 4980 days ago | link | parent | on: The use of + for non-numbers

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.

3. I'm constantly doing string concatenation. + is good for that because it's a short function name and also because I expect it to work because it works like that in many popular high-level languages (python, ruby, javascript). I also don't like to use arc's "@" for string-escaping because I find thinking about whether or not I have to escape the "@" character is distracting.

-----

3 points by waterhouse 4977 days ago | link

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.)

-----

1 point by garply 4977 days ago | link

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.

-----

1 point by prestonbriggs 4977 days ago | link

I wouldn't do anything for a speed boost at this stage. Premature optimization and all that.

Preston

-----

2 points by fallintothis 4980 days ago | link

String concatenation is particularly convenient after the + change for arc3.tar: http://arclanguage.org/item?id=9937. That's probably what I use + for most of the time.

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.

-----

2 points by garply 4979 days ago | link

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.

-----

2 points by fallintothis 4971 days ago | link

Sorry, I'm not going to be the one to write SLIME for Vim. :P I'm afraid the only "goodies" I have are highlighting-related. Off the top of my head:

- It can detect macros that take rest parameters named body, then highlight and indent them correctly.

- It uses R5RS's grammar & mz-specific extensions to highlight numbers correctly -- even weird ones, like

  #e1.5
  -nan.0+2.5i
  1/2@+inf.0
  #x8a
  #o1E+2
- It notices paren errors involving [], like

  [(+ a b])
- It highlights escape sequences in strings, like

  "\x61b \t c\u0064\n"
- It does its best to highlight ssyntax characters so they're easy to read.

You can check out more at http://arclanguage.org/item?id=10147 or http://bitbucket.org/fallintothis/arc-vim. It hasn't changed much since I first submitted it, though I've noticed it fails to highlight 0-argument function names like queue and new-fnid. Been meaning to fix that for awhile.

-----

More