Recent

Author Topic: default integer type for codetools  (Read 242 times)

BeniBela

  • Hero Member
  • *****
  • Posts: 763
    • homepage
default integer type for codetools
« on: November 19, 2020, 02:28:08 pm »
When you write something like
Code: Pascal  [Select][+][-]
  1. i := 0
or
Code: Pascal  [Select][+][-]
  1. for i := 1 to length(something) do  
and press ctrl+shift+C, Lazarus adds
Code: Pascal  [Select][+][-]
  1. var  i: Integer;
which is often wrong on 64-bit system.

How do you set it to always complete it to:

Code: Pascal  [Select][+][-]
  1. var  i: SizeInt;


lucamar

  • Hero Member
  • *****
  • Posts: 3188
Re: default integer type for codetools
« Reply #1 on: November 19, 2020, 02:43:56 pm »
I don't think you can. After analizing the line Lazarus always "completes" to the closest, more generic type it can find which in this case is Integer, just as with strings it always completes to generic String rather that using Short- or AnsiString.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.10/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

BeniBela

  • Hero Member
  • *****
  • Posts: 763
    • homepage
Re: default integer type for codetools
« Reply #2 on: November 22, 2020, 12:03:13 pm »
But integer is  neither the closest (that would be byte or shortint) nor the most generic (which would be sizeint)

Even if there is no config option, there should be at least a line in the code where it can be patched

lucamar

  • Hero Member
  • *****
  • Posts: 3188
Re: default integer type for codetools
« Reply #3 on: November 22, 2020, 01:40:33 pm »
But integer is  neither the closest (that would be byte or shortint) nor the most generic (which would be sizeint)

Even if there is no config option, there should be at least a line in the code where it can be patched

Maybe "closest" was not the right term; I meant "basest", as in "the more general type". For reals, for example, it completes "i := 0.8" by adding "i: Extended".

But I might be completely wrong. If you want to know exactly what it's doing your best bet is to dive into the sources and, maybe, build a patch to allow it to be configurable.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.10/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

 

TinyPortal © 2005-2018