Skip to content

CORE: type system #16

Description

@shikaan

We should be able to create a minimalistic type system for lifp.

Something like:

;; [number number] -> number
(def! sum (fn (a b) (+ a b)))

Rules:

  • ;; starts a type block
  • -> indicates return value
  • scalar types are bool number builtin nil special string any
  • functions should be typed by their type signature (i.e., no closure but (number) -> number)
  • lists are typed with () and their type (number) is a list of numbers
  • ... means variadic arguments (NOT SUPPORTED BY RUNTIME YET)
  • variadic arguments are always last (NOT SUPPORTED BY RUNTIME YET)

More examples

;; number
(def! a 12)

;; [number] -> bool
(def! pos? (fn (a) (> a 0)))

;; [(number) number] -> number
(def! nth (fn (list num) (list:nth list num)))

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions