Hi,

I'm trying to check whether it's possible to implement Python's SQLAlchemy-like query syntax in D, but I get stuck a bit.

Here is a simple example of what I want to achieve:

```
auto result = User.filter(User.id == 10);
result = User.filter(User.name == "John");
result = User.filter(User.age > 18);
```

Expressions like `User.id == 10`, `User.age > 18`, etc. should return a struct instead of a bool (let's call it `struct BinaryExpression`).

So I'm making the two versions of opEquals: one returns a BinaryExpression, and the second - a boolean value.

However, when I want to use the same expression for the `if` operator, the compiler cannot decide what function to call and shows an error: "overloads bool(int b) and BinaryExpr!int(int b) both match argument list for opEquals".


I'm wondering, is that possible to declare multiple versions of opEquals() and evaluate them in the different places depending on return type?

Here is my test code to check: https://run.dlang.io/is/yTFHWp
Gist: https://gist.github.com/run-dlang/67ec42ca73d56d310e8ae765fabede69

Thanks!

Reply via email to