<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:Arial;}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;}
p.MsoAutoSig, li.MsoAutoSig, div.MsoAutoSig
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
span.Typed
{font-family:"Courier New";}
span.tty
{font-family:"Courier New";}
span.Name
{font-style:italic;}
span.Variable
{font-family:"Times New Roman";
font-style:italic;}
span.EmailStyle21
{font-family:Arial;
color:windowtext;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
{page:Section1;}
/* List Definitions */
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
-->
</style>
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal>I am writing my first Erlang program, and found myself
requiring a data type that simulates a finite tape (i.e., a finite version of a
Turing machine’s tape). I am attaching here the documentation (produced
by edoc) and the module source code in case anyone is interested. On the
off-chance that someone is interested, I wonder if you could help me:</p>
<p class=MsoNormal> </p>
<ol style='margin-top:0in' start=1 type=1>
<li class=MsoNormal>Did I take the correct overall approach? No
knowledge of the internal storage of a tape is required in order to use
the ADT, so I think I did it about right.</li>
</ol>
<p class=MsoNormal style='margin-left:.25in'> </p>
<ol style='margin-top:0in' start=2 type=1>
<li class=MsoNormal>Is the module name “tape” appropriate, or
should I either rename it to “finite_tape” or add support for infinite
tapes in order to name it “tape”? While I am sure you’re
thinking that’s up to me, ideally, if this is useful to others, I
would submit it to some repository for use by others.</li>
</ol>
<p class=MsoNormal> </p>
<ol style='margin-top:0in' start=3 type=1>
<li class=MsoNormal>Do I handle errors correctly? I was kind of
schizophrenic in that I do not handle a move beyond the edge of the tape
(causing an error), but in other cases, such as reading or writing a tape
cell, I return the <span style='font-family:Consolas'>{ok, …}</span>
tuple or an atom indicating an error. (I suppose I should have
returned <span style='font-family:Consolas'>{error, null_tape}</span>
instead of plain old <span style='font-family:Consolas'>null_tape</span>
in this case, right?) The cause of my schizophrenia was that I
started out thinking that The Erlang Way is to not do any error checking
and let errors fall where they may, but then I thought of other Erlang code
which prefers to signal exceptions with the return tuple, so I switched my
style half way through. Naturally, I would fix this before
publishing, but I just don’t know which way to fix it. Advice?</li>
</ol>
<p class=MsoNormal> </p>
<ol style='margin-top:0in' start=4 type=1>
<li class=MsoNormal>Did I document it using edoc correctly? Mainly I
just used <span style='font-family:Consolas'>@spec</span>’s and <span
style='font-family:Consolas'>@doc</span>’s, and the result is
attached.</li>
</ol>
<p class=MsoNormal> </p>
<ol style='margin-top:0in' start=5 type=1>
<li class=MsoNormal>Does anyone else think this is useful, or is this
functionality already available in a library somewhere that I overlooked?</li>
</ol>
<p class=MsoNormal> </p>
<ol style='margin-top:0in' start=6 type=1>
<li class=MsoNormal>Is it normal in Erlang, when creating functions that act
on an ADT, for the abstract data value to be passed as the last argument (as
I did) or to pass it as the first argument? E.g., should I have
defined <span style='font-family:Consolas'>move/2</span> as</li>
</ol>
<p class=MsoNormal style='margin-left:1.0in'><span style='font-family:Consolas'>move(N::integer()
| first | last, Tape::tape()) -> tape()</span></p>
<p class=MsoNormal style='margin-left:.5in'>or</p>
<p class=MsoNormal style='margin-left:1.0in'><span style='font-family:Consolas'>move(Tape::tape(),
N::integer() | first | last) -> tape()</span></p>
<p class=MsoNormal style='margin-left:.5in'>?</p>
<p class=MsoNormal> </p>
<p class=MsoNormal>Any advice appreciated. Else, I’ll continue
along my happy way.</p>
<p class=MsoNormal> </p>
<p class=MsoNormal>Cheers,</p>
<p class=MsoNormal> </p>
<p class=MsoNormal>David</p>
</div>
</body>
</html>