Recent

Author Topic: Lazarus is saving Units in lowercase (unit name)  (Read 6450 times)

Gald

  • Jr. Member
  • **
  • Posts: 85
Lazarus is saving Units in lowercase (unit name)
« on: December 14, 2021, 05:03:09 am »
Lazarus is saving Units in lowercase.

The Application Project (.lrp) is showing the unit name correctly, but not in Project Inspector and in the saved files on the system.
Is this fixed on the RC version?

Lazarus 2.0.12 r64642 FPC 3.2.0 x86_64-win64-win32/win64
Lazarus 2.0.12 r64642 FPC 3.2.0 x86_64-win64-win32/win64/Manjaro KDE 21
AMD Ryzen 3 1300X Quad-Core Processor 3.50 GHz / 8,00 GB RAM / GTX 1500 TI / 2TB M.2 NVMe

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 853
  • Professional amateur ;-P
Re: Lazarus is saving Units in lowercase (unit name)
« Reply #1 on: December 14, 2021, 05:50:24 am »
Hey Gald,

I'm not completely sure what you're talking about, but the default of suggesting filenames in lowercase can be adjusted under:
Tools->Options->Environment->Naming

By default it's in lower case due to the case sensitivity of some OSs, mainly Linux and macOS.

But on that sections of the settings you can change all that at your heart's contempt :)

Cheers,
Gus
Lazarus 2.3.0(trunk) FPC 3.3.1(trunk) Ubuntu 21.10 64b Dark Theme
Lazarus 2.0.12(stable) FPC 3.2.2(stable) Ubuntu 21.10 64b Dark Theme
http://github.com/gcarreno

PascalDragon

  • Hero Member
  • *****
  • Posts: 4005
  • Compiler Developer
Re: Lazarus is saving Units in lowercase (unit name)
« Reply #2 on: December 14, 2021, 09:09:21 am »
Lazarus is saving Units in lowercase.

The Application Project (.lrp) is showing the unit name correctly, but not in Project Inspector and in the saved files on the system.
Is this fixed on the RC version?

This is the default (and as Gus wrote it can be changed), but you shouldn't change this. Especially on systems with case sensitive file systems this could lead to problems. For example: your unit is called MyFancyUnit.pp. Now inside your program the uses-clause contains MyFancyunit (note the lower case 'u'). The compiler will now search for the unit as-is, in all lower case and in all upper case. On a non-case sensitive file system (e.g. FAT or NTFS with a directory that isn't case sensitive) the first one will already be sufficient to find the file. However on a case sensitive file system (e.g. EXT or NTFS with a directory that is case sensitive) the file will never be found.

Thus if there isn't a very good reason to change this (and I don't know any) then don't change it.

Bart

  • Hero Member
  • *****
  • Posts: 4689
    • Bart en Mariska's Webstek
Re: Lazarus is saving Units in lowercase (unit name)
« Reply #3 on: December 14, 2021, 02:52:02 pm »
An (minor) annoying side effect is thatit also changes the casing of the phrase "unit myfancyunit;" in the source to lowercase.
As a result, in the source editor of Lazarus, it will show "myfancyunit" also as caption in the Tab of the editor.

The remedy is simple: just change "unit myfancyunit;" (in the sourcecode) back into "unit MyFancyUnit;".
Upon reload, the IDE will show the camelcase caption in the Tab of the source editor.


That being said: unless none of what you write will ever be used (by you, or by any other) on another filesystem than NTFS (case-insensitive) or FAT: use lowercase filenames.

Bart

MarkMLl

  • Hero Member
  • *****
  • Posts: 4162
Re: Lazarus is saving Units in lowercase (unit name)
« Reply #4 on: December 14, 2021, 03:05:15 pm »
On Linux, there might be minor variations in behaviour depending on whether a mixed-case name is specified when a unit is first created or using "Save As". Also a mixed-case unit name might not be displayed as such in the tab until a project is reloaded.

I'm definitely not complaining, just warning that there /might/ be conditions under which an inexperienced user might get confused.

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

howardpc

  • Hero Member
  • *****
  • Posts: 3972
Re: Lazarus is saving Units in lowercase (unit name)
« Reply #5 on: December 14, 2021, 04:54:40 pm »
One source of confusion is the way Lazarus maintains two distinct names for each unit:
1. the unit name, specified by you in the source of the unit as
Code: Pascal  [Select][+][-]
  1. unit MyFancyUnit;

2 the unit's filename, which is used for disk access, and which Lazarus does its best to keep all lowercase, though it does not enforce this ../myfancyunit.pas or ../myfancyunit.pp or whatever.

Lazarus does a remarkably good job of keeping these two names distinct but associated, and only in the case Bart cites above does the filename intrude and overwrite the unit name. A simple manual correction, as he writes, is sufficient to restore the casing you prefer to the unit name, and this does not affect the unit's filename.

MarkMLl

  • Hero Member
  • *****
  • Posts: 4162
Re: Lazarus is saving Units in lowercase (unit name)
« Reply #6 on: December 14, 2021, 05:35:56 pm »
The compiler authors and maintainers have done a solid job, and I'd be the last person to criticise their choices in this area because of the cross-platform nature of the project.

If anybody feels like arguing, I suggest first running a full build of the compiler and libraries with the -vt option to show all candidate filenames.

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

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 853
  • Professional amateur ;-P
Re: Lazarus is saving Units in lowercase (unit name)
« Reply #7 on: December 14, 2021, 08:06:04 pm »
Hey Bart,

An (minor) annoying side effect is that it also changes the casing of the phrase "unit myfancyunit;" in the source to lowercase.

This is very far from my experience, to the point that I could dare a: It's not true.

I like my PascalCase unit names and when I type the name on the Save Dialog I use PascalCase, well, more of Pascal.Case since I also like my namespaces, and the saved file is always in lowercase but the unit name on the source keeps the Pascal.Case.

Could you share the Tools->Options->Environment->Naming screenshot with your settings so we can compare and find out how you get lowercase unit names in the source?

Many thanks!!

Cheers,
Gus
Lazarus 2.3.0(trunk) FPC 3.3.1(trunk) Ubuntu 21.10 64b Dark Theme
Lazarus 2.0.12(stable) FPC 3.2.2(stable) Ubuntu 21.10 64b Dark Theme
http://github.com/gcarreno

JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4096
  • I like bugs.
Re: Lazarus is saving Units in lowercase (unit name)
« Reply #8 on: December 14, 2021, 09:18:56 pm »
I like my PascalCase unit names and when I type the name on the Save Dialog I use PascalCase, well, more of Pascal.Case since I also like my namespaces, and the saved file is always in lowercase but the unit name on the source keeps the Pascal.Case.
Yes, that is my experience as well.
Only if you type a new filename in the dialog in all lowercase, then also the unit name becomes lowercase.
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

PascalDragon

  • Hero Member
  • *****
  • Posts: 4005
  • Compiler Developer
Re: Lazarus is saving Units in lowercase (unit name)
« Reply #9 on: December 15, 2021, 09:12:38 am »
An (minor) annoying side effect is thatit also changes the casing of the phrase "unit myfancyunit;" in the source to lowercase.
As a result, in the source editor of Lazarus, it will show "myfancyunit" also as caption in the Tab of the editor.

When I save a unit the first time I use PascalCase and Lazarus will then use that name for the unit-heading and the lowercase one for the filename. :)

 

TinyPortal © 2005-2018