SByC – Investigating Specialization by Constraint
SYNOPSIS
SByC is an investigation about Specialization by Constraint as an alternative to common type systems that we found in (object-oriented) programming languages. The library is written as a collection of Ruby tools described below. Those tools are in fact sub-gems of SByC that can often be used in isolation.
CodeTree
This part of SByC provides a safe, reusable, extensible, mashallable, and non-intrusive (no monkey patching of Ruby core classes) implementation of block expressions. Block expressions are parsed using a generic DSL and converted to a parse tree, which may be analyzed, rewrited, compiled, and so on. The example below illustrates typical usage of CodeTree.
code = CodeTree::parse{ x > 10 & y < 20 } # => (& (> x, 10), (< y, 20)) # See the evaluation section for details code.eval{:x => 5, :y => 5} # => true # See the code-generation section for details code.object_compile('scope', :[]) # => "scope[:x].>(10) & scope[:y].<(20)" # CodeTree expressions may be marshaled Marshal.dump(code)
TypeSystem
This part of SByC implements a TypeSystem abstraction. A type is simply collection of values. A type system is to generate and parse literals and to coerce from String values.
TypeSystem::Ruby::type_of(-125) # => Fixnum lit = TypeSystem::Ruby::to_literal(-125) # => "-125" TypeSystem::Ruby::parse_literal("-125") # => -125 TypeSystem::Ruby::coerce('-125', Integer) # => -125
INSTALL
gem install sbyc
DOCUMENTATION
- The official documentation can be found on GitHub pages
- The api documentation can be found on rdoc.info
CONTRIBUTE
Fork the project on github, make a contrib, and send me a pull request
CREDITS
SByC © 2010 by Bernard Lambeau. SByC is distributed under the MIT licence. Please see the LICENCE.md document for details.