comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Ada  "library only" compiler ?
Date: Sat, 21 Jul 2012 16:31:17 +0300
Date: 2012-07-21T16:31:17+03:00	[thread overview]
Message-ID: <a6vp98FrcfU1@mid.individual.net> (raw)
In-Reply-To: <juct1g$eho$1@munin.nbi.dk>

On 12-07-21 03:27 , Randy Brukardt wrote:
> "Niklas Holsti" <niklas.holsti@tidorum.invalid> wrote in message
> news:a6tvrmFdinU1@mid.individual.net...
> ...
>>> So again, I don't mean to be harsh but if we are always building on C
>>> through the GNAT compilation progress would it be logical to decouple
>>> the two to create a simple Ada "as library" compiler? It seems that
>>> we can't open a file or get a command line argument without C
>>> anyways.
>>
>> GNAT runs on operating systems (Windows, Linux, etc.) in which the
>> Application Programming Interface is defined in C. In order to open a file
>> under Linux, the application (here GNAT) *must* use the open() or fopen()
>> functions, which are defined in the API as C functions. Trying to open a
>> file using "low-level Ada" would be breaking the OS interface which is
>> obviously a bad idea (and probably impossible because an application does
>> not have the necessary low-level access rights for that).
>>
>> Likewise, when a GNAT-compiled Ada program runs on Windows or Linux and
>> accesses files, the GNAT-provided libraries (Ada.Text_IO etc.) must use
>> the Windows/Linux C-style I/O libraries, for the same reasons.
>
> This isn't quite right. Janus/Ada contains 0% C code (there is not a single
> line of C in Janus/Ada, the only exception being the never released Sun OS
> compiler and some parts that Unisys built for their hardware). That's true
> even on Windows. The Windows Win32 API does not require using any C code; it
> can be accessed directly. (Even the calling convention is not "C", it's
> "StdCall" which originally was "Pascal" until Microsoft got rid of their
> Pascal compiler.)
>
> It's true that the Win32 API is defined in C, but an Ada system can
> interface directly to it without using any intermediate C code.

Sure. I didn't say that the compiler or other Ada program must contain 
some C source; I said that it must use the OS API, which is almost 
always defined in C (unless it chooses to use the low-level, 
machine-specific OS-invocation mechanisms, as Peter Chapin pointed out).

Still, I have sometimes found it easier to write a thin interface layer 
in C, as I also said, just to have a simpler Ada/C interface.

> Janus/Ada is written solely in Ada; the Janus/Ada runtime is about 95% in
> Ada and 5% in assembler.

But you still use the Win32 C API and its services, translated into Ada 
form. Which is nice, if you can afford the effort (including the 
maintenance effort).

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .





  parent reply	other threads:[~2012-07-26 15:03 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-20 20:05 Ada "library only" compiler ? Patrick
2012-07-20 21:11 ` Niklas Holsti
2012-07-20 21:47   ` Ludovic Brenta
2012-07-20 22:25   ` Peter C. Chapin
2012-07-20 22:51     ` Ludovic Brenta
2012-07-21  0:32       ` Randy Brukardt
2012-07-21 12:39         ` Pascal Obry
2012-07-22  4:59           ` Shark8
2012-07-22  7:04             ` Pascal Obry
2012-07-22 10:17           ` Florian Weimer
2012-07-24  1:54           ` Randy Brukardt
2012-07-24 16:50             ` Pascal Obry
2012-07-24 18:01               ` Vasiliy Molostov
2012-07-24 21:30                 ` Pascal Obry
2012-07-25  6:33                   ` Vasiliy Molostov
2012-07-25 23:44                   ` sbelmont700
2012-07-25 23:34               ` Randy Brukardt
2012-07-21 11:05     ` Niklas Holsti
2012-07-20 23:30   ` Patrick
2012-07-21 16:47     ` Niklas Holsti
2012-07-21 17:47       ` Patrick
2012-07-21 19:22         ` Simon Wright
2012-07-21 19:38           ` Patrick
2012-07-21 22:53         ` Brian Drummond
2012-07-22  3:25           ` Patrick
2012-07-22 17:54             ` Brian Drummond
2012-07-22 17:59               ` Brian Drummond
2012-07-22 18:44                 ` Patrick
2012-07-22 21:03                   ` Brian Drummond
2012-07-25 19:10                   ` J-P. Rosen
     [not found]               ` <m2a9yrsbf5.fsf@nidhoggr.home>
     [not found]                 ` <jui36a$hs0$1@dont-email.me>
2012-07-23 10:10                   ` Simon Wright
2012-07-24 10:55                     ` Brian Drummond
2012-07-22 21:25             ` Niklas Holsti
2012-07-22 22:00               ` Patrick
2012-07-22 21:18         ` Niklas Holsti
2012-07-21  0:27   ` Randy Brukardt
2012-07-21  7:36     ` Dmitry A. Kazakov
2012-07-21 13:31     ` Niklas Holsti [this message]
     [not found]   ` <olpj085ii9fpifpligh6jerghoaieiim1d@invalid.netcom.com>
2012-07-20 23:38     ` Patrick
2012-07-21 13:12     ` Niklas Holsti
2012-07-23  5:02 ` Miles Bader
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox