lib/kl/primitives/vectors.rb in shen-ruby-0.3.1 vs lib/kl/primitives/vectors.rb in shen-ruby-0.4.0
- old
+ new
@@ -1,21 +1,26 @@
module Kl
module Primitives
module Vectors
def absvector(n)
+ raise Kl::Error, "#{n} is not a number" unless n.kind_of? Fixnum
Kl::Absvector.new(n)
end
define_method 'address->' do |v, n, value|
+ raise Kl::Error, "#{v} is not a vector" unless v.kind_of? Kl::Absvector
+ raise Kl::Error, "#{n} is not a number" unless n.kind_of? Fixnum
if n < 0 || n >= v.upper_limit
raise Kl::Error, "out of bounds"
end
v[n] = value
v
end
define_method '<-address' do |v, n|
+ raise Kl::Error, "#{v} is not a vector" unless v.kind_of? Kl::Absvector
+ raise Kl::Error, "#{n} is not a number" unless n.kind_of? Fixnum
if n < 0 || n >= v.upper_limit
raise Kl::Error, "out of bounds"
end
v[n]