No header files?
Yigal Chripun
yigal100 at gmail.com
Wed Oct 21 16:22:02 PDT 2009
On 22/10/2009 00:57, BCS wrote:
> Hello Yigal,
>
>> On 22/10/2009 00:14, BCS wrote:
>>
>>> Hello Yigal,
>>>
>>>> On 21/10/2009 23:59, AJ wrote:
>>>>
>>>>> Since D has no header files, how does one create "a library" that
>>>>> another developer can use without exposing the implementation?
>>>>>
>>>> D does have header files with the extension .di which can be either
>>>> auto generated and/or manually edited. IMO this is a design mistake
>>>> carried over from c/c++.
>>>>
>>> What would you prefer?
>>>
>>> Aside from a better library format you need something to give DMD the
>>> information. Switching to a better library format has several issues
>>> including requiring more tools to make them and view them as well as
>>> it doesn't solve the problem of linking with C libs that don't and
>>> never will use this new format. Not fatal issues I'll grant, but what
>>> we have works NOW.
>>>
>> As you said, what is needed is a better lib format. we already have
>> DDL NOW which already has most of what you described above. D can also
>> take advantage of the LLVM framework.
>
> Does DDL or LLVM work to generate monolithic executable that use all of
> D's features and do so for both Win32 and *nux?
>
> Also, can I use notepad to view either of those file types?
>
>>
>> why do you need to choose between the two options anyway? dmd can
>> support c header files combined with c libs and use a better D lib
>> format for D code. Another option would be to have a simple tool to
>> convert a bunch of c header files and a C lib to a D lib.
>
> Option 1 is a no starter (Walter has said NO the that exact option based
> on it needing in effect a full C frontend to work) Option 2 in
> interesting but, it runs flat into to "needs more tools" issue.
>
>> The C/C++ way of headers + lib has problems which D inherited as part
>> of the same (broken) design.
>
>
from http://llvm.org/docs/LangRef.html
<quote>
The LLVM code representation is designed to be used in three different
forms: as an in-memory compiler IR, as an on-disk bitcode representation
(suitable for fast loading by a Just-In-Time compiler), and as a human
readable assembly language representation. This allows LLVM to provide a
powerful intermediate representation for efficient compiler
transformations and analysis, while providing a natural means to debug
and visualize the transformations. The three different forms of LLVM are
all equivalent.
</quote>
IIRC DDL wraps objects/libs with meta-data.
while it will be easy to get a text representation with llvm (the
equivalence that is mentioned above) why would you want to do it anyway?
Automatically extracted documentation to a human format (ddoc, javadoc,
etc) is much more useful and more flexible - you can get a printed
manual or an interactive and easy to navigate html, you can also get all
sorts of graphs and diagrams that would ease understanding of the
structure of code.
the only valid IMO use case for header files is for linking libs - the
compiler can handle just find binary formats for that.
More information about the Digitalmars-d
mailing list