Atomo v0.4 Release Notes
Language Design Features
Tuples & Variadic Roles
Tuples are "temporary" groupings of arbitary data. They are similar to lists, but do much less, as they are meant to be gone as soon as they're used; they're not for persistent data.
Example:
> () () > ($a, 1) ($a, 1)
Their primary application is variadic roles, where they can be used to send along zero or more than one values (sending one value is done by just using the value itself; there is no one-element tuple).
As you can see, they are converted to lists on the receiving end. You can't do much with tuples themselves (except for pattern-match them), but converting to a list is trivial (and fast).
Optional Roles
Methods can now be defined with optional roles, which can be overridden by the sender. A default must be specified.
Example:
> foo: x &bar: 2 := [x, bar] @ok > foo: 1 [1, 2] > foo: 1 &bar: 3 [1, 3]
Default values are actually arbitrary expressions that will be evaluated with the bindings from the other patterns.
As you can see, we're using & at the start of a keyword role for optionals syntax. A non-keyword name can be used like a flag, e.g. 1 foo &bar, which is equivalent to 1 foo &bar: True.
Macro-Quotes
Macro Quotes provide a generalized string quotation mechanism, allowing arbitrary literal values to be created by the user. At macroexpansion time, they trigger a message sent to the Macro Environment, where a user-defined method determines what they expand to.
Example:
> w{foo bar baz} -- word list ["foo", "bar", "baz"] > raw"foo\nbar 'baz'" -- raw string "foo\\nbar 'baz'" > r"(\d+)" -- regexp literal r{(\d+)}
The application for these is already far-reaching, fostering the new regular expression and string formatting features listed below. In the future they may be used for things like URL literals, byte strings, paths, and more.
New Features
The following are new features added to the standard library, or implementation-level additions and goodies.
PCRE-style regular expressions. Regexp literals can be created with the
rmacro-quoter. See Regular Expressions,A new String Formatting system has been custom-built for Atomo, modeled on Common Lisp's
FORMATfunction, withprintf-like syntax. Thefmacro-quoter is used to parse these intoFormatters at macroexpansion time.Class Objects, providing
module,include, andclassfunctionality similar to Ruby.Particles can now have the first role filled in. Accordingly, a
completemethod was added, which is justcomplete: ().A new Pretty-Printing system.
Added
set!:andset!:to:for explicitly updating a slot rather than defining one.Added
has-slot?:for determining if an object has a given slot defined on it directly.wandrawmacro-quoters, for word lists and raw strings, respectively.Example:
> w{foo bar baz} ["foo", "bar", "baz"] > raw'hello\nworld, I\'m pretty \'\r\a\w\'.' "hello\\nworld, I'm pretty '\\r\\a\\w'."
A new, better, faster lexer and parser.
TextMate/Sublime Text 2 editor stuff is now included in
etc/.The REPL now intelligently accepts multiline input.
Many other little methods, some not yet documented.
Changes
The following is a list of major changes in this version which are backwards-incompatible.
Defining and dispatching now only uses the first role as the target. Pattern-matching provides the rest of the "multiple dispatch."
Countless documentation updates and additions.
Linebreaks and other special characters are now accepted in string literals.
Implicit gensyms now use
!rather than#as a prefix.Condition handlers are now properly removed from the stack to prevent a handler from handling itself.
Many methods, including
call:, now use tuples rather than lists to provide multiple arguments.A few methods, notably
zip:, now use optional roles.zip:now returns a list of lists and accepts multiple lists to zip with.join:now searches the block's context before the target's delegates.responds-to?:now accepts a less-complete particle, and does partial matching based on which roles are filled and not filled.Example:
> 1 responds-to?: @+ True > 1 responds-to?: @(+ "foo") False
<<and>>operators are now macros intended for destructive update.Block repeatandBlock repeat: Integernow call the block in-context.Pattern match: _now yields@noneor@okrather than@noor@yes:.Charis nowCharacter.File and directory I/O methods now check that the file/directory exists, etc., to prevent hard crashes.
The Atomo library is not installed by default; use
-flib.Many internal cleanups and fixes.
The Raw Log
The most recent changes are at the top:
* updated string formatting docs * providing both `<` and `>` flags to a justifier now implies `=` * allow `<`, `>`, and `=` flags in justification formatter, which are like `:`, `@`, and `:@` from FORMAT. closes #42. * cleanups * allow &foo to mean &foo: True. closes #44. * added `raw` macro-quoter. closes #43. * include range docs * added Range docs and updated List docs. closes #10. * added Ordered docs. closes #25. * rename @begin to @start in Range * more efficient/simpler @shift: for Ordered * a bunch of Range corrections * formatting docs updates * added initial string formatting docs. closes #37. * removed ePretty field of EVM record * promoted @match: to a first-class expression * expand a macro body's gensyms beforehand * updated class-object docs and ruby tutorial * expand through quasiquotes, and corrected !bang decorating * added @pretty-expression * added Valuable Prettied instance * corrected exporting of various condition methods * class-object documentation updates * @class: now uses an optional for extending a given object (defaults to Object) * optionals roles with macros. closes #40. * Added initial class-objects system documentation. Closes #9. * provide a @pretty method for class-objects created with @(class: Dispatch) * @module: macro now expands to @ok * Char -> Character. Closes #39. * pretty-printing docs. closes #7. * updated sync-docs script * pattern object docs. closes #16. * conversion to patterns is now called @to: rather than @as: to indicate the possibility of failure * updated ruby tutorial * added REPL docs. closes #22. * minor cleanups * added Regexp docs * ruby.atomo -> ruby.anatomy * minor cleanups * TM lexer: rationals support * .atomo -> .anatomy * Formatting -> Formatter * list formatting modules in cabal file * corrected @\ macro; first role doesn't have to be a dispatch * added @\ macro for parentheses-free message chaining * finished pretty-printing for AtomoError. closes #15. * suppress orphan instance warning in Atomo.Pretty * minor tweak * corrected iterating with * using all inputs rather than the rest, and added breaking from a sublist iteration via %.^. closes #38. * added @replace:with: and @replace-all:with:. closes #3. * rename sublime text/textmate folder * added textmate/sublime text stuff to etc/ * tabs -> spaces * added initial formatting tests * corrected . flag for iteration (sublists) * capitalizing formatter now lowercases the rest of the word * give a better error in `i2d` * minor cleanups * properly parse hex as %x rather than %h * use a custom int-to-digit that goes up to Z * corrected handler popping * handlers are popped from the stack as they're called to ensure they don't handle their own handlers * corrected @(Simple-Error pretty) and @(Simple-Warning pretty) * added disabled error debugging helper * updated tests for new @zip: behaviour * SInteger -> SDecimal * capitalize now takes a number for how many words to capitalize * formatter cleanups * load comparable prelude a bit sooner * initial string formatting system * added @(String plural) * more general parser types in Atomo.Lexer.Base * use a Prettied alias for the Pretty class (for Doc), added Typeable instance * corrected regexps in @case-of: not introducing bindings * remove -funfolding-use-threshold flag * cleaner regexp compilation failures. closes #36. * added prettyFrom for PEForMacro and PEMacroQuote * use a custom eof that pretty-prints the token rather than `show's it * allow linebreaks and other characters in string literals * use findString before fromString in a few places * improved parse error describing * cleaned up macro-quote docs * replaced @show definitions with @pretty, removed @show for True/False * improved parse error pretty-printing * updated syntax docs; split it up into three additional documents: Patterns, Defining Methods, and Macros! * magic quotes -> macro-quotes * added PEForMacro and PEMagicQuote patterns * more complete Eq instances for Pattern and Expr * inserting methods ignores optionals when checking message pattern equivalence; also added manual Eq instances for Message and Option * added macro-quote docs. closes #5. * tweaked operator syntax docs * Regexp values now pretty-print as a macro-quote * corrected unknown quoter error * ignore ?<= and ?<! when looking for named bindings * tuples documentation fix * tuples documentation. closes #4. * define @(Pretty pretty) rather than @(Pretty show) * updated Getting Started to explain how methods are defined and found. closes #8. * added @case-of: docs. closes #12. * @case-of: - _ as a test acts as a wildcard; no matches now yields @ok; moved to comparable prelude * corrected @regexp?: to return False for other types * moved @case-of: to core prelude, corrected debug printing * document ! gensym mechanism. closes #32. * added @set!: and @set!:to: docs, removed contracts from @= and @:= docs. closes #20. * added @set-slot:to:, @set!:to: now takes a String rather than a Pattern * added @with-restarts:bind: docs. closes #23. * updated @catch: docs. closes #24. * updated @(Block repeat: Integer) docs, relocated to Block section (and the method definition as well) * @(Assocation == Association) docs. closes #30. * updated @responds-to?: docs. closes #31. * added @(has-slot?: String) docs. closes #21. * relocated @id docs * @(List to: String) documentation. closes #26. * updated particle docs. closes #11. * added @id documentation. closes #13. * updated docs for variadic roles, cleaned up one bit in continuation docs. closes #18. * updated @>> and @<< docs, added @push: and @cons: docs. closes #29. * updated @zip: documentation. closes #14. * updated repository location in docs. closes #19. * allow reserved words in particles/dispatch chains * a more general `continue' * added some helper functions for lexing * @(File new: String) - only check if the file exists if they're opening in @read more * moved prettyVM to Atomo.Helpers * version bump to 0.4 * removed @(Expression pretty) * rollback pcre packaging * experimental: package pcre 8.12 with atomo * added trivial @id method, just yields the object it's sent to * corrected pretty-printing of a single particle with optionals * @zip: now takes a variadic role, for zipping multiple lists. now returns a list of lists rather than a list of Associations. * removed PrettyVM module * added @(Tuple pretty) * added creating a list from a tuple via varargs * updated benchmark tests * added regexp example * pretty-printing tweaks * added an interface for Text.PrettyPrint, @show now uses @pretty. closes #2. * only define and dispatch on the first role * minor cleanups * minor cleanup * merge lIdentifier and lMagicQuote so `try' isn't needed * allow magic quotes to span multiple lines * added @contents and @flags for magic-quote expressions * added w magic-quoter, for creating word lists * added DidNotUnderstand error pretty-printing * allow more reserved punctuation for magic quotes, no longer allow / and < * added @name for getting a magic quote's name * correct EMagicQuote evaluation * corrected regexp check in @case-of?: * just use a tuple for making a Match expression * Atomo.Pretty cleanups * removed regexp literals in favor of a generalized magic-quoting mechanism * added @(Regexp new: String &flags: String) * @(Regexp match: String) now returns a RegexpBindings object; remember the regexp's named captures for this * allow fully-completed particles (i.e. with a filled first role) * @case-of: with a regexp evaluates the branch with the bindings * initial regular expressions work, added a prettier Show Value instance, and other minor cleanups in Atomo.Types * added equality test for Pattern values * pretty-printer cleanups * corrected `head' crash when lexing an unmatched closing punctuation * @(Pattern match: _) now returns @none or @ok: rather than @no or @yes: * added `findTuple' * up is low, low is up * cleanups and completeness * target for variable role is Object * corrected @spawn: usage to use variable role, @call/cc: now uses variable role * use variable roles for @call:, @spawn:, @join:with:, @do:with:, @restart:with:, @(Restart jump: _) * tuples and variable-length arguments * added flag for installing atomo library, off by default * updated rectangle example * updated monad example * updated exceptions example * updated coroutine example * corrected @set!:to: to use recursion rather than just go one level deep * skip whitespace at the start of lexing * updated generator example * added @set!: and @(target set!: Particle to: value) for overwriting (not adding) a definition * added @(has-slot?: String) for checking if an object has a slot defined on it (and not its delegates) * added @(Port buffering) and @(Port set-buffering: Particle) * @(Block repeat) now calls the block in its context * multiline REPL input * added @with-restarts:bind: macro * cleaned up unmatched paren/brace/bracket error in the lexer * more robust parse error values * @catch: now accepts any object as its second role (e.g. a particle) * cleanups * allow more precise definitions of @shift: for e.g. doubles and rationals * ordering -> ordered * tweaked Ordered module * added Ordering module, include on ordered primitives to provide @to:by:, @up-to:, and @down-to: * added @case-of:, which does a match based on @matches?: * added Enumerable and Range, which replaces @.. and @... * add class-objects to the prelude * @to-string -> @(to: String) * added spaceship operator, @sort and @sort-by: use it by default (&comparison: optional), @sort-by: now does something closer to what its name suggests * added @(Expression optionals), and creating dispatch expressions with optionals * search outer scope before an object's delegates in @join: * more optional arguments use (@center:, @left-justify:, @right-justify:) + some cleanups * use an optional argument for @zip: * @(Block repeat: Integer) now calls the block in-context * use optional argument for port mode * parser cleanups, plus some clearer parser errors in two cases * @<< and @>> are now macros which update the target * added a quick particles + optionals test * corrected @(Particle show) on keyword particles * added @(Association == Association) * added @(Message optionals) * improved particle completion (now completes optionals) * particle pretty-printing now includes optionals * added @(Particle optionals) * corrected expansion and parsing of particles with blank optionals * added Valuable instances for (x, y) (as Association) and Maybe a (as @ok:/@none) * @responds-to?: now accepts particles missing more than one value; uses a fuzzy match, where only filled-in values are checked as the roles * slight wording tweak in optionals tests * removed superfluous parentheses * added some optionals tests * corrected single dispatch in a keyword role getting its optionals overridden * parse singles with optionals in cSingle, as (foo &bar: 2) * minor cleanups * corrected a keyword dispatch's optionals being eaten by a single-dispatch role * corrected particle expression evaluation to retain the (evaluated) optionals * pretty-print optionals * corrected particle expansion eating its optionals * parse single dispatch with optionals * added some file/directory-exists checks to a bunch of methods * parser simplification * some optionals cleanups and small optimizations * re-implemented automatic gensyms * shiny new parser (+ lexer), and initial work on optional arguments * catch infinite error loops * replace Particle data type with an alias to Message (Maybe v) * good ol' manual labour * rollback darcs replace job * added @(Expression pretty) and @(Expression location) * move PExpr up with the normal fellas * corrected a few expr patterns from the last batch replace * cleanups; all Expr constructors now start with E, plus improved haddock * ruby tutorial updates * added Ruby in Atomo macro tutorial * added boringfile * documentation corrections * use ! rather than # for gensyms in quasiquotes * corrected pretty-printing of particular object definition patterns