Thank you for your answers. I would like to summarize the parts of my suggestion that I think are possible to implement acording to the answers.
First let me state, that the graph-unit is only an example. I took this example, because its IMHO really silly and very bad style to write a graphics unit for only one chip-videoboard-monitor-combination (further referenced only as the "card").I use for graphics the VESA-API.
Assume the BP-style-graph-unit and a self-made keyboard-unit and a mouse-unit. Now you want to do 3 things :
* put all of them into 2 units to make it possible to give them all away as ONE unit, not as a confusing bunch of files. You want to have one communication-with-the-user-unit and not much for different aspects. * rewrite putpixel and line to make them faster on _your_ card. * log all mouse activities to a file (can't think of a reason for that, just assuming)
the syntax would be :
///// EXAMPLE BEGINS ////////////////////
unit communication(graph,keyboard,mouse);
interface
...no interface because its unchanged ...new/changed procedures or variables would be declared here
implementation
var logfile:text;
procedure putpixel(x,y:integer); begin ...do some stuff end;
procedure line(..); begin ...write that line end;
procedure mouse_reset(); begin writeln(logfile,`mouse resetet at `,mouse_x,` `,mouse_y); inherited mouse_reset; end; ...the same with all mouse procedures
begin assign(logfile,`log`); rewrite(logfile); inherited begin; (*or inherited init? or inherited main? Don't know which is better*) end.
//////// EXAMPLE ENDS ////////////////////////
New syntax-elements needed : 1.) "unit foo(bar1,bar2,..);" 2.) "inherited <someprocedure>;" Advantages are, that this new syntax is IMHO very intuitive and uses existing keywords by carefully extending their meaning.
Discussion of the new syntax: ---------------------------- 1.) The "unit foo(bar);" part would be simple(?,IMHO): Its just that all interfaces are put after each other in order of appearence.
2.) The "inherited <someprocedure>;" part should be possible too. You have procedure-overloading. As far as I know from C++ this is implemented by translating names of procedures :
procedure foo(s:string) -> asmname "foostring" (the identifier in the) procedure foo(i:integer) -> asmname "foointeger" (.o-file, just example)
The .gpi-file includes a mapping asmname<->pascalname of all funtions that the compiler can put a call to "foostring" for a command like foo(`bar!bar??BAR!!`) and a call to "foointeger" for foo(10).
Assuming our example, the compiler reads the line "inherited putpixel(..);". It looks for the asmname of graph.putpixel and calls it. Communication.putpixel then gets its own asmname which has to be different from the one of graph.putpixel.
This is just my imagination. I'm not an expert of compiling, I just know how to type "gcc foo.c -o foo.exe" so don't take the above lines too serious.
Yours
Hans