comp.lang.ada
 help / color / mirror / Atom feed
From: Paul Rubin <no.email@nospam.invalid>
Subject: Re: Implicit actions & program correctness
Date: Fri, 15 May 2020 15:09:59 -0700
Date: 2020-05-15T15:09:59-07:00	[thread overview]
Message-ID: <871rnk97ew.fsf@nightsong.com> (raw)
In-Reply-To: 3c545096-d000-4d09-b3fe-ad8530632457@googlegroups.com

deadhacker <gstover@gmail.com> writes:
> I'd rather see explicit code like this:
> if is spam, error
> elsif is not authenticated, redirect to authentication
> elsif is not authorized, error
> else vend the resource.
>
> Seems that Ada, at least in the books I've been reading, nudges the
> programmer to work that way, so I was wondering what people with
> actual Ada experience have to say about it.  Does Ada nudge you to
> work that way?  And are you glad you do work that way?

Ideally you want to enforce those invariants at compile time, so you
don't have to do runtime checks.  You should only be able to vend given
an authorized request, where "authorized request" is a type, so the type
system enforces it.  Similarly to create an authorized request you have
to start with an authenticated one, etc.

You might like this article (not Ada specific):

http://blog.tmorris.net/posts/understanding-practical-api-design-static-typing-and-functional-programming/

  reply	other threads:[~2020-05-15 22:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-15 17:45 Implicit actions & program correctness deadhacker
2020-05-15 17:55 ` deadhacker
2020-05-15 18:27 ` Nasser M. Abbasi
2020-05-15 19:01 ` Paul Rubin
2020-05-15 19:03 ` Jeffrey R. Carter
2020-05-15 20:13   ` deadhacker
2020-05-15 22:09     ` Paul Rubin [this message]
2020-05-25 20:15       ` deadhacker
2020-05-25 20:36         ` Niklas Holsti
2020-05-25 22:31         ` Paul Rubin
2020-05-26  8:47           ` Niklas Holsti
2020-05-26  9:55             ` Paul Rubin
2020-05-16 13:52     ` Brian Drummond
2020-05-16 10:10 ` Niklas Holsti
replies disabled

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