;; -*-theme-d-*-

;; Copyright (C) 2008-2013 Tommi Höynälänmaa
;; Distributed under GNU General Public License version 3,
;; see file doc/GPL-3.

;; Expected results: translation and running OK


(define-proper-program (tests test13)


  (import (standard-library core)
	  (standard-library console-io))


  (define-param-class :triplet (%type1 %type2 %type3) <object> #f #f #t public
    ()
    ((first %type1 public public)
     (second %type2 public public)
     (third %type3 public public)))


  (define-param-proc-alt reverse-triplet (%type1 %type2 %type3)
    (lambda (((arg (:triplet %type1 %type2 %type3)))
	     (:triplet %type3 %type2 %type1)
	     pure)
      (make (:triplet %type3 %type2 %type1)
	(field-ref arg 'third)
	(field-ref arg 'second)
	(field-ref arg 'first))))

  (define-param-proc-alt make-triplet (%arglist)
    (lambda (((arglist (splice %arglist)))
	     (:triplet (splice %arglist))
	     pure)
      (reverse-triplet
       (make (:triplet (splice %arglist))
	 (car (cdr (cdr arglist)))
	 (car (cdr arglist))
	 (car arglist)))))

  (define main
    (lambda (() <integer> nonpure)
      (let ((result
	     (make-triplet 1 2 3)))
	(console-display (field-ref result 'first))
	(console-newline)
	(console-display (field-ref result 'second))
	(console-newline)
	(console-display (field-ref result 'third))
	(console-newline))
      0)))
