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 6 of 9 Topic 2359 of 2472
Post > Topic >>

Re: Data structures for efficient overload resolution

by Chris Dodd <cdodd@[EMAIL PROTECTED] > Mar 17, 2008 at 07:07 PM

Steve Horne <stephenhorne100@[EMAIL PROTECTED]
> wrote in
news:08-03-063@[EMAIL PROTECTED]
> When my naive approach resolves one particular call, it checks every
> single candidate. It looks linear at a glance, but it's not. An
> apparent ambiguity can arise early in the search only to be resolved
> later. For example, given a hierarchy with parent class p and child
> class c, consider the following sequence of candidates...
>
>   1 (p, c)
>   2 (c, p)
>   3 (c, c)
>
> When resolving for the call (c, c), candidates 1 and 2 will both
> appear valid with neither being more specific than the other.
> Therefore, when *****sing candidate 3, it must be compared with both
> of these two earlier candidates. Only then can these candidates be
> eliminated. Comparisons must be done both with the call being resolved
> and with those previously identified candidates that have yet to be
> eliminated. Since the number of previously identified candidates can
> grow linearly with the number of candidates checked so far, the
> overall worst-case complexity is quadratic.

The usual way to do this is to compare each function against the list
of best matches for each argument irrespective of which function they
came from.  That way you get O(nm) complexity in the number of
candidates and number of arguments.  So after looking at #2, you'll
have (c, c) as your best match argument types and no function that
matches it.  #3 will then match.

Chris Dodd
cdodd@[EMAIL PROTECTED]

 




 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 Thu Jul 24 14:27:47 CDT 2008.