<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.5pt;
        font-family:Consolas;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:Consolas;}
span.EmailStyle20
        {mso-style-type:personal;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
/* List Definitions */
@list l0
        {mso-list-id:217671304;
        mso-list-type:hybrid;
        mso-list-template-ids:-1753867918 -1901810080 -1901810080 67698693 67698689 67698691 67698693 67698689 67698691 67698693;}
@list l0:level1
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:-;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Calibri","sans-serif";
        mso-fareast-font-family:Calibri;}
@list l0:level2
        {mso-level-start-at:0;
        mso-level-number-format:bullet;
        mso-level-text:-;
        mso-level-tab-stop:1.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        font-family:"Calibri","sans-serif";
        mso-fareast-font-family:Calibri;}
@list l0:level3
        {mso-level-tab-stop:1.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level4
        {mso-level-tab-stop:2.0in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level5
        {mso-level-tab-stop:2.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level6
        {mso-level-tab-stop:3.0in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level7
        {mso-level-tab-stop:3.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level8
        {mso-level-tab-stop:4.0in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l0:level9
        {mso-level-tab-stop:4.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1
        {mso-list-id:1087267946;
        mso-list-type:hybrid;
        mso-list-template-ids:444367152 -1387234500 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l1:level1
        {mso-level-text:"%1\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:.75in;
        text-indent:-.25in;}
@list l1:level2
        {mso-level-number-format:alpha-lower;
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        margin-left:1.25in;
        text-indent:-.25in;}
@list l1:level3
        {mso-level-tab-stop:1.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level4
        {mso-level-tab-stop:2.0in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level5
        {mso-level-tab-stop:2.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level6
        {mso-level-tab-stop:3.0in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level7
        {mso-level-tab-stop:3.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level8
        {mso-level-tab-stop:4.0in;
        mso-level-number-position:left;
        text-indent:-.25in;}
@list l1:level9
        {mso-level-tab-stop:4.5in;
        mso-level-number-position:left;
        text-indent:-.25in;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal>Tfpt review /shelveset:NewMethodBinder;tomat<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Affects outer DLR, Python, Ruby.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><b>DLR, Python<o:p></o:p></b></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Redesigns the default method binder:<o:p></o:p></p>
<p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>Merges ParameterBinder into MethodBinder, moves virtual
methods related to CLR method binding and parameter conversions from
ActionBinder and DefaultBinder to MethodBinder.<o:p></o:p></p>
<p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>MethodBinder is now an abstract class that provides
virtuals that languages can override. DefaultMethodBinder provides simple
implementation that languages can base their binders on or directly use.<o:p></o:p></p>
<p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>Enables “partially restricted splatting”
feature (only implemented in Ruby so far, but should be relatively easy to
generalize it and use it by default):<o:p></o:p></p>
<p class=MsoListParagraph style='margin-left:1.0in;text-indent:-.25in;
mso-list:l0 level2 lfo1'><![if !supportLists]><span style='mso-list:Ignore'>-<span
style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>Previous implementation required languages to pass the
binder an array of meta-objects including all items of the splatted array. This
is not feasible for splatting arrays containing thousands of items
(StackOverflow exception occurred in a Ruby library due to an expression of
depth greater than 5k constructed as a rule condition). The new implementation
allows the binder to only construct such conditions and restrictions that are
necessary to decide which overload to select. In the worse case, which occurs
e.g. when the overload set is { foo(params int[]), foo(params object[]) } and
the call-site is foo(*([1]*10000 + [‘x’])) , the condition that decides
whether an overload/rule is applicable is implemented using a loop rather than
disjunction of 10001 type equality expressions. Usually, the overload could be
selected by splatting the array partially, using few items of the array from
beginning and/or end of the array. More optimizations to the partial
splatting are certainly possible - those should be easy to implement on top of
the new method binder architecture if needed.<o:p></o:p></p>
<p class=MsoListParagraph style='margin-left:1.0in'><o:p> </o:p></p>
<p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>MethodBinder builds its state in several steps (see
ResolveOverload method):<o:p></o:p></p>
<p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in;
mso-list:l1 level1 lfo2'><![if !supportLists]><span style='mso-list:Ignore'>1)<span
style='font:7.0pt "Times New Roman"'> </span></span><![endif]>TargetSets
and MethodCadnidates are built – MethodCandidate represents a CLR method
overload tailored to a fixed arity (a follow-up refactoring will merge
MethodTarget into MethodCandidate, they map 1:1). TargetSet represents a set of
MethodCandidates (CanidateSet would be a better name – will rename in a
follow-up change) that match the same arity. Building MethodCandidates involve
creating ParameterWrappers and ArgBuilders. This process can be customized by
languages. Languages can define their own wrappers and builders, their own
dictionary and array splatting mechanisms. <o:p></o:p></p>
<p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in;
mso-list:l1 level1 lfo2'><![if !supportLists]><span style='mso-list:Ignore'>2)<span
style='font:7.0pt "Times New Roman"'> </span></span><![endif]>The
ActualArguments class is created (this is also customizable by languages).
ActualArguments instance holds on meta-objects of positional and named
arguments, actual argument names, and various indices needed for splatting.<o:p></o:p></p>
<p class=MsoListParagraph style='margin-left:.75in;text-indent:-.25in;
mso-list:l1 level1 lfo2'><![if !supportLists]><span style='mso-list:Ignore'>3)<span
style='font:7.0pt "Times New Roman"'> </span></span><![endif]>TargetSet
with arity corresponding to the number of actual arguments is created. If the
binder implements partial splatting, the array is splatted to match arities of
existing target sets but no more. The rest of the arguments (those that were
not extracted from the array) are referred to as “collapsed” and
are dealt with separately during overload resolution. The previous
implementation of “MakeBindingTarget” is replaced by a new one,
which fixes issues with named arguments and also takes collapsed arguments into
consideration. It has several steps:<o:p></o:p></p>
<p class=MsoListParagraph style='margin-left:1.25in;text-indent:-.25in;
mso-list:l1 level2 lfo2'><![if !supportLists]><span style='mso-list:Ignore'>a.<span
style='font:7.0pt "Times New Roman"'> </span></span><![endif]>Match
actual names of the arguments with parameter names, calculate permutations that
map indices of the former to the latter, and filter out MethodCandidates whose
parameter names don’t match. The result of this step is a set of
ApplicableCandidates, each ApplicableCandidate comprises of a MethodCandidate
and a ArgumentBinding permutation. <o:p></o:p></p>
<p class=MsoListParagraph style='margin-left:1.25in;text-indent:-.25in;
mso-list:l1 level2 lfo2'><![if !supportLists]><span style='mso-list:Ignore'>b.<span
style='font:7.0pt "Times New Roman"'> </span></span><![endif]>Then
for each narrowing level: Non-collapsed arguments are tested for convertibility
to the parameter types of the applicable overloads. Those overloads that
don’t match are removed from applicable candidates set. If no overloads
remain, it’s an error. If a single overload remains we successfully
chosen the overload (note that collapsed arguments don’t need to be
visited in this case). Otherwise we check whether collapsed arguments can all
be converted to the element type of the corresponding params-array. Again, if
no candidate remains, we failed. If a single one remains we succeeded. Otherwise
we continue by comparing various conversions and selecting the best ones based
on the current narrowing level.<o:p></o:p></p>
<p class=MsoListParagraph><o:p> </o:p></p>
<p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>During these steps the MethodBinder builds its state
(candidate sets, actual arguments, etc.) and derived method binders can also
remember some additional data/state that is used for building arguments or
error reporting (temporary variable that stores the splattee,
restrictions/conditions used for splatting, the signature of the call-site,
etc.). The MethodBinder should be instantiated with all information that
doesn’t change during overload resolution (the “input” to the
overload resolution).<o:p></o:p></p>
<p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>Renames ParameterBinderWithCodeContext to PythonMethodBinder
and moves it to Python.<o:p></o:p></p>
<p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>Moves SiteLocalStorage to Python. Ruby uses a different
storage class and it’s very simple for languages to define and use their
own.<o:p></o:p></p>
<p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>ActionBinder.BindSpecialParameter shouldn’t deal
with CodeContext and SiteLocalStorage – moved to PythonMethodBinder.<o:p></o:p></p>
<p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>Moved ContextArgBuilder and SiteLocalStorageArgbuilder
to Python.<o:p></o:p></p>
<p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>ArgBuilder.CanGenerateDelegate needs to be protected so
that custom ArgBuilders can override it.<o:p></o:p></p>
<p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>Improves errors reported by the method binder. <o:p></o:p></p>
<p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>Removes old call, invoke and operation actions
and related code.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><b>Ruby:<o:p></o:p></b></p>
<p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>Replaces calls to obsolete methods of default method
binder with those using meta-objects.<o:p></o:p></p>
<p class=MsoListParagraph style='text-indent:-.25in;mso-list:l0 level1 lfo1'><![if !supportLists]><span
style='mso-list:Ignore'>-<span style='font:7.0pt "Times New Roman"'>
</span></span><![endif]>Implements partially restricted splatting.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal>Fixes <a
href="http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=18379">http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=18379</a>.<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
</div>
</body>
</html>