GLORP (Generic Lightweight Object Relational Persistence) allows you to specify queries as blocks of code.
db readManyOf: User where: [:user | user username = 'Blanchard' && user password = 'passW0rd' ].
given a table: CREATE TABLE USER (USER_NAME varchar(60), PASSWORD varchar(60))
how can this work?
The second argument to readManyOf:where: is a block of code. The block is evaluated with a MessageLogger standing in for user. ie
readManyOf: aClass where: aBlock
| aMessageLogger |
aMessageLogger := MessageLogger forClass: aClass
aBlock value: aMessageLogger.
The MessageLogger's doesNotUnderstand is examining the messages and producing an equivalent SQL translation based on some attribute to column mapping data it has. Since even the operators are actually messages, this is relatively straightforward to do. In Smalltalk that is.
This is just plain impossible in Java/C++/Object Pascal/etc.