File: mutable-pair.thi

package info (click to toggle)
theme-d 7.2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,036 kB
  • sloc: lisp: 9,625; sh: 5,321; makefile: 715; ansic: 477
file content (51 lines) | stat: -rw-r--r-- 1,560 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
;; -*-theme-d-*-

;; Copyright (C) 2021, 2025 Tommi Höynälänmaa
;; Distributed under GNU Lesser General Public License version 3,
;; see file doc/LGPL-3.

(define-interface (standard-library mutable-pair)

  (import (standard-library core)
	  (standard-library object-string-conversion))

  (define-param-class :mpair
    (parameters %type1 %type2)
    (inheritance-access hidden)
    (attributes equal-by-value)
    (fields
     (head %type1 public public)
     (tail %type2 public public)))

  (define-param-logical-type :mutable-alist (%key %value)
    (:uniform-list (:mpair %key %value)))
    
  (define-param-logical-type :nonempty-mutable-alist (%key %value)
    (:nonempty-uniform-list (:mpair %key %value)))

  (declare-param-method mcons (%type1 %type2)
			(%type1 %type2) (:mpair %type1 %type2) pure)
  
  (declare-param-method mcar (%type1 %type2) ((:mpair %type1 %type2))
			%type1 pure)

  (declare-param-method mcdr (%type1 %type2) ((:mpair %type1 %type2))
			%type2 pure)

  (declare-param-method m-set-car! (%type1 %type2)
			((:mpair %type1 %type2) %type1) <none> nonpure)

  (declare-param-method m-set-cdr! (%type1 %type2)
			((:mpair %type1 %type2) %type2) <none> nonpure)

  (declare-param-method m-assoc (%key %value %default)
			(%key (:mutable-alist %key %value) %default)
			(:union (:mpair %key %value) %default)
			pure)

  (declare-param-method mpair->string (%type1 %type2)
			((:mpair %type1 %type2)) <string> pure)

  (declare-param-virtual-method object->string (%type1 %type2)
				((:mpair %type1 %type2)) <string> pure))