Arc Forumnew | comments | leaders | submitlogin

Author here. Happy to answer any questions or comments people may have. Also will be launching an app later today, called Ohayo, which demonstrates the benefits of ETNs.
2 points by lojic 3 days ago | link | parent | on: How many people still lurk here?

True :)

I had high hopes for Arc over a decade ago, then it languished, then pg stopped participating.... then I looked at Racket (then PLT-Scheme) since that's what Arc was built on and realized Racket was the language I was looking for :)

I still pop in occasionally out of curiosity.


Thanks akkartik for updating all the tests! I'm hoping this test framework helps out.

Feel free to ping me if there are any questions, problems, or other feedback. I think the test framework is pretty solid now, in terms of features.

2 points by rocketnia 13 days ago | link | parent | on: Pursuing higher quasiquotation

I've fooled myself before, but I may have settled on the right data structure to represent higher quasiquotations.

I define the data structure three times:

- Once as a sequence of types that represent progressively higher-degree quasiquotations, which use maps to hold orphaned nodes. (https://github.com/rocketnia/lathe/blob/5375d95cb7b748972a65...)

- Once as a single type that can represent arbitrarily high degrees of quasiquotation, but in a very weakly typed way. (https://github.com/rocketnia/lathe/blob/5375d95cb7b748972a65...)

- Once as a sequence of types that represent progressively higher-degree quasiquotations, which use type families to hold orphaned nodes. This is the most strongly typed of all these representations. (https://github.com/rocketnia/lathe/blob/5375d95cb7b748972a65...)

Here's the simplest one, the one in the middle:

  data HDExpr s m
    = HDExprMedia (m (HDExprNonMedia s m))
  data HDExprNonMedia s m
    = HDExprHole s [Map s (HDExpr s m)]
    | HDExprLayer (HDExpr s m) [Map s (HDExpr s m)]
It's not very self-documenting, so to start describing it, here's a Lispier pseudocode:

  <expr> ::= <s-expression where some leaves are <paren>>
  
  <paren> ::= (close <identifier> <list of <environment of <expr>>>)
  <paren> ::= (open-and-close <expr> <list of <environment of <expr>>>)
I say "s-expression" there, but we could have any monad there for our syntax. If we work in the s-expression monad, the usual quasiquote operations ` , are parens of degree 1. When the monad we're working in is Haskell's (Writer String), our syntax is effectively reader syntax, where the ( ) parens are degree 1 and ` , are degree 2.

(There are also parens of degree 0, but they're a bit weird: Once they open, they only close again by reaching the end of the syntax. So when we're in the s-expression monad, perhaps ' is a paren of degree 0. When we're in the (Writer String) monad, perhaps pressing enter at the end of a REPL command is a paren of degree 0.)

The degree of the paren is reflected in the length of the list of environments it contains. Degree-0 parens have no environments, degree-1 parens have exactly one, and so on. If we want to represent a degree-N expression, then the parens we use are limited in a specific way:

  <expr> ::= <s-expression where some leaves are <paren>>
  
  <paren> ::=
    (close <identifier>
      <for some (M < N), an M-element list of
        <environment of <expr>>)
  <paren> ::=
    (open-and-close <expr>
      <for some (M <= N), an M-element list of
        <environment of <expr>>)>
The (open-and-close ...) syntax begins a nested expression. The environments serve to fill the holes in the <expr>, resuming the previous level of nesting. Each element of the list fills holes of a different degree. Holes of degree higher than the number of environments in the list are not filled; they remain holes. For instance, in `(a b (c d ,e) f), the "(" before "c" has two holes in its expression (",e" and ") f"), but it only fills the hole for ") f". The hole for ",e" is a higher degree than the "(" paren, so it's not filled at such a local place. It's only filled by the "`" paren on the outside.

The (close ...) syntax begins a hole of degree equal to the number of elements of the list. The list of environments will be used when the hole is replaced with an expression. It'll fill in the (low-degree) holes of that expression.

Note that the list lengths correspond with the degrees of holes, but not with the degrees of expressions. In fact, a degree-N expression does not contain any expressions of degrees other than N. If we consider ourselves to be working with higher quasiquotations of an infinite degree N, but every (close ...) actually occurring in our data has finite degree, then we can represent our data using finite lists. We never need to select a finite value for N!

---

In Haskell, the strongly typed variations I wrote do require a finite value for N to be decided beforehand (and baked into the name of the type), because I'm pretty sure that vastly simplifies the type system features I would need to use to get it to work. :-p Roughly, the difficulty is that I need 0 to give me something of kind ( * ), 1 to give me something of kind ( * -> * ), 2 to give me something of kind (( * -> * ) -> ( * -> * )), and so on, so I would need kinds that depend on values. Agda or Idris might already be up for this task, but I doubt that's going to be the kind of effort I want to spend since I intended to build my macroexpander in (untyped) Racket to begin with.

There might just be a little more I want to tinker with in Haskell, because on my way to defining this data structure I started to develop some code for "higher monads," and it would be fun if this data structure turned out to be an instance of that concept. Still, at this point I'm probably ready to go back to Racket.

I'm even hopeful again that this macro system might play nicely with Racket's. Racket has some hygiene features[1] that walk recursively over the inputs and outputs of macros, expecting them to be s-expression-shaped with no holes. I wasn't sure that Racket's technique could be reconciled with higher quasiquotation. With this data structure, the exotic nesting of higher quasiquotations is converted to the traditional kind of nesting that Racket expects.

So, this might be a usable self-contained Racket library in the end -- not even a framework but a seamless library -- which is what I want, because that would make it easy to clarify the meaning of higher quasiquotation in terms of an existing ecosystem before I use it in Cene. :)

Since this thread and my code comments contain some walls of text, I'll see if I can convert them to a blog post soon.

---

[1] In particular, Racket uses a hygiene technique where it attaches a fresh scope label to a piece of syntax before macroexpanding and then flips the presence of that scope after macroexpanding so that the scope winds up attached to only the parts of the macro result that don't come from the input (making that region more local than the rest). Racket also has a "syntax taints" feature which lets macros attach "dye packs" to their results so that the identifiers occurring in those results can't be used by a client to access private module bindings.

3 points by bvttf 16 days ago | link | parent | on: How many people still lurk here?

No, but rss
3 points by rocketnia 18 days ago | link | parent | on: Pursuing higher quasiquotation

Maybe I could actually use something like that ^ and $ syntax.

I'll need to generalize it to an infinite number of degrees:

  (     )
  ^.    $.
  ^-.   $-.
  ^--.  $--.
  ^---. $---.
Since Scheme's ,',',', technique doesn't generalize to other DSLs, I'll want to have at least one way to unquote from more than one level of nested quasiquotation at once:

  $---.
  $$---.
  $$$---.
Cene has more than one notation for doing that. (I can write a label on an outer layer, and then I can unquote all the way to a particular label.) I'd like to support various unquoting styles as macros, but maybe that macro system can expand to a notation like this, so getting this to work first seems best.

Finally, representing data structures with orphaned parts might be easy enough once I actually try using key-value tables to hold orphans like I've planned.

I think I like this approach even better than the one I reached in the blog post. It means that I actually can process an infinite number of degrees of quasiquotation "in the reader" rather than letting the top level of macroexpansion begin with an s-expression.

But I suppose this and the blog post tackle two different parts of the problem. The blog post's approach/challenges still apply to the process of parsing this syntax into an infinite-degree quasiquotation.

3 points by rocketnia 18 days ago | link | parent | on: Pursuing higher quasiquotation

No, just like you can nest parentheses without spontaneously having quasiquotation, you can nest quasiquotations like you're talking about without reaching a higher degree of quasiquotation.

Suppose we have notations like so:

  ( ) parentheses
  ` , quasiquotation
  ^ $ the next higher degree of quasiquotation
      (I would go on, but I'll run out of punctuation.)
S-expressions are bounded on both sides by single characters, and they nest within each other like this (labeling the layers as "a" and "b" and anything outside their lexical extent as "__"):

  (a (b) a) --
If we want to look at just the "b" s-expression, it's simple to write that down on its own:

  (b)
Quasiquotations are bounded on both sides by s-expressions, and they nest like this:

  `(a `(b ,(a ,(--) a) (b) b) a ,(--) a (a) a) --
The meaning of "--" in the inner expressions hasn't changed: Every "--" is outside the lexical boundary of the `(a ...) quasiquotation, just as every "a" is outside the lexical extent of the `(b ...) quasiquotation. Occurrences of "--" can appear when the lexical extent closes on an s-expression (")") or a quasiquotation (","), and both of these are shown in the example.

We can isolate the "b" part pretty easily again, but we need to allow for holes in our data structure:

  `(b ,(--) (b) b)
Quasiquotations of the next higher degree are bounded on both sides by quasiquotations, and they nest like this:

  ^`(a
      ^`(b
          $`(a
              $`(--)
              a ,(b (b) b) a ,(b) a `(a) a (a) a)
          b ,(a) b `(b) b (b) b)
      a ,(--) a `(a) a (a) a)
  --
Occurrences of "--" can appear when the lexical extent closes on an s-expression (")"), a quasiquotation (","), or a quasiquotation of the next higher degree ("$"), and all of these are shown in the example.

This time, writing down just the "b" part gets tricky using s-expression-shaped syntax because one of the holes has orphaned sections inside (holes in the hole):

  ^`(b
      $`(-- ,(b (b) b) ,(b))
      b ,(--) b `(b) b (b) b)
When we have more than one orphaned section in the same hole like we do here, we may need to use labels (or positions, or extra hole structure) to tell them apart so we can insert the "b" section into the "a" section deterministically. So far I haven't figured out how to represent this data in a way that works, let alone an elegant way.

For a concrete use case, look at it this way: When do we use ( and )? When our DSLs don't last all the way to the end of the file. When do we use ` and ,? When our DSLs have holes in them (although it might be unusual to hear this, because most Lisps couple these syntaxes together with a particular nested-list-generating DSL). When do we use ^ and $? When our DSLs have holes with holes in them. And so on, where higher degrees of quasiquotation have more and more intricate holes.

Let's say I'm writing a macro that implements a DSL where Common Lisp code and Arc code can be combined in the same function. (I'm going with Common Lisp so that we can't simply compile it to inline Racket code.) I may have Common Lisp s-expressions occurring under my Arc s-expressions and Arc s-expressions occurring under my Common Lisp s-expressions, but I want Arc variables to be visible in all the Arc parts and Common Lisp variables to be visible in all the Common Lisp parts. When we take a look at the lexical scope of any one local Common Lisp (or Arc) variable in that code, it's not simply shaped like an s-expression like traditional lexical scopes are; it has holes-with-holes wherever the Arc (respectively Common Lisp) expressions occur. So ^ and $ are a natural fit for the DSL:

  (def three ()
    (arc-in-common-lisp
      ^`(let ((common-lisp-var 1))
          $`(let arc-var 2
              (+ ,common-lisp-var arc-var)))))
4 points by conanite 20 days ago | link | parent | on: Pursuing higher quasiquotation

Is a higher quasiquotation like a nested macro? A macro that generates macros? Like (made-up example) ...

    (mac metamac (opname op)
      `(mac ,opname (name n)
         `(mac ,name (x)
            `(',',,op ,,n ,x))))

    (metamac multiplier *) ;; defines a macro called multiplier

    (multiplier times-five 5) ;; defines a macro called times-five

    (times-five 3) ;; expands to (* 5 3)
Or something else?
3 points by breck 21 days ago | link | parent | on: How many people still lurk here?

hello
4 points by rocketnia 21 days ago | link | parent | on: Pursuing higher quasiquotation

To summarize this post, I'm trying to generalize macros and quasiquotation in several ways all at once, but most of the hard problems I'm encountering center on an idea I call "higher quasiquotation":

- A quasiquotation is data shaped like an s-expression with s-expression-shaped holes.

- A quasiquotation of higher degree is data shaped like a quasiquotation with quasiquotation-shaped holes.

I already want to define macros whose bodies are not s-expressions but quasiquotations, so I already want to move up one degree on this progression. To make sure this design is correct, I want it to work even if I move up an arbitrary number of degrees. If it works, I expect one macro system to work for quasiquotation macros, regular macros, and reader macros, all in the same generalized way.

But... it's not working yet. :)

3 points by hjek 22 days ago | link | parent | on: How many people still lurk here?

Yo!

Looking forward to hearing more about the development of the macro system!
3 points by mpr 26 days ago | link | parent | on: How many people still lurk here?

Hello! I come around every few weeks to see what's up.

I meant to submit this post when I first saw it, but forgot :)

Quite a while ago I silently made the decision to keep my opinions on language design to myself most of the time unless I had a language to show for it. :) Cene has come further along than any language I've made before. Part of that is because I learned some skills at work, and part of that is because I didn't want to bring it here until it was in a very polished state.

Cene has currently stalled a bit as I try to generalize the macro system to support quasiquotation macros, reader macros, and better error messages. This post touches on that topic a bit, particularly the error message part. In the 16 days since this post, I've tried to work on an implementation of this new macro system. My initial attempts were full of errors, and as I keep trying to organize my thoughts, I've learned a lot about Racket macros and category theory, but I still haven't found a way to implement the macro system. In a couple of days I'm planning to write another post about where I've gotten with that and what the difficulties are.

4 points by waterhouse 29 days ago | link | parent | on: How many people still lurk here?

Hello there.

(This experiment also serves as a sample of how regularly the lurkers lurk.)

4 points by ymln 30 days ago | link | parent | on: How many people still lurk here?

Hi!
3 points by jsgrahamus 30 days ago | link | parent | on: Nice work, malisper!

http://arclanguage.org/item?id=20096
3 points by jsgrahamus 30 days ago | link | parent | on: Nice work, malisper!

Well, that is certainly true; although I was surprised at the recent post where all those other folks showed up.
2 points by akkartik 30 days ago | link | parent | on: Nice work, malisper!

I don't think we can :) This forum seems slow enough that I figured we had time to discuss something off-topic.
2 points by jsgrahamus 31 days ago | link | parent | on: Nice work, malisper!

Where does Arc get into a bind? No idea here.
3 points by jsgrahamus 31 days ago | link | parent | on: Nice work, malisper!

Makes sense. Thanks for the read.

How can we apply this to Arc, akkartik?

6 points by malisper 31 days ago | link | parent | on: How many people still lurk here?

I check if there is anything interesting here once every few days.
3 points by akkartik 32 days ago | link | parent | on: At-sign in string

Yes, the atstrings feature is turned off by default in Arc 3.1 (and also in Anarki's official/stable branches). I think I'll turn off the default in Anarki as well, and just let news.arc continue to make use of it.

Edit 1 hour later: This is now done. Turns out Anarki never meant to turn on atstrings by default. This was a side effect of loading news.arc by default (mea culpa). I've changed things so we load news.arc by default but only use atstrings in news.arc by default. Keep an eye out for subtle bugs introduced by atstrings being turned off when functions in news.arc are called. If we see any I'll probably take out the ability to turn it on and off and just decide to keep it everywhere or take it out entirely.

https://github.com/arclanguage/anarki/commit/d0eb0dcf17

6 points by jsgrahamus 32 days ago | link | parent | on: How many people still lurk here?

Me, too.
3 points by jsgrahamus 32 days ago | link | parent | on: At-sign in string

When I try this in Arc 3.1, I get no complaints.
5 points by akkartik 33 days ago | link | parent | on: How many people still lurk here?

Great idea, mikhail. Thanks for doing this. I now know of two readers that I wasn't at all aware of before! ^_^
5 points by nathanielrb 33 days ago | link | parent | on: How many people still lurk here?

hi!
5 points by zck 33 days ago | link | parent | on: How many people still lurk here?

I, too, am around.
6 points by prestonbriggs 34 days ago | link | parent | on: Operating Systems

I know of 2 examples of Lisp being used to develop an OS (there may be more): one by Symbolics (called Genera) and the other by Lisp Machine Inc (aka LMI). Apparently both of these descended from code developed at MIT's AI Lab. Googling, it sounds like some of the source code for one of the versions was released as open source.

Of course, Lisp Machine Lisp (or Zeta Lisp, et al.) are not the same as Arc, but I expect that what you can do in one, you can do in the other. Small matter of programming :-)

The interesting question is not the implementation language, but what you intend to build.

More