Re: I really hate .NET especially inside Delphi



Tim Jarvis [Borland/DTG] wrote:

Ok, to create an assembly that looks and feels like a C# assembly, in
Delphi.NET terms this is a package (yeah, yeah, I don't know why
either, but it is what it is) a Delphi.NET package does not compile to
a BPL it will compile to a dll, in otherwords an assembly.


Hi Tim, actually I think I know what I talk about.
No offense taken and not meant to be offensive, btw. ;-)
I used D8 for some time until I simply had to give it up. Mainly because I couldn't get the output as I wanted it to be and I simply got used to the ease of namespaces and multi pass compiling in the time before Delphi learned .Net.
D8 didn't give *me* any advantage over C# (later Chrome), only disadvantages. So why use it? ;-)
However, I checked every new release of the D.Net compiler either using BDS205 personal or Turbo, just to see if things changed and what was changed.
But judging from threads in b.p.d.l.d.dotnet that camtasia isn't a bad idea, anyway. :-)

Now say we creat a class in there lets call it TTestClass in the
namesapce TimsTest i.e Unit TimsTest.TTestClass, if you compile this
"package" and have a look at the created assembly with reflector you
will see a namespace called TimsTest with TTestClass in it, if you
reference this assembly in a C# project you simply would reference this
class via TimsTest.TTestClass or put a using clause in i.e. Using
TimsTest, in a Delphi app in the Uses class you would put
TimsTest.TestClass...this is some additional scoping, this is
deliberate, but not an artifact of the assembly, but Delphi, it
actually determines the unit name by reflection...if you look closely
at the assembly you will see a class attribute called TUnitName with
the scoped name passed as a parameter.


Actually, your sample is too oversimplified to show what I meant with unit <> namespace when consuming D.Net classes from D.Net or from another .Net language.
Simply change your class "TestClass" to be placed in a unit called "RobertsTest.Unit1".

Now I could use it like this in C#:

using RobertsTest;
....
class Blabla : TestClass
{...}

or simply this way:

class Blabla : RobertsTest.TestClass
{...}

A D.Net assembly that consumes the sample assembly with our TestClass had to look like this

uses
RobertsTest.*Unit1*;

type
Blabla = class(TestClass)
end;

You cannot use the namespace inside a D.Net assembly:

uses
RobertsTest;

type
Blabla = class(TestClass)
end;

Using the full path instead of putting the namespace/unit name into the uses clause does not work in D.Net, too. ;-)


So yes, its different from C#, but the assembly is perfectly valid, and
works just the same as a C# assembly...just has some additional Delphi
unit naming attributes that the Delphi IDE uses is all.

Also, don't confuse C# and VB.NET with the "usual way .NET languages
implement things" sure these are by far the most common .NET languages,
but there are some really obscure things out there that do stuff waaay
differently, have a look at some of these interesting
beasts....http://www.dotnetpowered.com/languages.aspx


Well, C#, Chrome, VB (*cough*), Nemerle, Boo, [most likely a long list of others] do behave that way when it comes to namespaces and how you use them.
They also won't force you to provide a dcpil besides your assembly.
.



Relevant Pages

  • Re: F1026 blinker error
    ... and a main exe file. ... Last weekend I encountered a strange error with Delphi ... every second time I hit the compile button in the IDE, ... The file is in a package. ...
    (alt.comp.lang.borland-delphi)
  • Re: I really hate .NET especially inside Delphi
    ... in Delphi.NET terms this is a package (yeah, yeah, I don't know why ... to a BPL it will compile to a dll, ... will see a namespace called TimsTest with TTestClass in it, ... in a Delphi app in the Uses class you would put ...
    (borland.public.delphi.non-technical)
  • Re: Abbrevia for Delphi2007 - zipping/unzipping Winzip files
    ... When I had produced one for the VD file - the designtime package, ... Ok for a Tzip component in Delphi proper!! ... There are "RUNTIME" packages (which you compile first). ... Then ther are "DESIGN" packeages (which you compile and install) (some ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: Can Install PngComponents under BDS 2006.
    ... Now you are trying to recompile one of those packages in Delphi 2006 without changing the names. ... This would be okay, except the package requries another package that was build in D9. ... Compile and install. ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: automatic namespace importing
    ... It parses the ASPX page and creates a class. ... and those are the assemblies your page is linked against. ... used to compile the class. ... Namespaces do not map to assemblies directly. ...
    (microsoft.public.dotnet.framework.aspnet)