OK, it is not the time for it currently, just an idea for future.
Usage:
puts SymEngine.formula {|x, y| x**2 + y**2}
# => x**2 + y**2
Naive implementation:
def SymEngine.formula &block
block.parameters.empty? and fail(ArgumentError, "Block should list all expected symbols")
block.parameters.map(&:first).uniq == [:opt] or fail(ArgumentError, "Only plain parameters are supported (no defaults, no *rest, no keyword args)")
symbols = block.parameters.map(&:last).map(&SymEngine::Symbol.method(:new))
block.call(*symbols)
end
There's almost no "dangerous" magics (with method_missing, instance_eval and stuff), and seems pretty useful?..