www.digitalmars.com         C & C++   DMDScript  

D - Re: Import or Not


I don't think that's quite what I'm looking for. Let me show you a very
simple example that illustrates my question exactly.

The following is a sample library. It's compiled using "DMD -c x.d".

class a
  int b;
  this(int z){b = z;}
  void set(int z){b = z;}
  int get(){return b;}

An OBJ file is created. The following program is created by a user. It uses
the above library. It's compiled using "DMD y.d x.obj".

import x;            // It works with this here

int main(char[][] args)
  a a1 = new a(25);
  return 0;

It works fine because It has "import x;" at line 1, but if I remove the
"import" statement, it fails because it can't see "class a". But I don't
want the user to see the code in the library so I'm not going to give them
access to it.

Here's my question: What should the "import" file look like so the user
program can use "class a" without having all the library code? Is there some
way to prototype the class without divulging all the internal code? If so,
what does it look like... exactly?

Thanks... Gary.

"Walter" <walter digitalmars.com> wrote in message
news:b4e5n2$vcr$1 digitaldaemon.com...
 "Gary" <gedumer bcpl.net> wrote in message
 news:b4ctkg$c5v$1 digitaldaemon.com...
 I'm creating a library that I want to compile separately and make into a
 .lib file. I want to use that library in other programs obviously. How

 the programs using the .lib "see" the class definitions in the library?

 have to provide some sort of symbol file containing the definitions

 the "import" statement?  If so, how do I show the definitions without
 divulging all the code? What would such a definition file look like? How
 does the Phobos library work in that regard? We don't have to import any
 definitions from Phobos. Why?

Take a look at phobos/gc.d and phobos/gc2/gd.d. That's an example of what you're trying to accomplish.

Mar 10 2003