Call-site explanation?

后端 未结 2 901
别跟我提以往
别跟我提以往 2021-01-31 20:35

scaning the internet , im having trouble understanding in a simple manner - the term call-site (@dlr). ive been reading here that CallSite is :

one site says

相关标签:
2条回答
  • 2021-01-31 20:54

    The first explanation has nothing to do with the dlr or the dynamic type: simply speaking, a call site is a location (or site) in the source code where a method is called.

    In implementing the dynamic type, it is necessary to store information about the dynamic method calls contained in your code, so they can be invoked at runtime (the dlr needs to look up the method, resolve overloads, etc.). It seems natural that the object representing this information should also be called a ”call site”.

    0 讨论(0)
  • 2021-01-31 21:05

    Ok this is how I see it.

    For this example call is simply like a method or function that executes some code and returns.

    For a static language runtime program (C, or CLR etc) a call site is essentially where a function call takes place. It's the location that the call will return to in a normal (non exceptional) flow. Since this is a static program the call site is simply a memory location, pushed on the stack.

    For a dynamic language program (Ruby, Python, etc) , the code you are calling is not worked out until runtime. This means that some form of logic is needed to manage the process of making the correct function call and then cleaning up after the call (if needed). If the dynamic language program is on .NET 4 this is done using dlr (dynamic language runtime) objects of type System.Runtime.CompilerServices.CallSite. So the call will return to a method within the CallSite object and then on to location of the original call.

    So the answer is that it depends upon how you doing the call and thus what platform you are using.

    0 讨论(0)
提交回复
热议问题