User Tools

Site Tools


messagepassing

단순히 데이터를 똑똑하게 하는것 이상의 무슨 이점이 있는거 같다. DataDirectedProgramming 은 사용 할려면 table을 확인을 해야하는데 MessagePassing은 구현하는거 몰라도 인터페이스만 알면 잘 쓸 수 있다.

이것 뿐만아니라, 아이디어는 간단하긴 한데,, 파생되는 이점이 많다.(그냥 봐서는 몰랐는데, 문제를 풀어보니깐 알껫다.) 아래처럼..

(define (regular->message-passing lst)
   (if (null? lst)
      '()
       (make-pair (car lst)
                  (regular->message-passing (cdr lst))))) ;;요기 
 
(define (make-pair x y)  
   (define (dispatch msg)      
     (cond ((eq? msg 'the-car-please) x)     
           ((eq? msg 'the-cdr-please) y) 
           ((eq? msg 'the-cadr-please) 
            (y 'the-car-please)) ;;요기
           ((eq? msg 'the-length-please)
            (+ 1 (if (null? y) 0 (y 'the-length-please)))) ;;요기
           (else (error "I don't understand: " msg)))) 
   dispatch)
messagepassing.txt · Last modified: 2018/07/18 14:10 by 127.0.0.1