[Lazarus] Identifier not found, but code completion works....

classic Classic list List threaded Threaded
57 messages Options
123
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Identifier not found, but code completion works....

Bo Berglund
I am testing an old Delphi communications component with lazarus. I
don't want to install it as a component but instead create it in code.
So I have started a new project and added the path to the Serial unit
to the project options (Other Unit files).
I also included it in the uses clause.

In my form I have put code to create it and set its properties like
this:

procedure TForm1.FormCreate(Sender: TObject);
begin
  serComm := TSerial.Create(NIL);
end;

procedure TForm1.btnOpenClick(Sender: TObject);
begin
  serComm.Baudrate := 38400;
  serComm.DataBits := d8bit;
  serComm.StopBits := st1bit;
  serComm.FlowMode := fcNone;
  serComm.Port := 1;
  serComm.Active := true;
end;

When I did this lazarus showed me hints on what I could select when I
added the period after the serComm name, so I know that it is known by
lazarus.
But when I try to run the program lazarus shows an error:

unit1.pas(22,21) Error: Identifier not found "TSerial"

But TSerial is the class name for the component and it is found by
lazarus when I write the code, so why in heavens name does it not find
it when compiling???????


Bo Berglund


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Identifier not found, but code completion works....

Thomas Gatliff
First, one thing I can say about the fpc is that it is a pretty solid piece of code.  Yes, it does have some different quirks with delphi (overloading for example), but in over 1,000,000 lines of code I have personally compiled I have not (recently) found even one instance where it was a bug related to the fpc.  Meaning, I always start off by questioning what I did wrong first before blaming the compiler.  That is just me, though...  Now on to your question...

It sounds like it fpc parser does not like your class file name for some reason.  This is just a guess, however without looking at an strace output.   Try several things... First, remove the file and see if it complains.  If that does not work, baby step it by creating a new file with a different class name...  If you still cannot figure it out, then send the files to [hidden email] and I will see what happened.

On Thu, Feb 10, 2011 at 5:41 PM, Bo Berglund <[hidden email]> wrote:
I am testing an old Delphi communications component with lazarus. I
don't want to install it as a component but instead create it in code.
So I have started a new project and added the path to the Serial unit
to the project options (Other Unit files).
I also included it in the uses clause.

In my form I have put code to create it and set its properties like
this:

procedure TForm1.FormCreate(Sender: TObject);
begin
 serComm := TSerial.Create(NIL);
end;

procedure TForm1.btnOpenClick(Sender: TObject);
begin
 serComm.Baudrate := 38400;
 serComm.DataBits := d8bit;
 serComm.StopBits := st1bit;
 serComm.FlowMode := fcNone;
 serComm.Port := 1;
 serComm.Active := true;
end;

When I did this lazarus showed me hints on what I could select when I
added the period after the serComm name, so I know that it is known by
lazarus.
But when I try to run the program lazarus shows an error:

unit1.pas(22,21) Error: Identifier not found "TSerial"

But TSerial is the class name for the component and it is found by
lazarus when I write the code, so why in heavens name does it not find
it when compiling???????


Bo Berglund


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Identifier not found, but code completion works....

Graeme Geldenhuys
In reply to this post by Bo Berglund
Op 2011-02-11 00:41, Bo Berglund het geskryf:
> But TSerial is the class name for the component and it is found by
> lazarus when I write the code, so why in heavens name does it not find
> it when compiling???????

As far as I know Lazarus uses CodeTools for code navigation - that is
different to the information used by the compiler (FPC) to compile your
project.

Select "Project -> Project Options -> Show Options" and have a look an
see if the path is indeed supplied and or correct, so FPC can find the
unit TSerial component resides in.



Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Identifier not found, but code completion works....

Mattias Gaertner
In reply to this post by Bo Berglund
On Thu, 10 Feb 2011 23:41:27 +0100
Bo Berglund <[hidden email]> wrote:

> I am testing an old Delphi communications component with lazarus. I
> don't want to install it as a component but instead create it in code.
> So I have started a new project and added the path to the Serial unit
> to the project options (Other Unit files).
> I also included it in the uses clause.
>[...]
> When I did this lazarus showed me hints on what I could select when I
> added the period after the serComm name, so I know that it is known by
> lazarus.
> But when I try to run the program lazarus shows an error:
>
> unit1.pas(22,21) Error: Identifier not found "TSerial"
>
> But TSerial is the class name for the component and it is found by
> lazarus when I write the code, so why in heavens name does it not find
> it when compiling???????

Do you have units with upper case letters in the file name?
Maybe you have two units with the same name.
Go to your uses section, where Serial is uses. Place source editor
cursor at the end of the used unit name and use Ctrl+Space to fix the
case.

Mattias

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Identifier not found, but code completion works....

Mattias Gaertner
On Fri, 11 Feb 2011 09:20:25 +0100
Mattias Gaertner <[hidden email]> wrote:

> On Thu, 10 Feb 2011 23:41:27 +0100
> Bo Berglund <[hidden email]> wrote:
>
> > I am testing an old Delphi communications component with lazarus. I
> > don't want to install it as a component but instead create it in code.
> > So I have started a new project and added the path to the Serial unit
> > to the project options (Other Unit files).
> > I also included it in the uses clause.
> >[...]
> > When I did this lazarus showed me hints on what I could select when I
> > added the period after the serComm name, so I know that it is known by
> > lazarus.
> > But when I try to run the program lazarus shows an error:
> >
> > unit1.pas(22,21) Error: Identifier not found "TSerial"
> >
> > But TSerial is the class name for the component and it is found by
> > lazarus when I write the code, so why in heavens name does it not find
> > it when compiling???????
>
> Do you have units with upper case letters in the file name?
> Maybe you have two units with the same name.
> Go to your uses section, where Serial is uses. Place source editor
> cursor at the end of the used unit name and use Ctrl+Space to fix the
> case.

I just got the same error.
The cause was a cross unit reference. Implementation uses sections are
evil. It's near impossible to create simple bug reports for such
compiler bugs.

Mattias

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Identifier not found, but code completion works....

Bo Berglund
In reply to this post by Graeme Geldenhuys
On Fri, 11 Feb 2011 08:39:18 +0200, Graeme Geldenhuys
<[hidden email]> wrote:

>Op 2011-02-11 00:41, Bo Berglund het geskryf:
>> But TSerial is the class name for the component and it is found by
>> lazarus when I write the code, so why in heavens name does it not find
>> it when compiling???????
>
>As far as I know Lazarus uses CodeTools for code navigation - that is
>different to the information used by the compiler (FPC) to compile your
>project.
>
>Select "Project -> Project Options -> Show Options" and have a look an
>see if the path is indeed supplied and or correct, so FPC can find the
>unit TSerial component resides in.
>
>
Thanks, but this is my options:

-MObjFPC -Scghi -O1 -gl -WG -vewnhi -l -Filib\i386-win32
-FuC:\Engineering\Projects\Lazarus\cmp\Serial
-FuC:\Programs\lazarus_0_9_30_fixes\lcl\units\i386-win32
-FuC:\Programs\lazarus_0_9_30_fixes\lcl\units\i386-win32\win32
-FuC:\Programs\lazarus_0_9_30_fixes\packager\units\i386-win32 -Fu.
-FUlib\i386-win32\ -oproject1.exe -dLCL -dLCLwin32

Notice the second line....
That is where the Serial.pas file resides and where it is picked up by
the IDE.

Now I tried to enter the path to this dir in the project options for
"Other sources" instead, but the compile error is exactly the same.
The file is named Serial.pas and it contains amongst others this:

unit Serial;
...
interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs,Windows;

type
...
  { TSerial main class }

  TSerial = class(TComponent)
  private

etc

Do I need to add some kind of switch telling FPC that this file
originated in Delphi? I seem to recall that there is such a marker,
but I don't know what it looks like.


Bo Berglund


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Identifier not found, but code completion works....

Bo Berglund
In reply to this post by Mattias Gaertner
On Fri, 11 Feb 2011 09:20:25 +0100, Mattias Gaertner
<[hidden email]> wrote:

>On Thu, 10 Feb 2011 23:41:27 +0100
>Bo Berglund <[hidden email]> wrote:
>
>> But TSerial is the class name for the component and it is found by
>> lazarus when I write the code, so why in heavens name does it not find
>> it when compiling???????
>
>Do you have units with upper case letters in the file name?
>Maybe you have two units with the same name.
>Go to your uses section, where Serial is uses. Place source editor
>cursor at the end of the used unit name and use Ctrl+Space to fix the
>case.
>

Ther unit file is Serial.pas
There is no other file named like this in any case style.

What I did was to go to the uses clause put the cursor on the word
Serial and use the pop-up menu command "Open file at cursor", which
brought the file into the editor...
Ctrl-Space does nothing other than pop up a window with three names,
the top being Serial.


Bo Berglund


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Identifier not found, but code completion works....

Mattias Gaertner
On Fri, 11 Feb 2011 18:34:54 +0100
Bo Berglund <[hidden email]> wrote:

> On Fri, 11 Feb 2011 09:20:25 +0100, Mattias Gaertner
> <[hidden email]> wrote:
>
> >On Thu, 10 Feb 2011 23:41:27 +0100
> >Bo Berglund <[hidden email]> wrote:
> >
> >> But TSerial is the class name for the component and it is found by
> >> lazarus when I write the code, so why in heavens name does it not find
> >> it when compiling???????
> >
> >Do you have units with upper case letters in the file name?
> >Maybe you have two units with the same name.
> >Go to your uses section, where Serial is uses. Place source editor
> >cursor at the end of the used unit name and use Ctrl+Space to fix the
> >case.
> >
>
> Ther unit file is Serial.pas
> There is no other file named like this in any case style.

Maybe
fpc/rtl/unix/serial.pp

 
> What I did was to go to the uses clause put the cursor on the word
> Serial and use the pop-up menu command "Open file at cursor", which
> brought the file into the editor...
> Ctrl-Space does nothing other than pop up a window with three names,
> the top being Serial.

I get only one. The one from fpc.

Compile with -vt and see if fpc loads the right unit.
If yes, check for implementation uses sections. Maybe you have the fpc bug I wrote in the other mail.


Mattias

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Identifier not found, but code completion works....

Bo Berglund
In reply to this post by Bo Berglund
On Thu, 10 Feb 2011 23:41:27 +0100, Bo Berglund
<[hidden email]> wrote:

>unit1.pas(22,21) Error: Identifier not found "TSerial"

I finally managed to get my file recognized by *both* lazarus and fpc.
This is how:

1) In project inspector I *added* the Serial.pas file to the project.

2) In the Serial.pas file I added the following conditionals:
At the top of the file:
{$ifdef fpc}
  {$mode delphi}
{$endif}

further down I had to remove two uses files:
uses
  SysUtils,
  {$ifndef fpc}
  WinTypes,
  WinProcs,
  {$endif}

Now the test project compiles all right, but unfortunately it does not
work and I don't know if this is caused by:
- My PC has only one real serial port (in the docking station) so all
  others are via USB adapters.
- Some confusion caused by VMWare in my virtual machine when mapping
  com ports.
- My own shortcomings in using lazarus/fpc

I even copied the test program exe file over to my host and tried to
communicate via the serial ports to a Hyperterminal running on the
host using a null-modem cable between the real com port and one of the
USB ones. No go....
So this test with my old and proven Delphi serial component seems not
to work out, and it would not have sufficed anyways because I need
cross-platform compilation.

In any case right now I have only one working configuration for the
real project I am working on:
- Development in the virtual machine (no lazarus/FPC on the physical
laptop)
- Program uses COM1 in the virtual machine
- VMWare maps virtual machine COM1 to host COM1 (the real port)
- The other end of the connection is a simulator I am always using
when developing stuff and it connects to one of the USB ports (the
ATEN one is the only one working).

Seems to be a real bugger to get serial ports working properly and I
cannot rule out my laptop itself either. I got it in December and it
has Win7x64 whereas I always used WinXP-Pro for the last 8-9 years or
so. Maybe the Windows drivers are not up to speed?
The SUNIX device uses the Prolific serial converter chip and driver.
I think that basically it is a 4-way USB hub followed by 4 individual
Prolific RS232 converters in one box.

Has anyone here successfully used SdpoSerial in lazarus on Win7x64
towards a SUNIX ComHub 4-channel adapter???


Bo Berglund


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Identifier not found, but code completion works....

Graeme Geldenhuys
In reply to this post by Bo Berglund
Op 2011-02-11 19:29, Bo Berglund het geskryf:
>
> Notice the second line....
> That is where the Serial.pas file resides and where it is picked up by
> the IDE.

Umm, then I have no clue, sorry.



>
> unit Serial;

  {$IFDEF FPC}
    {$mode delphi}{$H+}
  {$ENDIF}

> interface
>
> uses
>   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
>   Forms, Dialogs,Windows;
>
> type
> ...
>   { TSerial main class }
>
>   TSerial = class(TComponent)
>   private
>
> etc
>
> Do I need to add some kind of switch telling FPC that this file
> originated in Delphi?


Normally you would add the code shown above (below the 'unit' line).



Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Identifier not found, but code completion works....

Bo Berglund
In reply to this post by Mattias Gaertner
On Fri, 11 Feb 2011 15:30:48 +0100, Mattias Gaertner
<[hidden email]> wrote:

>On Fri, 11 Feb 2011 09:20:25 +0100
>Mattias Gaertner <[hidden email]> wrote:
>
>> On Thu, 10 Feb 2011 23:41:27 +0100
>> Bo Berglund <[hidden email]> wrote:
>>
>> > I am testing an old Delphi communications component with lazarus. I
>> > don't want to install it as a component but instead create it in code.
>> > So I have started a new project and added the path to the Serial unit
>> > to the project options (Other Unit files).
>> > I also included it in the uses clause.
>> >[...]
>> > When I did this lazarus showed me hints on what I could select when I
>> > added the period after the serComm name, so I know that it is known by
>> > lazarus.
>> > But when I try to run the program lazarus shows an error:
>> >
>> > unit1.pas(22,21) Error: Identifier not found "TSerial"
>> >
>> > But TSerial is the class name for the component and it is found by
>> > lazarus when I write the code, so why in heavens name does it not find
>> > it when compiling???????
>>
>> Do you have units with upper case letters in the file name?
>> Maybe you have two units with the same name.
>> Go to your uses section, where Serial is uses. Place source editor
>> cursor at the end of the used unit name and use Ctrl+Space to fix the
>> case.
>
>I just got the same error.
>The cause was a cross unit reference. Implementation uses sections are
>evil. It's near impossible to create simple bug reports for such
>compiler bugs.
>
Could you expand on this?

I am used to my Delphi practice of putting uses references as far down
the ladder as possible.
This means that if something is not needed in the interface section I
routinely put it into the implementation uses.

Is this bad practice with FPC/Lazarus?


--
Bo Berglund
Developer in Sweden


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Identifier not found, but code completion works....

Mattias Gaertner
On Sat, 19 Feb 2011 15:11:13 +0100
Bo Berglund <[hidden email]> wrote:

>[...]
> >> >[...]
> >> > When I did this lazarus showed me hints on what I could select when I
> >> > added the period after the serComm name, so I know that it is known by
> >> > lazarus.
> >> > But when I try to run the program lazarus shows an error:
> >> >
> >> > unit1.pas(22,21) Error: Identifier not found "TSerial"
> >
> >I just got the same error.

... with another unit and identifier.

> >The cause was a cross unit reference. Implementation uses sections are
> >evil. It's near impossible to create simple bug reports for such
> >compiler bugs.
> >
> Could you expand on this?
>
> I am used to my Delphi practice of putting uses references as far down
> the ladder as possible.
> This means that if something is not needed in the interface section I
> routinely put it into the implementation uses.
>
> Is this bad practice with FPC/Lazarus?

The general idea is a good one, because this could help to avoid
unneeded/accidental dependencies in the interface.
OTOH I never got that case in reality, so I wonder if this really
helps someone.
For the program size or unit dependencies it does not
matter if the unit is used in the implementation or the interface.
The implementation uses section has some disadvantages:
1. It can redefine types. For example using the Windows unit redefines
TRect.
2. You can create "circular" dependencies without noticing.
2.1 Circular dependencies make it hard to tell the order of
initialization sections.
2.2 Combined with some optimization features the compiler
has to recompile some units multiple times. Since I know FPC this
process had bugs, resulting in strange errors. The FPC team did a
great job to fix all they could reproduce. The problem is that the
remaining bugs happen only in big programs and it is near
impossible to create a small example, so these bugs are not reported
and therefore not fixed.
2.3 Circular dependencies make refactoring a lot harder.
3. The uses section is split, reducing readability.

Conclusion: I don't see any real advantage but I see some
disadvantages, so I recommend to avoid the implementation uses section
whenever possible.


Mattias

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Identifier not found, but code completion works....

Hans-Peter Diettrich
In reply to this post by Bo Berglund
Bo Berglund schrieb:

>> The cause was a cross unit reference. Implementation uses sections are
>> evil. It's near impossible to create simple bug reports for such
>> compiler bugs.
>>
> Could you expand on this?

IMO this applies to bugreports (only). The unit order in uses clauses is
always important, regardless of one or two such clauses.

> I am used to my Delphi practice of putting uses references as far down
> the ladder as possible.
> This means that if something is not needed in the interface section I
> routinely put it into the implementation uses.
>
> Is this bad practice with FPC/Lazarus?

FPC can have some problems with macros, inlines and other constructs,
that may require a recompilation of units. But apart from that
(acceptable) issue I don't see real obstacles right now.

DoDi


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Identifier not found, but code completion works....

Alexander Klenin
In reply to this post by Mattias Gaertner
On Sun, Feb 20, 2011 at 01:03, Mattias Gaertner
<[hidden email]> wrote:

>1. It can redefine types. For example using the Windows unit redefines TRect.

On a half-related note, I think FPC would strongly benefit from Python-like
"limited import" feature.
Quote from http://docs.python.org/tutorial/modules.html#more-on-modules :
"Note that in general the practice of importing * from a module or package
is frowned upon, since it often causes poorly readable code. "

> 2. You can create "circular" dependencies without noticing.
> 2.1 Circular dependencies make it hard to tell the order of
> initialization sections.
...
> 2.3 Circular dependencies make refactoring a lot harder.

I still believe that a simple warning from FPC would go a long way
to fixing this problem.

> 3. The uses section is split, reducing readability.

I personally find the opposite -- if properly maintained,
the separate "uses" lists are giving reader additional information
about unit dependencies and at the same time reduce the amount
of dependencies one must scan in order to understand only
the unit interface (i. e. to use, not develop, a unit).

--
Alexander S. Klenin

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Identifier not found, but code completion works....

Rich Saunders
On 2/19/11 10:27 AM, Alexander Klenin wrote:
> 3. The uses section is split, reducing readability.
> I personally find the opposite -- if properly maintained,
> the separate "uses" lists are giving reader additional information
> about unit dependencies and at the same time reduce the amount
> of dependencies one must scan in order to understand only
> the unit interface (i. e. to use, not develop, a unit)
I also find the opposite.

Using a unit in a uses clause defines the scope of the usage. I think
the overriding principle should be to limit the scope to only the code
that requires it. Using a unit in the implementation section adds
valuable info to the reader that the used unit is NOT needed to define
the current unit's interface.




--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Identifier not found, but code completion works....

Mattias Gaertner
On Sat, 19 Feb 2011 11:07:42 -0500
Rich Saunders <[hidden email]> wrote:

> On 2/19/11 10:27 AM, Alexander Klenin wrote:
> > 3. The uses section is split, reducing readability.
> > I personally find the opposite -- if properly maintained,
> > the separate "uses" lists are giving reader additional information
> > about unit dependencies and at the same time reduce the amount
> > of dependencies one must scan in order to understand only
> > the unit interface (i. e. to use, not develop, a unit)
> I also find the opposite.
>
> Using a unit in a uses clause defines the scope of the usage. I think
> the overriding principle should be to limit the scope to only the code
> that requires it. Using a unit in the implementation section adds
> valuable info to the reader that the used unit is NOT needed to define
> the current unit's interface.

Readability is mostly up to what you are used to. That's why I listed
it as advantage and disadvantage.
The implementation uses section does not make the code more readable
for everyone. IMHO comments are better suited for that.

It is not the first time that people added implementation uses sections
to the Lazarus code, creating circular dependencies, which lead
weeks/months later to strange errors. And since I'm often the one who
has to fix it I call the implementation uses sections "evil" and I hope
that people will use them only when needed and not only for
"readability".


Mattias

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Identifier not found, but code completion works....

Hans-Peter Diettrich
Mattias Gaertner schrieb:

> The implementation uses section does not make the code more readable
> for everyone.

It makes the *interface* section more readable.

> IMHO comments are better suited for that.

Did you ever see a uses clause, separated by comments into units
required by the interface and the implementation?

That would be useless because nobody can verify that distinction,
without actually moving the units into the implementation uses and
compile again.

DoDi


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Identifier not found, but code completion works....

Mattias Gaertner
On Sat, 19 Feb 2011 23:21:46 +0100
Hans-Peter Diettrich <[hidden email]> wrote:

> Mattias Gaertner schrieb:
>
> > The implementation uses section does not make the code more readable
> > for everyone.
>
> It makes the *interface* section more readable.

Not for everyone.
Some people read the uses sections only to find out what is needed to
compile the unit.

 
> > IMHO comments are better suited for that.
>
> Did you ever see a uses clause, separated by comments into units
> required by the interface and the implementation?

No.
Apparently those who care separate them and those who don't care, see no
reason to mention it.

 
> That would be useless because nobody can verify that distinction,
> without actually moving the units into the implementation uses and
> compile again.

What about class private members? You don't need them to understand the
interface, but you might need some extra units for them.

Apparently I'm too stupid to understand the gain of the
readability of uses section separation, but I know the trouble with
FPC.


Mattias

--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Identifier not found, but code completion works....

Graeme Geldenhuys
In reply to this post by Bo Berglund
Op 2011-02-19 16:11, Bo Berglund het geskryf:
>
> Is this bad practice with FPC/Lazarus?

I don't think so. At least in my FPC-base programs I have always
preferred putting things first in the implementation uses clause before
the interface uses clause. As the old design statement goes.... On make
things public when really needed.

Contrary to Mattias statement - this reduces circular unit references in
my case/applications. I could never understand how Mattias thinks otherwise.


Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Identifier not found, but code completion works....

Graeme Geldenhuys
In reply to this post by Mattias Gaertner
Op 2011-02-19 17:03, Mattias Gaertner het geskryf:
> 3. The uses section is split, reducing readability.

I've never found that an issue, or ever heard any programmer complain
about that - so it's probably your own preference. After all, the whole
unit is split in two section. ;-)


> disadvantages, so I recommend to avoid the implementation uses section
> whenever possible.

This makes no sense - yet again. I have only ever seen this statement
being used in the Lazarus IDE project - nowhere else. In my experience
(just like in Delphi) it reduces circular unit dependencies if you use
the implementation section as much as possible, before the interface
uses section.


Regards,
  - Graeme -

--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/


--
_______________________________________________
Lazarus mailing list
[hidden email]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
123