[fpc-pascal] Strings - suggestions

Marco van de Voort marcov at stack.nl
Sat Dec 22 18:16:04 CET 2012


In our previous episode, Michael Van Canneyt said:
> >
> > Rule of thumb: anything global must be passed on the cmdline everytime, and
> > directives are only for unit level. (a few special ones for library units
> > like $libsuffix excluded)
> 
> While this is correct, I think it is possible to construct a (new) directive that 
> can be inserted in a program/library file only, and which will have the same 
> effect as the command-line argument: for all units that will be compiled as 
> part of the normal run, the string type is set.
 
> Whether or not this is desirable, is another matter.

Exactly. In theory you can lift a directive to global state for that
compiler invocation (as done with linker related switches atm)

But it can cause so much confusion (e..g other project that uses partially
the same units) that it causes more problems than it solves.

During the unicode discussions I thought about this, and even thought of a
mitigation (though not complete solution) of that problem:

1. if such directive is in a normal unit, mark the PPU as such.
2. if such a PPU is loaded, make it global.
3. if that causes a conflict (multiple such units with different 
  directives), abort.	

This way putting some directive in an unit that is at the top of the
dependency graph will cause it to quickly pull it in on independent
compiles.

It mainly fixes the case where one users generally uses only one style. It
does require some restraint though, which I think the solution is only
theoretical.

So either go to a mandatory project system (but not even Delphi does that),
or not. This will also allow to throw errors when using an unit not compiled
with the same project file etc.

Delphi seems to go in that direction though, I found it is hard to quickly
compile FPC programs on the cmdline with XE3, since then it misses the namespace
prefixes and complains it can't find "sysutils" because it wants
system.sysutils.

There are backwards compat aliases (actualy, already since D7, and the
winprocs,wintypes unit aliases are even older), but with XE3 they are less

> (personally, I think we have enough with the command-line version)

Yes. And even if not, I would go for a mandatory project file, not in
source.



More information about the fpc-pascal mailing list