Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Ferret scripting language
OCaml VimL
tree: a9c5d09576

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
demo
pkg/std
share/vim
.gitignore
LICENSE.txt
Makefile
README.md
atom.ml
cell.ml
compile.ml
core.ml
debug.ml
fixnum.ml
interp.ml
lexer.mll
main.ml
mvar.ml
parser.mly
parser.output
prims.ml
process.ml
range.ml
repl.ml
slice.ml
state.ml
term.ml
test.fc
vector.ml

README.md

Ferret

Ferret is an interpreted (bytecode compiled), functional scripting language implemented in Ocaml. It had roots in Go, REBOL, and various functional languages. It has the following characteristics:

  • Very small and fast
  • Simple syntax and rules
  • Functional
  • Garbage collected
  • Lightweight processes
  • Inter-process communication via channels
  • Lexical scoping and block closures
  • List comprehensions
  • Prototype objects
  • Simple package system

Ferret was designed to be a language that was quick to throw something together in order to solve internet problems. For this reason, it has many features to assist with crypto, sockets, email, HTTP, FTP, parsing, etc.

The source code for Ferret is freely available on GitHub and is under the Apache 2.0 License.

Quickstart

Here's a quick, obligatory sample of what idiomatic Ferret looks like:

package cards

;; define a deck of cards
let pips = [2,3,4,5,6,7,8,9,10,11,12,13,14]
let suits = [Clubs,Diamonds,Hearts,Spades]
let deck = for p,s in pips,suits do (p,s)

;; create a dealer process
let dealer () =
    let ch = chan() in
    fork {
        for card in lists:shuffle(deck) do card -> ch
    },
    ch

;; request 5 cards from the dealer
let hand ch = for _ in 1 to 5 do (<- ch)

;; create a new dealer and ask for 5 hands of cards
let main () = let ch = dealer() in for _ in 1 to 5 do hand(ch)

What is there to discern from this little bit of sample code?

Every file is a package. This declaration must come first. It can be any valid identifier, but cannot replace an already existing package. All packages live in a flat namespace (there is no hierarchy of packages).

Words are declared with the let keyword. If there are no formal parameters to the word, then it is evaluated at compile-time and is a constant. Otherwise it is a function. If you want to declare a function that takes no parameters, it should take a single formal: the unit value ().

List comprehensions are done with the for keyword. Each word is bound to a range and the do form is evaluated for each iteration. Lists and strings are implicit ranges, while integer ranges can be created using the to or downto operators.

let 
Something went wrong with that request. Please try again.