Skip to content

Instantly share code, notes, and snippets.

@kosh04
Created October 4, 2012 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kosh04/3832633 to your computer and use it in GitHub Desktop.
Save kosh04/3832633 to your computer and use it in GitHub Desktop.
FOOPでメンバ変数に名前を付ける #newlisp
;; FOOP in newLISP
;; * How find parent context?
(new Class 'Animal)
(new Animal 'Snake) (define Snake:super Animal)
(new Animal 'Horse) (define Horse:super Animal)
(context Animal)
;; constructor
; (define (Animal:Animal name)
; (list (context) name))
;; * use macro module. enabled (setf (@var) val)
; (module "macro.lsp")
; (macro (@name) (self 1))
(define (@name) (self 1))
(define (move meters)
(println (@name) " moved " meters "m.")
true)
(context Snake)
(define (move)
(print "Slithering...")
(super:move 5))
(context Horse)
(define (move)
(print "Galloping...")
(super:move 45))
(context MAIN)
(setq sam (Snake "Sammy the Python")
tom (Horse "Tommy the Palomino"))
(:move sam)
(:move tom)
(exit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment