Some people were asking for a way to change table schemas easily, so I came up with a DSL for doing that, so you can do stuff like:
alter_table :items add_column :name, :text, :unique => true drop_column :category endAnd Sequel will generate the correct SQL for you.
— Sequel Interview with Sharon Rosner (emphasis mine)
For a second that looked a lot like another language I knew, and then I looked more closely. Silly me. Those leading colons make all the difference.
Here's an idea. Instead of complaining about Ruby DSL's 24/7, show us how to write one in Perl.
Re:Well?
chromatic on 2008-01-19T06:04:53
Instead of complaining about Ruby DSL's 24/7...Exaggerate much?
... show us how to write one in Perl. I'll do you one better. Take off the leading colons, turn
end into a semicolon, and HEY LOOK IT'S SQL WITH SIGILS.
Sharon merely uglified an existing, perfectly working DSL. Some invention.
Re:Well?
pdcawley on 2008-01-20T04:28:28
Yeah, but at least it's not just passing a string to sql.execute or whatever, so ruby gets a chance to complain before the database does.
Nah... not exactly compelling as arguments go is it?
Re:Well?
chromatic on 2008-01-20T07:59:45
It's an advantage though, and if there's cross-database goodness hidden behind the API, that's an advantage too.
Of course, I worked on a project with something similar in 1999, and SQL was around before that, so anyone who didn't invent relational theory (or write a SQL database used by multiple people and projects) who claims to have come up with the syntax comes across as somewhat pretentious.
Re:Well?
Aristotle on 2008-01-19T06:50:45
show us how to write one in Perl.
I think chromatic’s entire point is that “DSLs” are just “APIs,” except sprinkled with a magic pixie dust that no one has the will or capacity to define, past the fact that hash keys in great quantities are involved. “I know it when I see it” seems to exhaust the substance of the difference.
So how does one reproduce something undefinable?