Hello,
here a beginner's question:
Let us say I wrote two units: unit1 unit2 and there is a procedure called HelloWorld in each of them. May I call them by unit1.HelloWorld; unit2.HelloWorld; or is that not supported by gpc? What should I do in the last case?
Thanks for your answer.
Uli.
=======================================================================
www.pukruppa.de www.2000d.de
=======================================================================
On 2 Mar 2001, at 12:10, Peter Ulrich Kruppa wrote:
Hello,
here a beginner's question:
Let us say I wrote two units: unit1 unit2 and there is a procedure called HelloWorld in each of them. May I call them by unit1.HelloWorld; unit2.HelloWorld;
No.
or is that not supported by gpc?
No, it is not supported (yet). This is in the "to do" list, I think (it would be noted there as "qualified identifiers").
What should I do in the last case?
Rename one of the procedures, if the two units are going to be used in the same program.
Best regards, The Chief --------- Prof. Abimbola Olowofoyeku (The African Chief) Author of Chief's Installer Pro v5.24 for Win32 Email: African_Chief@bigfoot.com http://www.bigfoot.com/~african_chief/
Thanks to your answers.
I am very sorry to hear so. Actually I am a half-time-first-semester-student at Fernuni-Hagen. These "Qualified Identifiers" are a feature one would need to do some exercises for our "Einfuehrung in die imperative Programmierung" - Lecture. And: They seem to be the only missing feature. Everything else went well.
On Fri, 2 Mar 2001, Prof. A Olowofoyeku (The African Chief) wrote:
On 2 Mar 2001, at 12:10, Peter Ulrich Kruppa wrote:
Hello,
here a beginner's question:
Let us say I wrote two units: unit1 unit2 and there is a procedure called HelloWorld in each of them. May I call them by unit1.HelloWorld; unit2.HelloWorld;
No.
or is that not supported by gpc?
No, it is not supported (yet). This is in the "to do" list, I think (it would be noted there as "qualified identifiers").
What should I do in the last case?
Rename one of the procedures, if the two units are going to be used in the same program.
Best regards, The Chief
Prof. Abimbola Olowofoyeku (The African Chief) Author of Chief's Installer Pro v5.24 for Win32 Email: African_Chief@bigfoot.com http://www.bigfoot.com/~african_chief/
=======================================================================
www.pukruppa.de www.2000d.de
=======================================================================
Peter Ulrich Kruppa a écrit :
Hello,
here a beginner's question:
Let us say I wrote two units: unit1 unit2 and there is a procedure called HelloWorld in each of them. May I call them by unit1.HelloWorld; unit2.HelloWorld; or is that not supported by gpc? What should I do in the last case?
Unfortunately this "qualified identifiers" problems is on the todo list since a long time (in fact since I begun to work with gpc: I asked the same question at the very beginning when trying to port BP programs to gpc). No other way at present time than to give an other name to one of the two HelloWorld. Seems to need a major rewriting in gpc.
Hope this helps
On Fri, 2 Mar 2001, Maurice Lombardi wrote:
HelloWorld. Seems to need a major rewriting in gpc.
I think it can be added without much effort. One possibility is to set the root node to the unit or program name, then create a seperate symbol table for each. When it's necessary to create jump targets/etc, just combine the unit name with the identifier.
For example...
unit Foo;
interface
var FooInt : Integer;
procedure CallFoo;
implementation
{...}
end.
program Bar;
uses Foo;
procedure CallFoo; {...}
begin {...} end.
One Symbol Table would have a name of "Foo" with symbol nodes "FooInt" and "CallFoo". If referenced, they would be referred to as "Foo_FooInt" and "Foo_CallFoo". The other Symbol Table would have a name of "Bar" with a symbol node of "CallFoo". If referenced, it would be called "Bar_CallFoo".
Obviously this leaves out things such as scope, as well as a thing or two I haven't thought of, but hopefully it gives you an idea of how it can be implemented.
See ya! Orlando Llanes
"Meine Damen und Herren, Elvis hat soeben das Gebaeude verlassen!"
"Look out fo' flyeeng feet" O__/ ollanes@pobox.com /|____. O <__. /> / \ ____________|_________ http://pages.prodigy.net/ollanes/ (inactive)
Hi, GPC folks,
Orlando Llanes wrote:
[Qualified identifiers ...]
I think it can be added without much effort. One possibility is to set
the root node to the unit or program name, then create a seperate symbol table for each. When it's necessary to create jump targets/etc, just combine the unit name with the identifier. [...]
Exactly.
BTW, that's about the same way how methods of objects are implemented. Currently, a method "Foo" of a method "Bar" is named "Bar_Foo". (In contrast, if you define your own "procedure Bar_Foo" it becomes "Bar_foo", internally.)
When doing this correctly, we must make sure that there are no name clashes - between units and objects, and in no other way. Thus, at the same time, the OOP naming scheme should be rewritten.
Now becoming more technical ...
Currently, the IDENTIFIER_LIMBO_VALUE slot in the IDENTIFIER_NODE (inherited from the C front-end) is (mis-)used to allow for importing only parts of a module (in Extended Pascal) and such. The correct re-write for Pascal would drop IDENTIFIER_LIMBO_VALUE in favour of a whole TREE_LIST of IDENTIFIER_UNIT_VALUEs for one identifier.
At the same time, we would introduce yet another slot in the IDENTIFIER_NODE in order to preserve the upper nad lower case of the identifier as typed by the Pascal programmer (for error messages and such).
While all this is not _that_ difficult but more or less straightforward, it is time-consuming and must be done very carefully, together with clean-ups at various places in the compiler which have to do with the naming of identifiers. I expect that I would need two full days of concentrated work to reach the goal - plus some period for testing, bug-fixing etc.
Unfortunately, I currently cannot work for a single hour without being interrupted by a phone call, an urgent email, or the next date. And currently I must assign priorities according to the amount of money I get for the job on a short time scale.
BTW, qualified identifiers are one of the top items _after_ the "Urgent" part of the GPC TODO list. And the integration of GPC into gcc-3.0 is still in progress.
To summarize:
I consider qualified identifiers a very important feature - also for my own work -, and I know what has to be done in order to implement them. However I see no possibility to do the actual work on a short time scale. Sorry for that.
If anyone wants to try him/herself on the job I can help.
Peter
Peter Gerwinski wrote:
Hi, GPC folks,
Orlando Llanes wrote:
[Qualified identifiers ...]
I think it can be added without much effort. One possibility is to set
the root node to the unit or program name, then create a seperate symbol table for each. When it's necessary to create jump targets/etc, just combine the unit name with the identifier. [...]
Exactly.
BTW, that's about the same way how methods of objects are implemented. Currently, a method "Foo" of a method "Bar" is named "Bar_Foo". (In contrast, if you define your own "procedure Bar_Foo" it becomes "Bar_foo", internally.)
When doing this correctly, we must make sure that there are no name clashes - between units and objects, and in no other way. Thus, at the same time, the OOP naming scheme should be rewritten.
Since objects type names should also be qualified then, this should not clash...
Frank