On 26 April 2012 17:00, Chris Travers <chris.travers@gmail.com> wrote:
> On Wed, Apr 25, 2012 at 11:34 PM, Brendan Jurd <direvus@gmail.com> wrote:
>> SELECT p.age_years(date '2012-05-01')
>> FROM person p
>>
>> As I recall, my idea did not achieve escape velocity, but I still
>> think it would a) extend the dot-call syntax to a more useful pattern,
>> b) bolster our justification for the "O" in "ORDBMS", and c) actually
>> be kind of awesome.
>
> Dot syntax should be replaced by something less ambiguous, though.
> The problem is that you currently have issues in some versions of Pg
> where p.name might be the name of the person, or it might be the p
> record cast as something almost identical to varchar(63)....... The
> only reason this is not an issue on more recent versions of Pg is that
> implicit casting to text types has been dropped so this doesn't really
> address the underlying problem.
The "method" dot-call syntax in my suggestion would always have
parentheses, p.name() for example, so I don't think it suffers from
the same ambiguity as the historical dot-call syntax.
Regardless, I don't know how we could replace the dot in the syntax.
Wouldn't it be unprecedented to have an OO syntax which uses a
different operator to reference attributes than the one to reference
methods? That would really drain much of the notational convenience
out of the feature.
Cheers,
BJ