Call-site explanation?

后端 未结 2 906
别跟我提以往
别跟我提以往 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 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.

提交回复
热议问题