Arc Forumnew | comments | leaders | submit | shawn's commentslogin
4 points by shawn 13 days ago | link | parent | on: Lexically scoped macros?

Actually, here's an Arc solution.

When I implemented Arc in Lumen (more info on Lumen: http://arclanguage.org/item?id=20935), this technique was ported over naturally. You can play with it here:

  git clone https://github.com/lumen-language/lumen
  git checkout 2018-10-29/arc
  npm i
  rlwrap bin/lumen-node # rlwrap is optional
  > (load "arc.l")
  function
  > (mac awhen (cond . body)
      `(let it ,cond
         (when it ,@body)))
  > (awhen 'hi (print it))
  hi
  > (awhen nil (print 'hi))
  > (awhen 1 (print it))
  1
  > (awhen 1 (print it)
      (let-macro ((awhen (cond . body)
                    `(let it ,cond
                        (unless it ,@body))))
        (awhen false (print it)))
      (awhen 42 (print it)))
  1
  false
  42
  >
It's not quite a complete port, but it's pretty close. It also runs on node, so you can use any npm library in Arc.

reply

3 points by shawn 13 days ago | link | parent | on: Lexically scoped macros?

Yes, Lumen has this. https://docs.ycombinator.lol/tutorial/macros

https://imgur.com/a/CUccgz1

  (define-macro when (condition rest: body)
    `(if ,condition (do ,@body)))
  (when true
    (list 42
    (let-macro ((when (condition rest: body)
                  `(if (not ,condition) (do ,@body))))
      (when false
        21))
     (when true
       21)))

This gives a list of '(42 21 21).

If there is interest, I can port the technique to arc3.2 and let the community take it from there. We're using arc3.2 over at https://www.laarc.io

https://github.com/shawwn/arc3.2/tree/ln

reply

4 points by shawn 29 days ago | link | parent | on: Arc REPL in emacs using cider-mode

There's no audio, so it's probably a bit hard to follow. I just wanted to throw together a quick demo of the Arc tooling I've been working on.

I implemented the nREPL protocol in Arc. This video shows cider-mode interacting with it (via `cider-connect`).

reply

5 points by akkartik 29 days ago | link

Looks wonderful! Thanks for exposing me to some new keywords ("nrepl", "cider-mode")

reply

5 points by i4cu 29 days ago | link

For anyone else who might be interested:

nRepl https://github.com/nrepl/nrepl

Cider https://docs.cider.mx/en/latest/

Cider-nRepl https://github.com/clojure-emacs/cider-nrepl

reply

4 points by i4cu 29 days ago | link

> There's no audio

There's awesome audio... I watched it a second time just for the audio!

reply

2 points by i4cu 29 days ago | link

> I just wanted to throw together a quick demo of the Arc tooling I've been working on.

To what end, might I ask? i.e. are you planning to contribute this to the arc community? Is this something the community can leverage with their own tooling?

I could have other questions, but if it's not something I can use or look at then they become somewhat pointless (the questions, that is).

reply


You can visit http://arclanguage.org/unban to unban yourself once. A little easter egg pg left.

-----

4 points by shawn 76 days ago | link | parent | on: Inline JavaScript

No such thing as necroing here. Post more Arc updates!

I'm thinking of starting a Discord server for Arc to give us a place to hang out.

-----

4 points by shawn 76 days ago | link | parent | on: Hook

Yes, the hooks exist because there was a lot of custom code that had to be injected somewhere. Much of HN's source code was not suitable for public release, even back in 2008.

Suppose you had to maintain an open source version of a codebase with closed-source elements. The hook functions here are the perfect way to do this.

For example, you'll notice pg does not appear on https://news.ycombinator.com/leaders (and never has). The logic to filter his username must exist somewhere. It likely existed as a hook.

-----

3 points by i4cu 71 days ago | link

I've found the 'hook' mechanism to be really useful. I use the same thing in an app I'm writing (in cljs) which auto creates web applications via data schematics.

When my app compiles a new app there's a little routine that adds/removes pre-defined function calls from within a table. So then when cljs compiles the client side code (which performs dead code elimination) the functions that are hooked into the table get added, but the others are eliminated. The cljs dead code elimination process couldn't do this alone; it required being able to hook/unhook code depending upon the app schematic.

Anyways, just wanted add to your point on how useful this feature can be.

-----

2 points by shawn 71 days ago | link

Correction: the reason pg doesn't show up on the leaderboard is that he's an admin, and admins are filtered out here: https://github.com/arclanguage/anarki/blob/f01d3f9c661eed055...

Poor example notwithstanding, the rest of my comment is probably correct. There was custom code that couldn't be shipped in the public release of news.arc.

-----

5 points by shawn 77 days ago | link | parent | on: Tell Arc: Arc 3.2

Here's the full diff: https://arc32diff.now.sh/

-----