[fpc-devel] Generics.Collections as package for Lazarus or package for FPC RTL

silvioprog silvioprog at gmail.com
Wed Jan 27 14:28:27 CET 2016


On Wed, Jan 27, 2016 at 6:22 AM, Michael Van Canneyt <michael at freepascal.org
> wrote:
[...]

> Assume we introduce namespaces, do things 'Properly' and introduce
> Core.FileUtils
> Core.StringUtils
> (the names are just examples, to make a point)
>
> Now let's take example existing routines such as
> ExtractFilePath
> ExtractFileName
> Where do we put them ?
>
> Both units are a candidate. The former because it is about filenames.
> The latter because they are purely string operations.
> Your namespace doesn't solve this problem.
>

ExtractFilePath/ExtractFileName sounds more related to file operations, so:

Core.File:
...
  TFile = class sealed(TObject)
  public
    class function ExtractPath ... ; static;
    class function ExtractName ... ; static;
...

writeln(TFile.ExtractPath(...));
writeln(TFile.ExtractName(...));

or:

Core.File:
...
function ExtractPath ...;
function ExtractName ...;

writeln(File.ExtractPath(...));
writeln(File.ExtractName(...));

(btw the example above needs the -NS feature)

IMHO, if the <context> already is called "file", you don't need to add the
context name again in the function name, so instead of:

writeln(Extract<File>Path(...));
writeln(Extract<File>Path(...));

just use:

writeln(<File>.ExtractPath(...));
writeln(<File>.ExtractName(...));

So, you can do <context>.code-completation to get all the features to this
context.

Once more, the above is purely theoretical discussion; I am not opposing
> anything, just pointing out that the use of namespaces is
> and remains a matter of preference (or even fashion/hype).


Both approaches compiles, but I agree the it is a preferencial thing.

-- 
Silvio Cl├ęcio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20160127/ee6bf1bc/attachment.html>


More information about the fpc-devel mailing list