← Back to team overview

ooc-dev team mailing list archive

Thoughts on housedsl

 

Hi,

I've just been looking over
http://github.com/nddrylliog/housedsl/blob/master/housedsl.ooc and I think I
have some ideas on how it can be improved.

Ruby gets away with doing to so nicely, because you can use dynamic scoping.
Dynamic scoping is not something we can easily do in a statically typed
language, but I think we can get close.

Consider if we had a generic type Method<T>, which we could use instead of
Func. Method's type parameter would be the class in whose scope you want to
run the func in, so in this case Method<CustomHouse>, Method<Floor>. I think
a big limitation of this is that we'd probably be only able to coerce lambda
literals into a Method<T>, but that might be fine since this is a feature
specifically targeted at DSLs.

I'm not sure what happens at the other end, whether you're required to pass
in an instance of that class, or whether it's more magical than that.

Here's my re-written example: http://gist.github.com/644243

Just an idea.

- Ycros