lunes, 19 de septiembre de 2011

Fastruby 0.0.8 released with support for lambdas

Fastruby is a gem which allows to execute ruby code much faster than normal, currently in a state of transition between a spike and a usable gem, it is released when possible with incremental improvements.
The version v0.0.8 was released with the new feature of supporting lambdas. Functional improvement does not appear to be important, but the underlying internal implementation will allow new features in the next release such as the support for proc and continuation objects.

Install

You can clone the repository at github:
git clone git://github.com/tario/fastruby.git
Or install it using gem install:
gem install fastruby
New Features
Examples of code being supported

Scope retention (lambda has a reference to the scope where it was created)

require "fastruby"

fastruby '
class X
attr_accessor :lambda_set, :lambda_get
def initialize
a = nil

@lambda_set = lambda{|x| a = x}
@lambda_get = lambda{a}
end
end
'

x = X.new

x.lambda_set.call(88)
p x.lambda_get.call

Yield block of the scope

require "fastruby"

fastruby '
class X
def bar
lambda_obj = lambda{
yield
}
lambda_obj
end

def foo
a = 77
bar do
a
end
end
end
'

x = X.new

lambda_obj = x.foo
p lambda_obj.call # 77


No hay comentarios:

Publicar un comentario