comp.lang.ada
 help / color / mirror / Atom feed
From: Paul Rubin <no.email@nospam.invalid>
Subject: Re: Implicit actions & program correctness
Date: Mon, 25 May 2020 15:31:31 -0700
Date: 2020-05-25T15:31:31-07:00	[thread overview]
Message-ID: <87o8qb7ikc.fsf@nightsong.com> (raw)
In-Reply-To: 14afb70d-cb70-4ca2-bd24-f9d9664ee103@googlegroups.com

deadhacker <gstover@gmail.com> writes:
> Sadly, his Java API is no longer available, so I can't see how he
> solved it.
> Do you (or anyone else here) know how it could be solved with Ada?

I didn't look at the Java code (don't know if it was posted somewhere)
but I'd expect it is done with Java classes and subclasses.  You'd have
a class for game state, and container (wrapper) classes for "initial",
"non-initial", "finished", and "non-finished".  Each wrapper would
either be empty, or contain a state of the specified type.

The "move" function would accept a non-finished state as a parameter,
and return three maybe-empty wrapper objects containing the new state.
To call "move" again you'd have to look in the "non-finished" wrapper to
get a non-finished state from it, in the event that there is one.  If
the non-finished wrapper is empty, then the game is finished and there
is no way to call "move" again.   Similarly with takeback, etc.

In Haskell, I did the exercise with numerically-indexed GADT's, but that
approach seemed hacky so I might try it again.

  parent reply	other threads:[~2020-05-25 22:31 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
2020-05-25 20:15       ` deadhacker
2020-05-25 20:36         ` Niklas Holsti
2020-05-25 22:31         ` Paul Rubin [this message]
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