5
votes

I've got two bpl packages: Core and Business, used by one application. Core.bpl contains unit User.pas with TUser class in it. TUser in Core.bpl has only two base fields: Login and Password. I want to expand TUser class in Business package with new field: UserName. And I want to name business unit as the base unit: User.pas.

So, I create a new unit User.pas in Business.bpl and place there TUser class that extends TUser from Core.bpl. Now I need to divide TUser from Core.bpl and TUser from Business.bpl. And I need to use "power of namespaces" here :)

I've read Embarcadero doc page. They say that one can set the default namespace for package with naming it, e.g. Base.Core. I named my packages as Base.Core.bpl and Extra.Business.bpl. And compiled files are named so. But all units in them are still named as they were before: User.pas -> User.dcu.

Now I've got two classes TUser in modules User.pas: one in package Base.Core.bpl, other in package Extra.Business.bpl. User.pas in Extra looks like

unit User;
interface
uses
  Base.User;
type
  TUser = class(Base.User.TUser)
  end;

But when I want to compile it, I've got a window: "Remove User. Unit(s) User were found in required package Base."

What have I do to inherit new TUser from Base.User.TUser like it can be in Java, for example?

P.S. Just in case, I use Delphi XE2 IDE.

1
Shouldn't you name them as 'Unit Base.User' and 'Unit Business.User', if you want to use such notation?Nickolay Olshevsky
There are many units in Core and in Business... And all of them are in SVN :( Renaming all of them is the last way... May be, one can do it easier?Mikhail Kopylov
I'm with you. The documentation says one thing. But the program behaves completely differently.David Heffernan
If it's feasable set the "default namespace". It was in "directories/conditionals" in project options in earlier versions. Somehow I can't find it now, but it's possible to add it as an additional option in "other options" in "compiling".Sertac Akyuz
What should I pass to option "other options" in "compiling"?Mikhail Kopylov

1 Answers

6
votes

The default namespace appears to be Portal cake–it's a lie. The documentation you link to does not match the program.

I made this program:

MyCompany.Programs.MyProgram.dpr

program MyCompany.Programs.MyProgram;

uses
  MyUnit in 'MyUnit.pas';

begin
end.

MyUnit.pas

unit MyUnit;

interface

implementation

end.

And the resulting .dcu file is named MyUnit.dcu. According to the documentation that you linked to it should be named MyCompany.Programs.MyUnit.dcu.

I believe that you will have to specify the namespace explicitly in the unit name.