Professional IronPython



Download 20,35 Mb.
Pdf ko'rish
bet318/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   314   315   316   317   318   319   320   321   ...   453
304

CHAPTER 14
InteractIng wIth the DLr
FIgURE 14-6: 
The output shows the process used to work with dynamic objects.
The point of all this is that you can implement a kind of dynamic object strategy for static languages, 
but it’s cumbersome compared to IronPython. You might use this approach when you need to provide 
a dynamic strategy for something small within C# or Visual Basic. This technique is also useful for 
understanding how IronPython works, at a very basic level. IronPython is far more robust than the 
code shown in this example, but the theory is the same.
UNDERSTANDINg THE ACTIONbINDER
In the section “Considering DynamicSite” earlier in this chapter, you discovered how DLR makes it 
possible to invoke dynamic code from within a static environment using a 
DynamicSite
object. The 
actual process for creating the method invocation call is to create an Abstract Syntax Tree (AST). 
The AST has functions assigned to it using an 
Assign()
method. When DLR wants to assign a 
new function to AST, it supplies a function name and provides a calling syntax using the 
Call()
method. The 
Call()
method accepts four arguments.
➤➤
An object used to hold the function. Normally, the code calls the 
Create()
method of the 
host class using 
GetMethod(“Create”)
.
A constant containing the name of the function as it appears within the host object.


The array of arguments supplied to the function.




A delegate instance used to invoke the code later. It’s this argument that you consider when 
working with an 
ActionBinder
.
At this point, you have an object that holds the parameters of the function call, as well as a delegate 
used to execute the function. The problem now is one of determining how to call the function. After 
all, the rest of your code knows nothing about the delegate if you create it during run time, as is the 
case when working with dynamic languages. If none of the code knows about the delegate, there 
must be some way to call it other than directly.
548592c14.indd 304
2/24/10 12:49:09 PM
www.finebook.ir



Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   314   315   316   317   318   319   320   321   ...   453




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish