I am trying to understand how PL/I handles defined structures, i.e. how to use a stronger typing discipline in my PL/I programs. When I define a named type using define structure I have two ways to use that type in my code:
- Using a handle, e.g. dcl foo handle Bar
- Using type, e.g. dcl foo type Bar
It seems I cannot use type when I want to create a recursive type such as List:
define structure 1 List;
define structure 1 List,
2 head pointer,
2 tail handle List;
However, in most other situations I cannot really tell when to use one over the other. I'm guessing there must be a difference between when memory is allocated, because handles are typed pointers, but I'm not really sure.
I have read the relevant sections of the language reference a number of times, but I have not been able to find a straight answer, better than that handles are typed pointers. I hope someone here can help clarify two things for me:
- When to use one over the other
- The difference between the two in terms of what the compiler does
I asked this question on twitter to @IBM_compilers and was in turn asked to ask my question here.