logo       

Sponsor
FREE Network Mapping Tool for Microsoft® Office Visio® Professional 2007
Don't map your network by hand - let LANsurveyor Exx press for Microsoft Visio Professional 2007 automatically create network diagrams for you!

Re: Type system notes: msg#00261

apache.db.derby.devel

Subject: Re: Type system notes

RPost wrote:

> The SQLInteger.java has a 'plus' method whose signature is:
> public NumberDataValue plus(NumberDataValue addend1,
> NumberDataValue addend2,
> NumberDataValue result)
>
> All of the parameters and the return value are interfaces.
>
> Would you shed some light on the actual technical requirements for the
> 'plus' method?
>
> In other words, can the type of each parameter and result value literally be
> any and all present and future implementations of the NumberDataValue
> interface? That is, is it a derby requirement that the 'plus' method be
> capable of being called with 'addend1', 'addend2' and 'result' parameters
> being three distinct classes? Or is this just a convenience to make the code
> generation more efficient?

I think the current use and requirements are that all the four types are
the same, and typically, if not always the addend1 is the same instance
as the receiver.

The technical requirement could be more flexible, requiring that the
result is suitable to hold the result of operation and that addend1 and
addend2 can be correctly represented by the receiver.

Thus, given the implementations today, this would work

SQLInteger.plus(SQLInteger, SQLShort, SQLLong)

This would give incorrect results

SQLInteger.plus(SQLInteger, SQLLong, SQLInteger)

Inccorrect results would occur because the plus methods 'pull' arguments
from addend1 and addend2 using the getXXX methods, in this case with
addend2 SQLLong.getInt(). This SQLLong.getInt() matches the Java
operation (int) longValue, thus silently truncating the top 32 bits.

I was saying that the methods should be simplified to say the method
executes on the receiver (self), thus plus (I think) should be defined as

// Perform result = this + val
void plus(NumberDataValue val, NumberDataValue result)

and thinking about interfaces, I think it might be possible to define
plus in NumberDataValue as

// set result to this + val
void plus(DataValueDescriptor val, DataValueDescriptor result)

The advantage of going to the primary type interface DVD, is that it
removes the need to add a cast in before calling plus, as type values
are handled generically in most of the code as DataValueDescriptors.

Dan.





<Prev in Thread] Current Thread [Next in Thread>
Sponsor
FREE Network Mapping Tool for Microsoft® OfficeVisio Professional 2007
Don't map your network by hand - let LANsurveyor Express for Microsoft Visio Professional 2007
automatically create network diagrams for you!
Google Custom Search

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation

Home | sitemap | advertise | OSDir is an inevitable website. super tiny logo