Hello,
I am not on pop-forum, hence any replies on comp.lang.pop appreciated
The new objectclass library in poplog 15.0 is an excellent
development. But there is one serious limitation. Although
procedures can be have different *types* of arguments it is not
possible to have varying *number* of arguments for a given procedure
name
eg 2D geometry
define translate(pt:point,dx,dy)
.....
enddefine;
define translate(pt:point,refpt:point,dx,dy)
....
enddefine;
In the second case i wish to supply one more argument but this is
illegal in pop11. The arity of the methods will depend on which
method is compiled first.
I have resorted to the rather inelegnt 'printf' way of handling
multiple arguments where I send the arguments in a list and I use a
procedure to determine the argument types and finally apply the
correct procedure.
sample procedure call :-
---------------------------------
translate(pt,[^dx ^dy]);
translate(pt,[^refpt ^dx ^dy]);
underlying code :-
-------------------------
define translate(obj,arglist); /* handling function */
examine arguments
decide on procedure to apply
apply appropriate method
enddefine;
point_translate1(pt:point,dx,dy);
point_translate2(pt:point,refpt:point,dx,dy);
segment_translate1(pt:point,dx,dy);
segment_translate(pt:point,refpt:point,dx,dy);
This messy implementation can be avoided if poplog's objectclass
allowed methods to have a varying number of arguments. I guess this
is related to the compiler deciding how many items to read off the
stack but I am sure this can be overcome..
This is a suggestion and hope it will be taken up.
regards,
suresh.
Suresh Kannan
Aerospace Engineering
University of Manchester
suresh@roja.demon.co.uk
"Never wrestle a pig, you get dirty and it only irritates the pig"
- Leon the pig farmer
|