Alex Fedorov
Alex Fedorov
Do I understand it right, something like that: ``` ruby Contract(App::Engine::Contracts, Contracts::Builtin) { [A, B => Not[C]] } ``` EDIT: this might be noisy to my taste, don't know.
Don't really see, how it will work without a block or a string/eval. The closest will be `Contract { [A => Num] }` again..
Now I get with that example. So all contract definitions will be in one namespace isolated from user codebase. Not bad idea.
I like this. But: the question is, will this approach with hidden namespace and contracts with the same name create any confusion for readers of the code? What about autoloading...
So. I want to see something like `include Contracts::Core` in the wild, that will not pollute current namespace with anything at all. No builtin contracts, nothing. `include Contracts` will still...
Played around in irb. 1st possibility: ``` ruby Contract {{ Num(), Maybe(Num()) => String }} ``` 2nd: ``` ruby Contract {{ c.Num, Maybe(c.Num) => String }} ``` 3rd: ``` ruby...
@alem0lars I don't really see any performance boost from parsing a string.. The only bottleneck contracts currently has is `Contract#call_with` which only handles actual arguments passed to method. Everything else...
BTW, I have just noticed, that `{{ a, b, c => d }}` is not working :) So it leaves only `{[ a, b, c => d ]}`
@sfcgeorge in 3rd example there will not be a conflict: ``` ruby stringy = Contracts::Or[String, Symbol] Contract {[ stringy => any ]} # => [{ Contracts::Or[String, Symbol] => Contracts::Any }]...
There is totally different possibility: ``` ruby Contract Contracts[:Num], Contracts[:Maybe][Contracts[:Num]] => String ``` Which is very verbose, but no magic involved at all.