Thanks for the response, paule32,
If I understand you you suggest that, in the implementation section of SymUtil, I include
But this would create exactly the loop that you suggest I am trying to avoid. Wouldn't it?
<Pause while I just try it>
I set up a Lab environment (TestScope - attached). It's pretty minimal, so I've got it here:
First - a unit that defines a couple of identifiers:
unit DefiningUnit;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils;
const
alfalen = 16;
type
DefiningEnum = (
value0,
value1);
implementation
end.
then a unit that consumes (or uses) those identifiers:
unit ConsumingUnit;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils,
DefiningUnit;
var
CUVar1 : DefiningEnum;
CUVar2 : array [1..alfalen] of integer;
implementation
end.
mirabile dictu this works (without the additional 'reverse' uses clause).
So, why does it not work when there's a load of extra stuff in each of the units (symutil & lexutil)?
Just for kicks, I googled the following question:
what parts of the interface section of a Lazarus unit are available to code that uses the unit?
and received the following response from their AI bot:
In a Lazarus unit, the interface section defines what parts of the unit are publicly available to other units or programs that uses it. This includes declarations of types, constants, variables, procedures, functions, classes, and interfaces that are intended for external use.
Elaboration:
uses clause:
The uses clause at the beginning of the interface section specifies other units that are needed by the current unit. This helps the compiler resolve references to types, variables, and other declarations defined in those other units.
Types, constants, variables, and interfaces:
Declarations of these elements made in the interface section become accessible to other units that use the current unit.
Procedures and functions:
Declarations of procedures and functions in the interface section become available to other units for calling and using their functionality.
Classes:
The declarations of classes in the interface section, including their public members (methods and properties), become accessible to other units.
Initialization and finalization blocks:
While these are not directly part of the interface, their presence is typically indicated in the interface section and they can contain code that runs when the unit is loaded or unloaded.
Implementation details are hidden:
The implementation section of the unit contains the actual code for procedures, functions, and methods declared in the interface. This code is not exposed to external units and is only visible to the current unit.
In essence, the interface section acts as a contract, defining the publicly available API of the unit. Other units that include it in their uses clause can access and use the declarations in the interface section, but they cannot access the implementation details.
The AI matches my expectation of what
should happen. So, what am I doing wrong in the original (CATCOMP) post?
Tony