Skip to content
David Jeske edited this page May 22, 2017 · 18 revisions

Syntax

Irken's syntax is nearly identical to Scheme's.

  • comments
    • single-line comments begin with ;
  • symbols
    • begin with a non-numeric character and can contain alphanumeric characters and the symbols *, +, !, -, _, ', and ?. colon (:) is a reserved character, it identifies variant constructors.
    • foo, my-foo, is-foo?
  • vectors
    • literals #(1 2 3) and postfix array-indexing x[i], soon will support #[1 2 3]
  • records literal declaration and field access
    • literal declaration { field0 = 10 field1 = "foo" }, and field-access a.field1
  • lists
    • lists of literals may be written as quoted lists '(1 2 3) or the empty list '()
    • lists with where expressions should be evaluated require an explicit construction (list 1 (+ 1 1) (+ 1 1 1))
  • booleans
    • #t : true, and #f : false
  • null
    • A zero value is written as #\nul
  • pattern matching
    • in match expressions and pattern function definitions, use ->
  • type declarations are optional. See datatypes and function type declarations

Immediate Literals Reference

Irken's reader implements a subset of the Scheme literals.

#u                      ; undefined

#t                      ; true
#t                      ; false

'hello                  ; symbol

"hello"                 ; string
"\x5e"                  ; string with character hexcode 5e
"\r\n\t\"\\"            ; carriage return; newline; tab; ", \

542                     ; integer
#x5e                    ; hex      0x5e in C
#o12                    ; octal     012 in C

#(1 2 3)                ; vector
'(1 2 3)                ; quoted list

#\a                     ; lowercase character 'a'
#\A                     ; uppercase character 'A'
#\space                
#\newline              
#\return
#\tab
#\nul
#\eof

Next: Datatypes