>
> Last argument, I promise.

I won't hold you to that. :-)
 

> The existence of Query and Set objects are not a hidden implementation
> details. For example, if the user is unaware of the presence of Query
> objects, db(db.mytable.id == 3) shouldn't make any sense, as
> db.mytable.id == 3 should return a boolean. How could passing a
> boolean to db() possibly encode the information that makes up a query?
>
Right, but your proposed alternative has the same problem:

(db.mytable.id > 0).select()

What's a boolean doing with a select() method, and how could it encode the 
information that makes up a query? Overloading operators to produce a Query 
object is just as magical either way, and it needs to be explained to users 
in either case. If passing what appears to be a boolean to a callable class 
to produce a set is confusing, then treating what appears to be a boolean 
as a set itself should also be confusing. If your problem is with 
overloading operators to produce a Query, then deprecating Set doesn't 
solve that.
 

> Learners should not be given the impression that 'DAL syntax' is
> anything but just Python code.
>
Well, Python does allow operator overloading, so it is Python code, but 
again, it does not appear you are proposing an alternative to the 
overloading.
 

> If learners take away the
> lesson that query expressions are a magic special case in Python
> itself, web2py is doing a disservice to those students.
>
Perhaps we could explain it better.
 

> Removing Set would make the syntax slightly cleaner, but that's not
> the important point: the comprehensible mental model of the objects is
> more important than the syntax.
>
To me, passing query syntax plus optional parameters to a db object to 
define a set of records evokes a fairly comprehensible mental model -- at 
least as comprehensible as applying a chain of methods to some query syntax 
to define a set of records.

Note, I'm not particularly against your proposed alternative (though I'm 
not crazy about the method chaining) -- I just don't find the case for it 
quite so compelling. It seems the operator overloading likely generates 
more confusion, and I don't think that is helped by the proposed syntax 
change.

Anthony

Reply via email to