Created
June 18, 2011 17:36
-
-
Save et4te/1033306 to your computer and use it in GitHub Desktop.
Dependent typing in common lisp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;-------------------------------------------------------------------- | |
;;-- Types | |
;; slot-number type | |
(defun within-slot-number-rangep (n) | |
(not (or (< n 0) (> n 255)))) | |
(deftype slot-number () | |
`(and fixnum (satisfies within-slot-number-rangep))) | |
;; vitality type | |
(defun within-vitality-rangep (v) | |
(not (or (< v -1) (> v 65535)))) | |
(deftype vitality () | |
`(and fixnum (satisfies within-vitality-rangep))) | |
;; field type | |
(deftype field () | |
`(or fixnum function)) | |
(deftype field-application () | |
`(and function)) | |
;;-------------------------------------------------------------------- | |
;;-- Structures | |
;; slot structure | |
(defstruct slot | |
(number 0 :type index) | |
(field #'identity :type field) | |
(vitality 10000 :type vitality)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment