The language

      .ooo
     'OOOo
 ~ p ooOOOo tion ~
     .OOO
      oO      %% a little
        Oo    fast language.
       'O
        `
       (o)
   ___/ /          
  /`    \ 
 /v^  `  ,
(...v/v^/
 \../::/
  \/::/

~ Potion! ~

Potion is an object- and mixin-oriented (traits) language.

Its exciting points are:

However, some warnings:

~ a whiff of potion ~

5 times: "Odelay!" print.

Or,

add = (x, y): x + y.
add(2, 4) string print

Or,

hello =
  "(x): ('hello ', x) print." eval
hello ('world')

~ how it transpired ~

This isn't supposed to happen!

I started playing with Lua's internals and reading stuff by Ian Piumarta and Nicolas Cannasse. And I, well... I don't know how this happened!

Turns out making a language is a lovely old time, you should try it. If you keep it small, fit the VM and the parser and the stdlib all into 10k lines, then it's no sweat.

To be fair, I'd been tinkering with the parser for years, though.

~ the potion pledge ~

EVERYTHING IS AN OBJECT. However, OBJECTS AREN'T EVERYTHING.

(And, incidentally, everything is a function.)

~ items to understand ~

  1. A traditional object is a tuple of data and methods: (D, M).

    D is kept in the object itself. M is kept in classes.

  2. In Potion, objects are just D.

  3. Every object has an M.

  4. But M can be altered, swapped, added to, removed from, whatever.

  5. Objects do not have classes. The M is a mixin, a collection of methods.

    Example: all strings have a "length" method. This method comes with Potion. It's in the String mixin.

  6. You can swap out mixins for the span of a single source file.

    Example: you could give all strings a "backwards" method. But just for the code inside your test.pn script.

  7. You can re-mix for the span of a single closure.

To sum up:

EVERYTHING IS AN OBJECT. EVEN MIXINS ARE OBJECTS. AND, OF COURSE, CLOSURES ARE OBJECTS.

However, OBJECTS AREN'T EVERYTHING. THEY ARE USELESS WITHOUT MIXINS.

~ unique ideas (to be implemented) ~

Potion does have a few unique features underway.

~ feverish and fond thankyous ~

I am gravely indebted to Basile Starynkevitch, who fielded my questions about his garbage collector. I favor French hackers to an extreme (Xavier Leroy, Nicolas Cannasse, Guy Decoux, Mathieu Bochard to name only a portion of those I admire) and am very glad to represent their influence in Potion's garbage collector.

Matz, for answering my questions about conservative GC and for encouraging me so much. Potion's stack scanning code and some of the object model come from Ruby.

Steve Dekorte for the Io language, libgarbagecollector and libcoroutine -- I referred frequently to all of them in sorting out what I wanted.

Of course, Mauricio Fernandez for his inspiring programming journal housed at eigenclass.org/R2/ and for works derived throughout the course of it -- extprot most of all. Many of my thoughts about language internals (object repr, GC, etc.) are informed by him.

Ian Piumarta for peg/leg. I use a re-entrant custom version of it, but the original library is sheer minimalist parsing amazement.

Final appreciations to Jonathan Wright and William Morgan who pitched in, back in the wee hours of Potion's history. Tanks.

~ license ~

See COPYING for legal information. It's an MIT license, which lets you do anything you want with this. I'm hoping that makes it very nice for folks who want to embed a little Potion in their app!