On Fri, Apr 3, 2015 at 2:27 AM, Aistis Raulinaitis
<[email protected]> wrote:
> It's an honor. If I stay to only total functions then my code is guaranteed
> to be either productive or guaranteed to terminate. Knowing that my program
> will never "crash" if I remain disciplined is a good starting point. Modulo
> infinite recursion and dirty data, but apparently Haskell can "solve the
> halting problem" with a <<loop>> exception, by doing some simple code path
> analysis, which I rarely, if ever bump into. For the sake of utility you
> can define partial functions as well, since working with a language with
> only total functions would not be very fun.
You can solve the halting problem in J if you work with a suitably
constrained subset of the language.
Here's a quick sketch:
Things to favor:
tacit code (avoid the ( : noun) form)
Things to avoid:
names, $: ^: foreigns &
Possibly I have overlooked something (especially in the context of
future implementations of J).
These rules can be relaxed when you understand the reasons for them:
With these rules in place, the code should always halt, making the
halting problem trivial.
Thus, for example, you can make an exception and use names if applying
f. removes all of them.
Thus, for example, you can use & if you can guarantee that you avoid
giving bonded verbs a potentially infinite left argument. (Do not do
this: _ +&0 i. 3)
And, of course, sometimes you want code that has the halting problem
(which is to say: it keeps running until someone turns it off).
Whether this is fun, or not, depends not only on your sense of fun,
but on what you are trying to accomplish.
Thanks,
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm