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.gitOr install it using gem install:
gem install fastrubyNew Features
- Support for lambdas
- Internal: new structure to represent stack
- Better implementation of break statement
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