4 ms·
Ok, so the answer is, "because Rubyists have redefined that phrase"? ;-) The sweetening of the syntax in Sinatra seems to be rather straightforward. I assume
by wheels 17y ago
Ok, so the answer is, "because Rubyists have redefined that phrase"? ;-)
The sweetening of the syntax in Sinatra seems to be rather straightforward. I assume it's something like:
# internal route stuff
@routes = {}
def get(method, &block)
@routes[method] = block
end
# user provided code
get 'foo' do
puts 'foo'
end
# something hooked up to execute at the end of the file
while input = gets.chomp
@routes[input].call if @routes.include? input
end
I find it really hard to call that a language – it's just a clever use of normal Ruby syntax.
- AndrewO 17y agoOk, so the answer is, "because Rubyists have redefined that phrase"? ;-) Well, by name dropping I was hoping to avoid the appearance of that. :-) Fowler certainly writes about Ruby a lot, but I'd hope he's perceived as general enough to not just be a "Rubyist" (I don't know what he primarily uses). But he also points out that Lisp is a perfectly good host environment for internal DSLs (he calls it the "doyen of internal DSL thinking"). And I also brought up the "fluent interface" thing to suggest that you could call it that if it made you happier. For my tastes, I'm fine with the idea that a "language" reuses a more general purpose language's interpreter and libraries. YMMV. I assume it's something like:... http://github.com/bmizerany/sinatra/blob/work/lib/sinatra/base.rb#L836 http://github.com/bmizerany/sinatra/blob/work/lib/sinatra/ba... Sure looks similar, but as you can see from all the code above the method there's a lot more going on. But hey, at least they didn't need to write a parser. ;-)