• R/O
  • SSH

kink: 提交

Kink runtime


Commit MetaInfo

修订版eea3268ebf1d123517d910c8c29271e15c128a05 (tree)
时间2020-02-25 23:00:19
作者miyakawataku
Commitermiyakawataku

Log Message

improve EQ documentation

更改概述

差异

diff -r cc7a70803371 -r eea3268ebf1d src/main/resources/kink-mods/kink/COMPARE.kn
--- a/src/main/resources/kink-mods/kink/COMPARE.kn Tue Feb 25 22:25:21 2020 +0900
+++ b/src/main/resources/kink-mods/kink/COMPARE.kn Tue Feb 25 23:00:19 2020 +0900
@@ -10,7 +10,7 @@
1010 # Makes a trait of comparing methods.
1111 #
1212 # $config must take a compare_conf.
13-# For the compare_conf, at least one of .lt or le must be specified.
13+# For the compare_conf, at least one of .lt or .le must be specified.
1414 #
1515 # The result trait contains the following methods:
1616 # op_lt, op_le, op_eq, op_ne, op_ge and op_gt.
@@ -133,7 +133,7 @@
133133 # Maybe [$eq?].
134134 'May_eq_fun' []
135135
136- ## Compare_conf.eq($eq?)
136+ ## C.eq($eq?)
137137 #
138138 # Sets $eq? to be used.
139139 #
@@ -150,7 +150,7 @@
150150 # Maybe [$ne?].
151151 'May_ne_fun' []
152152
153- ## Compare_conf.ne($ne?)
153+ ## C.ne($ne?)
154154 #
155155 # Sets $ne? to be used.
156156 #
@@ -176,7 +176,7 @@
176176 # The attribute is used to test the order of the vals.
177177 'by' {[:C](:attr)
178178 FUN.is?($attr) || raise(
179- 'C.by($attr): $attr must be a fun, but got {}'.format($attr.repr))
179+ 'Compare_conf.by($attr): $attr must be a fun, but got {}'.format($attr.repr))
180180 C:May_attr_fun <- [$attr]
181181 }
182182
diff -r cc7a70803371 -r eea3268ebf1d src/main/resources/kink-mods/kink/EQ.kn
--- a/src/main/resources/kink-mods/kink/EQ.kn Tue Feb 25 22:25:21 2020 +0900
+++ b/src/main/resources/kink-mods/kink/EQ.kn Tue Feb 25 23:00:19 2020 +0900
@@ -1,5 +1,14 @@
11 ##
22 # Mod to prodive equality methods.
3+
4+:FUN.require_from('kink/')
5+
6+## EQ.trait($config)
7+#
8+# EQ.trait makes a trait of equality methods: op_eq and op_ne.
9+#
10+# $config must take a eq_conf.
11+# For the eq_conf val, at least one of .eq, .ne or .by must be called.
312 #
413 # Usage:
514 #
@@ -13,8 +22,8 @@
1322 # }
1423 #
1524 # :Label_trait <- [
16-# ... EQ.oldtrait{(:X :Y)
17-# X.str == Y.str
25+# ... EQ.trait{(:C)
26+# C.by{(:L) L.str }
1827 # }
1928 #
2029 # 'str' {[:L]()
@@ -26,9 +35,32 @@
2635 # stdout.print_line((label('Foo') == label('Bar')).repr) # => false
2736 # stdout.print_line((label('Foo') != label('Foo')).repr) # => false
2837 # stdout.print_line((label('Foo') != label('Bar')).repr) # => true
29-
30-:FUN.require_from('kink/')
31-
38+#
39+# The program above can also be written using .eq as follows:
40+#
41+# :EQ.require_from('kink/')
42+#
43+# :label <- {(:Str)
44+# new_val(
45+# ... Label_trait
46+# 'Str' Str
47+# )
48+# }
49+#
50+# :Label_trait <- [
51+# ... EQ.trait{(:C)
52+# C.eq{(:X :Y) X.str == Y.str }
53+# }
54+#
55+# 'str' {[:L]()
56+# L.Str
57+# }
58+# ]
59+#
60+# stdout.print_line((label('Foo') == label('Foo')).repr) # => true
61+# stdout.print_line((label('Foo') == label('Bar')).repr) # => false
62+# stdout.print_line((label('Foo') != label('Foo')).repr) # => false
63+# stdout.print_line((label('Foo') != label('Bar')).repr) # => true
3264 :trait <- {(:config)
3365 :Conf = _do_config($config)
3466 [ 'op_eq' Conf._make_op_eq
@@ -42,25 +74,47 @@
4274 Conf
4375 }
4476
77+## type eq_conf
78+#
79+# Conf val type of EQ.trait.
4580 :Conf_trait <- [
4681 'Eq_fun_maybe' []
82+
83+ ## C.eq($eq?)
84+ #
85+ # C.eq specifies $eq? as a fun which tests two vals are equal.
86+ #
87+ # $eq? must take two vals, and return whether they are equal.
4788 'eq' {[:C](:eq?)
4889 FUN.is?($eq?) || raise(
49- 'Eq_trait_conf.eq($eq?): $eq? must be fun, but got {}'.format($eq?.repr))
90+ 'Eq_conf.eq($eq?): $eq? must be fun, but got {}'.format($eq?.repr))
5091 C:Eq_fun_maybe <- [$eq?]
5192 }
5293
5394 'Ne_fun_maybe' []
95+
96+ ## C.eq($ne?)
97+ #
98+ # C.ne specifies $ne? as a fun which tests two vals are not equal.
99+ #
100+ # $ne? must take two vals, and return whether they are not equal.
54101 'ne' {[:C](:ne?)
55102 FUN.is?($ne?) || raise(
56- 'Eq_trait_conf.ne($ne?): $ne? must be fun, but got {}'.format($ne?.repr))
103+ 'Eq_conf.ne($ne?): $ne? must be fun, but got {}'.format($ne?.repr))
57104 C:Ne_fun_maybe <- [$ne?]
58105 }
59106
60107 'Attr_fun_maybe' []
108+
109+ ## C.eq($attr)
110+ #
111+ # C.eq specifies $attr as a fun which extracts the attribute to which
112+ # equality test is delegated.
113+ #
114+ # $attr must take one val, and return the attribute of the val.
61115 'by' {[:C](:attr)
62116 FUN.is?($attr) || raise(
63- 'Eq_trait_conf.by($attr): $attr must be fun, but got {}'.format($attr.repr))
117+ 'Eq_conf.by($attr): $attr must be fun, but got {}'.format($attr.repr))
64118 C:Attr_fun_maybe <- [$attr]
65119 }
66120
Show on old repository browser