Welcome
Welcome to MicroAPL's Support Forum for APLX.


You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, join our community today!

[]NA and Objects

Tips, tricks and techniques for migrating APL applications from other versions of APL to APLX

[]NA and Objects

Postby Lobachevsky on Mon Sep 08, 2008 11:38 am

I have a lot of functions which are very similar to this. They came from Dyalog. This function creates and calls a []NA version of itself.

z := glNormal3f x
:If 3 <> []NC 'glNormal3f_DLL'
'glNormal3f_DLL' []NA'OpenGL32.DLL.C32|glNormal3f F4 F4 F4'
:EndIf
z := glNormal3f_DLL x

What I started to do is group families of functions together such that they all live in one object. I use []IC to do this, i.e.

'gl' []IC 'glNormal' (I will eventually rename the functions to remove the "gl")


Now I would like the []NA function to live in the object. I would be inclined to write:

z := Normal3f x
:If 3 <> gl.[]NC 'Normal3f_DLL'
'Normal3f_DLL' gl.[]NA'OpenGL32.DLL.C32|glNormal3f F4 F4 F4'
:EndIf
z := Normal3f_DLL x

This doesn't work, but I can write

'gl' []IC 'Normal3f_DLL' gl.[]NA'OpenGL32.DLL.C32|glNormal3f F4 F4 F4'

Can I do better than this? Is there any advantage to having named instances?
Lobachevsky
 
Posts: 16
Joined: Sun Jul 27, 2008 6:33 pm

Re: []NA and Objects

Postby MicroAPL on Mon Sep 08, 2008 4:16 pm

You are slightly ahead of us here! We realised a few weeks ago that it would be very useful to extend ⎕NA so that it can be used as a Method in the way you describe:

classname.⎕NA


However, that isn't yet implemented. For the moment, yes, you can use first define the external function as a global, and then use ⎕IC to transfer it into a class.

Usually, these will simply be methods of the class which don't require an instance. However, in some cases you might want to define a private method which is the external function, and a public method (of a different name) which calls the private method. This, for example, could be used to hide a handle which needed to be passed into each external function call.

By the way, if you are using classes containing external methods, make sure you are using APLX Version 4.1.10 or later; we fixed a couple of bugs in the Class editor which prevented you from displaying external methods or setting them to be private scope.
MicroAPL
Site Admin
 
Posts: 166
Joined: Tue Jul 08, 2008 5:25 pm


Return to Migrating from other APLs