Recent

Author Topic: Hint message "Local variable xx does not seem to be initialized" problem  (Read 14870 times)

PascalDragon

  • Hero Member
  • *****
  • Posts: 4887
  • Compiler Developer
Re: Hint message "Local variable xx does not seem to be initialized" problem
« Reply #45 on: November 03, 2022, 07:24:11 am »
So what is best way to to this?

Just continue to build within Lazarus and simply learn what the messages mean and whether you can safely ignore or disable them.

Code: Pascal  [Select][+][-]
  1.   a: TStringArray =();
  2.   b : string ='';
  3.  

But I thought that was supposed to be implicit for managed types, or is there a mode dependency there?

Yes, it's implicit and the reason why I personally am opposed to this hint cause unlike for the Result variable it definitely makes no difference.

But I thought that was supposed to be implicit for managed types, or is there a mode dependency there?
It depends on two things:
- heap or stack, heap is clean, stack is not (with the default MM)

Implicit initializaton depends on neither of these and happens always.

MarkMLl

  • Hero Member
  • *****
  • Posts: 5866
Re: Hint message "Local variable xx does not seem to be initialized" problem
« Reply #46 on: December 01, 2022, 09:43:58 pm »
Apropos increasing the size of a dynamic array:

Not a power of two but the golden ratio is way more efficient. ~1.618

Why? Not arguing, interested...

...and as a secondary question, is there a standard class that implements an extensible buffer with "append to end" and "remove from start" support?

MarkMLl
« Last Edit: December 01, 2022, 09:51:56 pm by MarkMLl »
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

MarkMLl

  • Hero Member
  • *****
  • Posts: 5866
Re: Hint message "Local variable xx does not seem to be initialized" problem
« Reply #47 on: December 25, 2022, 10:54:32 pm »
...and as a secondary question, is there a standard class that implements an extensible buffer with "append to end" and "remove from start" support?

Well, trusting Thaddy's judgement, that was a fun little exercise.

Some of the issues- not all of which I've yet addressed- are that it's desirable to have a "how many bytes can I add?" property, which is dependent on the maximum permitted size which is (original_size * (golden_ratio ^ n)) hence susceptible to rounding errors.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018