Skip to content
/ thing Public
forked from jpverkamp/thing

A Racket-based prototype object system

Notifications You must be signed in to change notification settings

armozel/thing

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Note: This is a fork for the purpose of updating the project to overcome a minor issue with the use of rackunit and test- engine/scheme-tests which seem to conflict

To install:

raco pkg install github://github.com/jpverkamp/thing/master

A prototype based object system for Racket

Examples:

; Create a basic thing
(define-thing color
  [red 0]
  [green 0]
  [blue 0])

; Extend things
(define-thing red color
  [red 255])

; Get values, with optional default
(thing-get red 'red) => 255
(thing-get red 'orange) => *error*
(thing-get red 'orange 9001) => 9001

; Set value, existing or not
(thing-set! red 'red 1.0)
(thing-set! red 'purple 0.5)

; Setting values does not change parent
(thing-get red 'purple) => *error*

; Values can be functions
(define-thing chatterbox
  [(talk name) (format "~a says hello world!" name)])

; Call functional values directly
(thing-call chatterbox 'talk "steve") => "steve says hello world!")

About

A Racket-based prototype object system

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Racket 100.0%