Recent

Author Topic: Issue of lots of unused variables in Forms type declaration  (Read 2307 times)

vfclists

  • Hero Member
  • *****
  • Posts: 1013
    • HowTos Considered Harmful?
Issue of lots of unused variables in Forms type declaration
« on: September 17, 2014, 11:31:19 am »

Whenever controls are added to a form, variables are created for them, although they may never be used.

Labels are a good example of this.

What is the general approach for dealing with this issue, besides eliminating unused variables from the source?

What are the unwanted side effects of removing them.

What effects does that normally have on the .lfm files etc?
Lazarus 3.0/FPC 3.2.2

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11457
  • FPC developer.
Re: Issue of lots of unused variables in Forms type declaration
« Reply #1 on: September 17, 2014, 11:44:40 am »
This is normal. Don't edit, it will break.

The LFM declares nothing on pascal level, that's what those fields are. Those fields _are_ the control instance, not an additional variable.

vfclists

  • Hero Member
  • *****
  • Posts: 1013
    • HowTos Considered Harmful?
Re: Issue of lots of unused variables in Forms type declaration
« Reply #2 on: September 18, 2014, 12:18:51 am »
This is normal. Don't edit, it will break.

The LFM declares nothing on pascal level, that's what those fields are. Those fields _are_ the control instance, not an additional variable.

If you don't ever expect to use the variable referring to a control, or its subcomponents anywhere in the code, isn't it safe to delete it?

Does the form streaming/loading system need the variables to be there even if they are never used?
Lazarus 3.0/FPC 3.2.2

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Issue of lots of unused variables in Forms type declaration
« Reply #3 on: September 18, 2014, 12:28:43 am »
This is normal. Don't edit, it will break.

The LFM declares nothing on pascal level, that's what those fields are. Those fields _are_ the control instance, not an additional variable.

If you don't ever expect to use the variable referring to a control, or its subcomponents anywhere in the code, isn't it safe to delete it?

  no if you want to make it safe to delete convert to dynamically created one.

Does the form streaming/loading system need the variables to be there even if they are never used?

Those variables are in the published section of the form for a reason, it is the only access point for the streaming mechanism if you move the definitions to a protected section then you will get exceptions.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018