klam 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/HISTORY.asciidoc +6 -0
- data/lib/klam/primitives/interop.rb +5 -38
- data/lib/klam/version.rb +1 -1
- data/spec/functional/extensions/interop_spec.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3c2a2a79c7fc9bd757b979c7e30ddb9db372ee3
|
4
|
+
data.tar.gz: 331259be37b2fd3c7581bd65907b3c0bfbebae5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3803840c457f33c6d61b0615fe8f09199829ee71ca1f22e4ec3a1c3ada28439e648a404266f2242e755fec8bca9f60b9a9043ef20f7936ae5e40866cc9de3ef5
|
7
|
+
data.tar.gz: 7485c26bc1e70d7d0b45b4d7fba90162b9110af12d7a729133ba0c298b54d2f5af8650a7453dd610f773e8ea2c630b52d1a26eb07e30a66455521324562bff8d
|
data/HISTORY.asciidoc
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
Relase History
|
2
2
|
==============
|
3
3
|
|
4
|
+
v0.0.6 -- February 1, 2015
|
5
|
+
--------------------------
|
6
|
+
Breaking Changes
|
7
|
+
~~~~~~~~~~~~~~~~
|
8
|
+
* `rb-send-block` no longer takes an arity argument.
|
9
|
+
|
4
10
|
v0.0.5 -- January 31, 2015
|
5
11
|
--------------------------
|
6
12
|
New Features
|
@@ -9,14 +9,14 @@ module Klam
|
|
9
9
|
alias_method :"rb-send", :rb_send
|
10
10
|
remove_method :rb_send
|
11
11
|
|
12
|
-
def rb_send_block(obj, method_name,
|
12
|
+
def rb_send_block(obj, method_name, blk, *args)
|
13
13
|
if blk.instance_of?(::Symbol)
|
14
14
|
# The caller won't take advantage of the currying, but we already
|
15
15
|
# are tracking the curried form. This also allows for paritial
|
16
16
|
# application of the named function, which could be interesting.
|
17
17
|
blk = @curried_methods[blk]
|
18
18
|
else
|
19
|
-
blk = ::Klam::Primitives::Interop.uncurry(blk
|
19
|
+
blk = ::Klam::Primitives::Interop.uncurry(blk)
|
20
20
|
end
|
21
21
|
obj.send(method_name, *args, &blk)
|
22
22
|
end
|
@@ -41,44 +41,11 @@ module Klam
|
|
41
41
|
remove_method :rb_const
|
42
42
|
|
43
43
|
class << self
|
44
|
-
def uncurry(blk
|
45
|
-
|
46
|
-
|
47
|
-
uncurry0(blk)
|
48
|
-
when 1
|
49
|
-
blk
|
50
|
-
when 2
|
51
|
-
uncurry2(blk)
|
52
|
-
when 3
|
53
|
-
uncurry2(blk)
|
54
|
-
when 4
|
55
|
-
uncurry2(blk)
|
56
|
-
when 5
|
57
|
-
uncurry2(blk)
|
58
|
-
else
|
59
|
-
::Kernel.raise ::Klam::Error, "unsupported arity: #{blk_arity}"
|
44
|
+
def uncurry(blk)
|
45
|
+
lambda do |*args|
|
46
|
+
args.reduce(blk) { |f, x| f.call(x) }
|
60
47
|
end
|
61
48
|
end
|
62
|
-
|
63
|
-
def uncurry0(blk)
|
64
|
-
-> { blk.call(:NIL) }
|
65
|
-
end
|
66
|
-
|
67
|
-
def uncurry2(blk)
|
68
|
-
-> a, b { blk.call(a).call(b) }
|
69
|
-
end
|
70
|
-
|
71
|
-
def uncurry3(blk)
|
72
|
-
-> a, b, c { blk.call(a).call(b).call(c) }
|
73
|
-
end
|
74
|
-
|
75
|
-
def uncurry4(blk)
|
76
|
-
-> a, b, c, d { blk.call(a).call(b).call(c).call(d) }
|
77
|
-
end
|
78
|
-
|
79
|
-
def uncurry5(blk)
|
80
|
-
-> a, b, c, d, e { blk.call(a).call(b).call(c).call(d).call(e) }
|
81
|
-
end
|
82
49
|
end
|
83
50
|
end
|
84
51
|
end
|
data/lib/klam/version.rb
CHANGED
@@ -9,7 +9,7 @@ describe 'extension: Ruby interop primitives', :type => :functional do
|
|
9
9
|
|
10
10
|
describe 'rb-send-block' do
|
11
11
|
it 'invokes a method on a Ruby object, passing the provided block' do
|
12
|
-
code = '(rb-send-block (cons 1 (cons 2 ())) map
|
12
|
+
code = '(rb-send-block (cons 1 (cons 2 ())) map (lambda X (* 2 X)))'
|
13
13
|
expect_kl(code).to eq([2, 4])
|
14
14
|
end
|
15
15
|
|
@@ -17,7 +17,7 @@ describe 'extension: Ruby interop primitives', :type => :functional do
|
|
17
17
|
eval_kl('(set vec (absvector 2))')
|
18
18
|
result = eval_kl <<-EOKL
|
19
19
|
(let V (absvector 2)
|
20
|
-
(do (rb-send-block (cons 1 (cons 2 ())) each_with_index
|
20
|
+
(do (rb-send-block (cons 1 (cons 2 ())) each_with_index
|
21
21
|
(lambda X (lambda Y (address-> V Y X))))
|
22
22
|
V))
|
23
23
|
EOKL
|
@@ -26,7 +26,7 @@ describe 'extension: Ruby interop primitives', :type => :functional do
|
|
26
26
|
|
27
27
|
it 'supports symbols as blocks' do
|
28
28
|
eval_kl('(set vec (absvector 2))')
|
29
|
-
expect_kl('(rb-send-block (cons 1 (cons 2())) map
|
29
|
+
expect_kl('(rb-send-block (cons 1 (cons 2())) map str)').to eq(%w{1 2})
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|