Rhine Overview of Rhine - Lisp style language - Automatic type - - PowerPoint PPT Presentation

rhine overview of rhine
SMART_READER_LITE
LIVE PREVIEW

Rhine Overview of Rhine - Lisp style language - Automatic type - - PowerPoint PPT Presentation

Rhine Overview of Rhine - Lisp style language - Automatic type inspired by Clojure conversion - S-Expressions - First class functions - Built on top of LLVM - External C bindings - Dynamic typing - Types - Functional features Example:


slide-1
SLIDE 1

Rhine

slide-2
SLIDE 2

Overview of Rhine

  • Lisp style language

inspired by Clojure

  • S-Expressions
  • Built on top of LLVM
  • Dynamic typing
  • Functional features
  • Automatic type

conversion

  • First class functions
  • External C bindings
  • Types
slide-3
SLIDE 3

Example: Fibonacci

(defn fib [n] (if (= n 0) 0 (if (= n 1) 1 (+ (fib (- n 1)) (fib (- n 2))))))

slide-4
SLIDE 4

Example: Map!

(defn map [f coll] (if (not (= [] coll)) (cons (f (first coll)) (map f (rest coll))) []))

slide-5
SLIDE 5

Implementation

  • OCaml LLVM bindings
  • LLVM arrays/vectors are fixed length, not

used

  • Arrays can contain any type
  • Variable length arrays supported
slide-6
SLIDE 6

Implementation

  • value_t is the structure behind dynamic typing
  • Contains Integers, Bools, Strings, Arrays,

Array length, Doubles

  • Function pointers are stored in value_t
  • Type conversion
slide-7
SLIDE 7

Implementation

  • defn generates LLVM functions directly
  • Nested and recursive let is supported
  • def uses global constant + initializer function
  • Top level statements are generated as

functions with zero arguments and are always run, like main

slide-8
SLIDE 8

Pipeline

slide-9
SLIDE 9

Summary and lessons learned

  • Summer class is really short
  • LLVM is really hard
  • Features of Lisp look nice abstractly but are

difficult to implement

slide-10
SLIDE 10

Future additions

  • Garbage collection, value_t is malloc'd but

never free'd currently

  • Variable number of arguments for functions

being passed around

  • Functions that support varargs
  • Connection to text editor
slide-11
SLIDE 11

Demo!