Cone Language Reference

Recipes: solutions to problems you will run into

Each part before this one teaches one side of Cone: the Guide the language itself, then memory, concurrency, modularity and safety. Some problems belong to none of them. They are the ones you run into while building something real, and want a coding solution for: a value there can only be one of, a type of yours that should work like a built-in one, a match whose cases no literal can say. This part gathers those. Each recipe opens on its problem, shows the technique that solves it with a program that runs, and then gives the complete rules, drawing on whatever earlier parts it needs and linking to them. Read them in any order.

  • Method patterns: what a struct can become: making a struct behave like a built-in type, with operators, properties, indexing, being called like a function, init and final, and being walked by each.
  • Moves: values there can only be one of: which types move, what a move leaves behind, handing a value on and getting it back, and getting one out of a struct, an array or a reference.
  • with blocks: working on one value: a block focused on one value, reading it or changing it through a reference, without its name on every line.
  • Patterns of your own: using: any ordinary function as a case of a match, with the full rules, a parser written that way, how a match is compiled, and keeping the matched value.
  • Generators: writing your own: a sequence written as the loop or the recursion that makes it, as a function or a method, generic or not, and what it may hold across a yield.

The first recipe is for a wish most programs meet early: a type of your own that works like a built-in one.