comp.lang.ada
 help / color / mirror / Atom feed
From: Keith Thompson <kst-u@mib.org>
Subject: Re: Implementing Rust's borrow checked pointers
Date: Tue, 24 Sep 2019 15:24:32 -0700
Date: 2019-09-24T15:24:32-07:00	[thread overview]
Message-ID: <lna7at5o4f.fsf@kst-u.example.com> (raw)
In-Reply-To: 1bf5a548-4d06-4a95-87f6-1e1170b04c99@googlegroups.com

Lucretia <laguest9000@googlemail.com> writes:
> On Tuesday, 24 September 2019 20:13:33 UTC+1, Keith Thompson  wrote:
>> Lucretia <no> writes:
>> > On Tuesday, 24 September 2019 12:23:30 UTC+1, Optikos  wrote:
>> >
>> >> > begin
>> >> >    A.all ... ; -- raises exception.
>> >> 
>> >> No, to be as useful as Rust's borrow checker, instead of raising
>> >> exception, it needs to be a compile-time error.  The compiler needs
>> >> to maintain a whole-program directed graph at compile-time, not defer
>> >> a detection-based localized analysis to run-time.
>> >
>> > Yes, the compiler would raise that exception at compile time. This
>> > idea that all exceptions are raised at runtime is false and you should
>> > check the AARM.
>> 
>> Can you provide a specific citation?
>
> No, I'm fairly sure I saw it in one of the AARM's under compilation
> requirements years ago, but I cannot find it now.
>
>> Certainly a compiler can diagnose an error at compile time, but I've
>> never heard that referred to as an "exception".  And a compiler can
>> generate code that unconditionally raises an exception, but that code is
>> executed at run time.
>
> I read it as the environment raises an exception like program_error on
> a compilation error.

Normally a compilation error prevents the generation of an executable,
so there's no environment in which an exception could be raised.

I suspect you're thinking of this (quoting the 2012 RM):

    Implementation Advice

    If an implementation detects a bounded error or erroneous execution,
    it should raise Program_Error.

"Erroneous execution" refers to an error that the implementation
is not required to detect or diagnose (called "undefined behavior"
in some other languages).  "Bounded errors" are similar, but are
limited in what can happen if the error occurs.

The "implementation" raising Program_Error doesn't imply a
compile-time exception.  Rather the compiler can generate code
that will (unconditionally) raise Program_Error at run time.
And the compiler may also issue a compile-time warning (as it can
about anything).

Unless I've missed something, there is no such thing as a
compile-time exception.  (A compiler implemented in Ada -- or C++,
for that matter -- might/throw raise an exception, but that's
a compiler bug if it's not handled.  The Ada standard makes no
assumptions about how a compiler is implemented.)

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

  reply	other threads:[~2019-09-24 22:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-24  9:05 Implementing Rust's borrow checked pointers Lucretia
2019-09-24  9:57 ` Dmitry A. Kazakov
2019-09-24 11:23 ` Optikos
2019-09-24 12:02   ` Lucretia
2019-09-24 14:08     ` Optikos
2019-09-24 18:56     ` Simon Wright
2019-09-24 19:13     ` Keith Thompson
2019-09-24 20:15       ` Optikos
2019-09-24 20:31         ` Keith Thompson
2019-09-24 20:40           ` Optikos
2019-09-24 20:53             ` Keith Thompson
2019-09-24 22:09       ` Lucretia
2019-09-24 22:24         ` Keith Thompson [this message]
2019-09-25  4:36         ` J-P. Rosen
2019-09-25 15:04           ` Simon Wright
2019-09-24 12:23 ` Lucretia
2019-09-25 17:21   ` Stephen Leake
2019-09-24 16:24 ` Jeffrey R. Carter
2019-09-25 16:26   ` Florian Weimer
replies disabled

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