eval in Objective-C [duplicate]

末鹿安然 提交于 2019-11-29 12:35:45

Neither the language nor Apple's frameworks directly support such a thing. However, one of the goals of LLVM is to be an embeddable compiler suite. I'm pretty sure it can generate executable code right into memory. The hard part would be providing that code with access to the pre-existing environment of the calling code. For example, compiling code which references a local variable or something like that.

(Mind you, this approach is forbidden for the iOS App Store, but it could maybe be workable on Mac OS X.)

Absolutely not. Objective-C is a fully compiled language. Only interpreted languages can do that sort of thing.

No. Code eval is the feature for dynamic language. Although objective-C has dynamic feature , and even Cocoa runtime , it is still considered as a static language (generally).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!