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

"Or just use Factor. :)"

I love how I could switch programming models for the one line in this example where it made sense: http://rosettacode.org/wiki/Rot-13#Wart

-----


Yeah, if I had to choose one axis over the other I'd rather have multiple functions than multiple arguments.

Here's the current varargs version of -> in wart:

  mac (transform x ... fs|thru)
    if no.fs
      x
      `(transform (,x -> ,car.fs) ,@cdr.fs)
Now you can call it like this:

  (transform 3 :thru (fn(_) (_ * 2))
                     (fn(_) (_ + 1)))
I think I'd support multiple args by using :thru as a delimiter:

  (transform 1 2 :thru (fn(a b) (a * b))
                       (fn(_) (_ + 1)))
But really, there's no need:

  (transform 1*2 :thru (fn(_) (_ + 1)))

-----

2 points by akkartik 4624 days ago | link | parent | on: Code golf with many Arc solutions

Thanks. On a related note, I've been having fun populating the Rosetta Code page for wart: http://rosettacode.org/wiki/Category:Wart. After seeing this I just realized that arc has no representation at all!

-----


Most promising! I'll need some time to play with this.

-----

2 points by akkartik 4626 days ago | link | parent | on: Improved plural, pluralize

"Is there a use case where you're not aware of the exception when calling the function?"

Any situation where the string being pluralized is not a literal. This is I suppose why rails pluralization doesn't work like this.

-----

2 points by zck 4625 days ago | link

Oh. Duh.

-----

1 point by akkartik 4627 days ago | link | parent | on: Nock: An alternative to lambda calculus

See also the discussion on HN: https://news.ycombinator.com/item?id=6438320

Especially why lisp failed: https://news.ycombinator.com/item?id=6441036

Equivalent of arc.arc: https://github.com/urbit/urbit/blob/master/urb/zod/arvo/hoon...

-----


http://arclanguage.github.io/ref/threading.html

You could sleep and periodically wake up to check if all the threads are dead.

  (def wait-for threads
    (while (~all t (map dead threads))
      (sleep 1)))

  arc> (do (wait-for (thread:do sleep.1 prn.1)
                     (thread:do sleep.2 prn.2)
                     (thread:do sleep.3 prn.3))
           (prn "Done!"))
  1
  2
  3
  Done!
  arc>

-----

3 points by fallintothis 4629 days ago | link

Slick! But just to play human lint tool:

  (~all t (map dead threads))
is the same as

  (~all dead threads)
and

  (while (~all dead threads)
    (sleep 1))
is the same as

  (until (all dead threads)
    (sleep 1))
which may read slightly better.

-----

2 points by akkartik 4629 days ago | link

Thanks! So weird that I missed that, especially the first.

-----

2 points by lark 4629 days ago | link

Thanks.

Shouldn't Arc provide something like pthread_join? A function that wakes up the thread that waits -- rather than continually checking for all threads to exit?

-----

2 points by akkartik 4628 days ago | link

I see racket does provide thread-wait:

http://docs.racket-lang.org/reference/threads.html#%28part._...

Should be easy to add to arc. Can you submit a pull request if you do so?

-----

3 points by lark 4623 days ago | link

Thanks so much for the link, that was it.

  $ diff -prauN ac.scm ac.scm.wait 
  --- ac.scm	2013-09-28 10:04:00.907266192 -0400
  +++ ac.scm.wait	2013-09-28 10:03:55.811266793 -0400
  @@ -1035,6 +1035,7 @@
   (xdef new-thread thread)
   (xdef kill-thread kill-thread)
   (xdef break-thread break-thread)
  +(xdef wait-thread thread-wait)
   (xdef current-thread current-thread)
   
   (define (wrapnil f) (lambda args (apply f args) 'nil))
And an example using wait-thread:

  (def th-test() ; how to use wait-thread                                              
    (withs (counter 0 allthreads nil)
           (while (< counter 4)
                  (withs (this nil localcnt counter)
                         (= this (thread (do (prn "thread " localcnt)
                                             (sleep 2))))
                         (push this allthreads))
                  (++ counter))
           (each th allthreads
                 (withs (thisthread nil)
                        (= thisthread (wait-thread th))
                        (prn "thread " thisthread " finished")))))

-----

2 points by akkartik 4623 days ago | link

Just tried your example. Nice!

-----


Can you try it with http://github.com/arclanguage/anarki if you aren't already? Your ascript.js example works with it for me.

To make the .lsp example work you have to modify static-filetype at lib/srv.arc (https://github.com/arclanguage/anarki/blob/31b773d91a/lib/sr...) to handle the new extension. I'm away from my usual machine, so can you send me a pull request if you get it working? :)

-----


PG has said he's still working on it, but you probably shouldn't rely on seeing further updates from him.

The community here makes updates from time to time, and I think we're pretty responsive to questions and bug reports. But our changes are not 'blessed' by PG or anything. Since PG has said that "future releases can break anything", such a blessing wouldn't be of much use anyway.

Bottomline: It's not for you if you just want features and don't care how they're built. But if you like the idea of gradually mastering the internals of the tools you rely on -- welcome aboard! You don't have to know anything at the start; we try to be very helpful.

(New version of http://arclanguage.org/item?id=17869)

-----

2 points by jsgrahamus 4636 days ago | link

For a perpetual newbie in Lisp/Scheme/etc, they have been very helpful to me.

-----

1 point by hk_mars 4623 days ago | link

I would also design a hackable lang. in the very-soon future. Now I have to work and live. hayhay... I like Paul. :)

-----

1 point by akkartik 4635 days ago | link

I should add a link to the community-managed version: http://github.com/arclanguage/anarki#readme

-----

1 point by akkartik 4639 days ago | link | parent | on: When I type 'mzscheme -m -f as.scm'

Yeah, I think the '-m' flag was deleted sometime after v372.

-----

3 points by rocketnia 4639 days ago | link

Here's a comment I made in an earlier thread (http://www.arclanguage.org/item?id=14747):

The -m option means to call the "main" function now. Just leave it out. It used to mean "--mute-banner", which suppressed the "Welcome to MzScheme" line.

-----

More