Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Compilers > Re: Data struct...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 9 Topic 2359 of 2472
Post > Topic >>

Re: Data structures for efficient overload resolution

by Barry Kelly <barry.j.kelly@[EMAIL PROTECTED] > Mar 14, 2008 at 02:42 PM

Steve Horne wrote:

> I'm interested in data structures for efficient overload resolution.

> What I'm really interested in is the case with multiple independent
> parameters. I have very little idea how to even approach this problem.

This may or may not be useful to your specific case, in so far as it
may give another direction to look for ideas:

I look at overload resolution as a sorting problem where the actual
argument types provide the sorting key for a partial order. Any given
argument type needs to be able to compare two parameter types, and
return one of (<, >, =, <> (incompatible with either)), or possibly more
nuanced for narrowing vs. widening etc., assuming the sorting function
normalises this. There may be more argument types than there are
parameter types (e.g. the 'nil' or 'null' type, in such languages that
sup****t it, usually cannot be a parameter type).

However, multiple parameters doesn't (normally) mean a lexicographical
ordering. Instead, the sorting function taking the key (composed of the
actual argument types) should return the ordering if only some of the
types in the key indicate an ordering; return incompatible if any
indicate <>; etc. with details governed by the specifics of your
overloading semantics.

Overload resolution is then reduced to creating and maintaining a list
of the "max" candidates, i.e. candidates which compare greater than any
previously seen candidate and equal to one another. If at the end of the
search, there are multiple candidates, then the result is ambiguous; no
candidates, not compatible; a single candidate, job done.

If the overload type ordering is sane, then this process should be
linear in the number of candidates (and arguments). By sane, I mean that
any candidate which compares greater than any previous candidate should
also compare greater than any candidate equal to the previous candidate,
preventing a potential quadratic mini-explosion.

-- Barry

--
http://barrkel.blogspot.com/
 




 9 Posts in Topic:
Data structures for efficient overload resolution
Steve Horne <stephenho  2008-03-11 16:35:50 
Re: Data structures for efficient overload resolution
Barry Kelly <barry.j.k  2008-03-14 14:42:33 
Re: Data structures for efficient overload resolution
Steve Horne <stephenho  2008-03-15 13:36:19 
Re: Data structures for efficient overload resolution
Barry Kelly <barry.j.k  2008-03-17 14:44:26 
Re: Data structures for efficient overload resolution
Steve Horne <stephenho  2008-03-18 07:07:52 
Re: Data structures for efficient overload resolution
Chris Dodd <cdodd@[EMA  2008-03-17 19:07:49 
Re: Data structures for efficient overload resolution
Steve Horne <stephenho  2008-03-18 07:23:56 
Re: Data structures for efficient overload resolution
George Neuner <gneuner  2008-03-18 21:46:51 
Re: Data structures for efficient overload resolution
Steve Horne <stephenho  2008-03-22 18:53:56 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 2:22:00 CDT 2008.