[fpc-devel] Fix CamelCase in unit and method names

R0b0t1 r030t1 at gmail.com
Thu Mar 22 16:12:36 CET 2018


On Thu, Mar 22, 2018 at 6:42 AM, Michael Van Canneyt
<michael at freepascal.org> wrote:
>
>
> On Thu, 22 Mar 2018, Ondrej Pokorny wrote:
>
>> Hello,
>>
>> will a patch be applied that fixes CamelCase in unit and method names and
>> other identifiers?
>>
>> Example:
>>
>> dateutils -> DateUtils
>> sysutils -> SysUtils
>> typinfo -> TypInfo
>> contnrs -> Contnrs
>> strutils -> StrUtils
>> EnterCriticalsection -> EnterCriticalSection
>> DoneCriticalsection -> DoneCriticalSection
>> LeaveCriticalsection -> LeaveCriticalSection
>> TryEnterCriticalsection -> TryEnterCriticalSection
>> (Funnily enough InitCriticalSection is correct.)
>>
>> TPoint.x -> TPoint.X
>> TPoint.y -> TPoint.Y
>>
>> (For unit names: of course only the unit definition name will be changed,
>> not the file name).
>
>
> At first sight I don't see any disadvantages from this, so yes, I would
> apply such a patch.
>
> Code completion will benefit from it, I suppose.
>

I asked about this a while ago; please apply the patches if any are made.


On Thu, Mar 22, 2018 at 7:44 AM, Tomas Hajny <XHajT03 at hajny.biz> wrote:
> On Thu, March 22, 2018 12:42, Michael Van Canneyt wrote:
>> On Thu, 22 Mar 2018, Ondrej Pokorny wrote:
>
>
> Hi,
>
>>> will a patch be applied that fixes CamelCase in unit and method names
>>> and other identifiers?
>>>
>>> Example:
>>>
>>> dateutils -> DateUtils
>>> sysutils -> SysUtils
>>> typinfo -> TypInfo
>>> contnrs -> Contnrs
>>> strutils -> StrUtils
>  .
>  .
>>> (For unit names: of course only the unit definition name will be
>>> changed, not the file name).
>>
>> At first sight I don't see any disadvantages from this, so yes, I would
>> apply such a patch.
>
> IMHO preferably not the unit names (as in 'unit XxX') - with case
> sensitive file names on Unix, this change might increase time for
> searching the respective file (somewhat). Obviously, all further
> references of the unit (as in 'SysUtils.Execute') should be fine.
>

I don't understand how it would increase the search time. I believe
what happens is all names are converted to lowercase for the search,
as in the strings taken from the user or their files and the names
taken from the disk are both converted to lower case before
comparisons are made.

This is why some of the unit names are entirely lower case - they were
at some point stored internally as entirely lower case, and no one
fixed them (because you have to do it each time you interact with
certain IDE GUIs). There may have been some versions of Lazarus that
would not allow you to save mixed case file names, or at least made it
very hard to do so.

I suspect some of the mixed case file names that are not capitalized
properly are due to the lack of case sensitivity and code completion.
I found some Microsoft projects which misspelled something the same
way in each of 4-5 places, probably because the name was typed once
and then never fully typed again.


Following from the above, very interesting patches would be ones that
do not automatically lower case file names in Lazarus.

Cheers,
     R0b0t1



More information about the fpc-devel mailing list