SHARE
TWEET

Is it a FOOP peculiarity?

kosh Jul 1st, 2014 262 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!newlisp
  2.  
  3. ;; Is it a FOOP peculiarity?
  4. ;; http://www.newlispfanclub.alh.net/forum/viewtopic.php?t=4557&p=22467
  5.  
  6. (new Class 'One)
  7. (new One 'Two)
  8.  
  9. (context One)
  10.  
  11. (define (put v)
  12.   (setf (self 1) v))
  13.  
  14. (context Two)
  15.  
  16. (define (Two:Two one x)
  17.   (:put one x)
  18.   (list (context) one x))
  19.  
  20. (context MAIN)
  21.  
  22. (setf uno:uno (One "A"))
  23. (println "Before: " uno:uno)    ;-> Before: (One "A")
  24. (setf duo:duo (Two uno "B"))
  25. (println "After:  " uno:uno)    ;-> After:  (One "B")
  26.  
  27. (println duo " of " duo:duo)    ;-> duo of (Two uno "B")
  28. (println (Two (One "X") "Y"))   ;-> (Two (One "Y") "Y")
  29.  
  30. (exit)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top