[Lazarus] FPReport file names
Michael Van Canneyt
michael at freepascal.org
Wed Sep 13 12:10:03 CEST 2017
On Wed, 13 Sep 2017, Mattias Gaertner wrote:
> On Wed, 13 Sep 2017 11:28:55 +0200 (CEST)
> Michael Van Canneyt <michael at freepascal.org> wrote:
>
>> [...]
>>>> The benefit of writing fpreport.exporthtml versus fpreportexporthtml is zero.
>>>
>>> It's a little bit better than zero. For example shorter uses clause.
>>
>> Without using a switch to set namespaces ? Please Explain ?
>
> Namespaces without the switch are pretty useless. I thought you were
> talking about namespaces as in Delphi. Sorry for the misunderstanding.
They are one and the same.
>> [...]
>>> Did you add "uses utils"?
>>
>> Yes, obviously. Here is the test program:
>
> I see now that your point was the order of namespaces. Which is an
> issue with unit paths as well. But with namespaces you can always pass
> the whole unit name, while with unit paths you cannot. So I'm not sure
> why the order is an argument against namespaces.
Because, as I demonstrated, the order issue forces you to disambiguate the unit names anyway.
Writing "uses utils;" is ambiguous if you are using 2 namespaces which both
have a "utils" unit, and you use both of them somewhere in your project.
We are agreed on that, I hope.
So, to avoid this, you must write "uses web.utils" and "uses os.utils"
(using my example).
So, if you write a class library (using a namespace) with many units,
you don't know in what environment it will be used, and what namespaces
the end user will use on the command line (or maybe none).
So, you must make sure all your code is unambiguous, i.e. write
"namespace.unitname" everywhere.
The same is true for the end-user. (see my demonstration program).
So if you must disambiguate anyway (i.e. write web.utils).
the whole point of using a namespace ("shorter names") becomes moot.
I am not trying to dissuade anyone from using namespaces.
I am trying to debunk a myth, namely that it will avoid unit name clashes.
It does not, and in certain circumstances (using /NS switch) makes the
problem only worse.
The end point - what got all this started - is that whether you use
fpreportutils.pp
or
fpreport.utils.pp
is a matter of personal preference only.
Using the latter does not avoid the possibility of name clashes.
Michael.
More information about the Lazarus
mailing list