Cross-platforming C++ functions to APL

旧巷老猫 提交于 2020-01-05 08:37:11

问题


I am currently writing C++ programs for APL. Up to now, what I've been doing is creating a function in APL, which runs the command prompt and calls the executable, with input and output files it creates as parameters and in turn, the C++ executable is programmed to open the input file, read the input and store the output in the output file, which is fetched by the APL function and stored in one or more variables. The problem with this method is that, when I use simpler functions which will be called a lot or sometimes recursively, opening and closing files all the time for a simple computation take up a lot of the processing time. What I am trying to find out is a way to call a function that is written in C++, either from a solution or a library, and use it directly in my APL workspace.

For example I have a function in C++ written in this form:

Xadd(int x, int y);

and want to write it in APL like this Xadd (x) (y) and be able to later open it through APL using ∇Xadd. Thanks.


回答1:


I didn't quite get if you're call CPP functions from APL or vice versa. And you didn't specify which flavour APL you're coding, but you might want to check out these concepts:

  • Shared Variable: ⎕SVO
  • Auxillary Processor
  • Calling compiled programs: ⎕NA
    • Check out chapter 28 in the System Services Reference: LINK for IBM APL2/370.



回答2:


I would first compile the Xadd function in a DLL with a single entry point, then experiment with []NA. A helpful stepping stone might be to first get the DLL call working with VBA in Excel (or Word or any other MS Office application which uses VBA), then move on to APL.



来源:https://stackoverflow.com/questions/24812963/cross-platforming-c-functions-to-apl

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