<div dir="ltr">At the risk of getting dragged into a complicated discussion, I think it would be productive to drop the complaints about the unfortunate &quot;PEBKAC&quot; reference.<br><br>I think it does make sense to have areas where the spec can leave the desired behavior undefined (e.g. low memory conditions, etc.). I interpreted the &quot;problem exists elsewhere&quot; to mean the spec doesn&#39;t need to cover every eventuality.<br>
<br>If I am mistaken you are welcome to ignore this suggestion :)<br><br>Steve<br><br><div class="gmail_quote">On Sun, Oct 19, 2008 at 5:11 PM, Richard O&#39;Keefe <span dir="ltr">&lt;<a href="mailto:ok@cs.otago.ac.nz">ok@cs.otago.ac.nz</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><br>
On 17 Oct 2008, at 7:00 pm, Paolo Bonzini wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Again, an exceedingly unhelpful response.<br>
</blockquote>
<br>
To explain my short answer of PEBKAC: the keyboard and the chair are the<br>
programmer&#39;s, if that&#39;s not clear.<br>
</blockquote>
<br></div>
It most definitely wasn&#39;t.<div class="Ih2E3d"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
&nbsp;The standard *can* provide methods<br>
that sometimes make sense and sometimes don&#39;t. &nbsp;If they don&#39;t, and the<br>
result could be infinite request of memory or an infinite loop, it&#39;s a<br>
problem of the user.<br>
</blockquote>
<br></div>
And now we are back to the ambiguous &quot;user&quot;.<br>
<br>
The thing is, if you persist in this attitude, *everything*<br>
ends up being the fault of the woman in the ATM queue.<br>
Everyone else just says &quot;it&#39;s not MY problem, PEBKAC PEBKAC PEBKAC&quot;.<br>
<br>
I suspect that you may be muddling up two distinguishable<br>
interpretations of &quot;sometimes make sense and sometimes don&#39;t&quot;.<br>
<br>
(1) If the standard specifies a precondition<br>
 &nbsp; &nbsp;and a method invocation violates that precondition,<br>
 &nbsp; &nbsp;that&#39;s a method that &quot;sometimes makes sense and sometimes doesn&#39;t&quot;.<br>
 &nbsp; &nbsp;If the precondition is not spelled out, it&#39;s the standard&#39;s fault.<br>
 &nbsp; &nbsp;If it spelled out and violated anyway, it&#39;s the programmer&#39;s<br>
 &nbsp; &nbsp;fault, PROVIDED the standard provides means for the programmer<br>
 &nbsp; &nbsp;to detect the fault in advance.<br>
<br>
(2) If the standard specifies a precondition and a postcondition<br>
 &nbsp; &nbsp;and a method invocation satisfies the precondition<br>
 &nbsp; &nbsp;but the postcondition is violated, then it&#39;s NOT the<br>
 &nbsp; &nbsp;programmer&#39;s fault: if the standard has specified a result<br>
 &nbsp; &nbsp;that cannot be achieved, it is the standard&#39;s fault; if the<br>
 &nbsp; &nbsp;standard&#39;s result could be achieved but the implementation<br>
 &nbsp; &nbsp;doesn&#39;t do that, it&#39;s the implementor&#39;s fault.<br>
<br>
Let&#39;s restructure that and introduce some technical terms:<br>
<br>
 &nbsp; &nbsp;programmer error:<br>
 &nbsp; &nbsp; &nbsp; &nbsp;precondition violated, programmer could have known<br>
 &nbsp; &nbsp;programmer incapacity:<br>
 &nbsp; &nbsp; &nbsp; &nbsp;precondition violated, programmer could not have<br>
 &nbsp; &nbsp; &nbsp; &nbsp;known<br>
 &nbsp; &nbsp;implementation error:<br>
 &nbsp; &nbsp; &nbsp; &nbsp;precondition ok, postcondition violated,<br>
 &nbsp; &nbsp; &nbsp; &nbsp;implementation wrong<br>
 &nbsp; &nbsp;implementation limit:<br>
 &nbsp; &nbsp; &nbsp; &nbsp;precondition ok, postcondition not established,<br>
 &nbsp; &nbsp; &nbsp; &nbsp;implementation basically ok but ran out of something<br>
 &nbsp; &nbsp;standard error:<br>
 &nbsp; &nbsp; &nbsp; &nbsp;precondition ok, postcondition violated,<br>
 &nbsp; &nbsp; &nbsp; &nbsp;no reasonable implementation _could_ get it right.<br>
<br>
<br>
The key discriminant here is the precondition.<br>
I am not saying that the standard could or should specify<br>
only things that work all the time (we&#39;d have no floating<br>
point arithmetic in that case). &nbsp;But I am saying that the<br>
standard should be more explicit about preconditions. &nbsp;It<br>
is explicit about argument types, &nbsp;but that&#39;s pretty much<br>
as far as it goes.<br>
<br>
There&#39;s also the problem in something like Smalltalk that<br>
the standard has two faces. &nbsp;When <a href="http://5.3.1.1" target="_blank">5.3.1.1</a> says that #=<br>
only returns true and false and has no errors, it is<br>
&nbsp;- making a PROMISE that implementations will get this right<br>
 &nbsp; for the standard &quot;classes&quot;,<br>
&nbsp;- setting out a REQUIREMENT for users who want to define<br>
 &nbsp; the same method.<br>
<br>
Some claims clearly cannot be taken at face value because of<br>
global resource limits: &nbsp;<a href="http://5.3.1.6" target="_blank">5.3.1.6</a> says that #copy has no<br>
errors, but despite that it&#39;s obvious that an attempt to<br>
copy some object may fail because there is not enough memory<br>
left. &nbsp;But this is something that applies to *every* method:<br>
#= could try to allocate arbitrary amounts of data on its<br>
way to a true or false. &nbsp;There are similar issues with<br>
opening files.<br>
<br>
The standard needs to say something about this.<br>
If there&#39;s a section of the ANSI standard that talks about<br>
it, I&#39;ve been unable to find it.<br>
<br>
Note that running out of memory is an implementation limit.<br>
It&#39;s not PEBKAC. &nbsp;(Hare PEBKAC, hare PEBKAC, hare hare.)<br>
<br>
For an example of something that&#39;s a programmer error,<br>
 &nbsp; &nbsp; &nbsp; &nbsp;nil perform: #==<br>
because <a href="http://5.3.1.15" target="_blank">5.3.1.15</a> says the behaviour is undefined if the<br>
number of arguments (here 0) does not match that implicitly<br>
required by the syntactic form of the selector (here 1), so<br>
the precondition is violated, and it is practical to check,<br>
so it&#39;s an error, not an incapacity.<br>
<br>
Anyone designing a new language would almost surely have<br>
designated a standard exception to be raised when #perform:<br>
gets an arity clash. &nbsp;It seems bizarre that ANSI Smalltalk<br>
has one of the most elaborate exception handling schemes<br>
around and makes so little use of it. &nbsp;But that&#39;s another<br>
issue.<div class="Ih2E3d"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
Certainly, it would be *insane* to require that #contents detects device<br>
files where it cannot terminate.<br>
</blockquote>
<br></div>
You keep on talking about cases where #contents cannot<br>
TERMINATE. &nbsp;But I was and remain talking mainly about<br>
cases where #contents cannot START. &nbsp;And it is not only<br>
not insane to detect that, it&#39;s quite easy.<br>
<br>
&nbsp;- if you only have write access to an external resource,<br>
 &nbsp; you can *never* perform #contents on it. &nbsp;So it doesn&#39;t<br>
 &nbsp; *EVER* make sense to have #contents in the &lt;writeFileStream&gt;<br>
 &nbsp; protocol.<br>
<br>
&nbsp;- if you cannot seek back to the beginning of an external<br>
 &nbsp; resource, you can *never* find the full contents.<br>
 &nbsp; This applies to sockets, pipes, ttys, ptys, and all that<br>
 &nbsp; kind of thing. &nbsp;And at least on Windows, VMS, MCP, and<br>
 &nbsp; UNIX variants, it&#39;s dead simple to recognise such things.<br>
 &nbsp; To a first approximation, it doesn&#39;t make sense to have<br>
 &nbsp; #contents in the interface of anything but a plain disc<br>
 &nbsp; file stream.<br>
<br>
 &nbsp; Far from being insane, this is exactly what Squeak and<br>
 &nbsp; VisualWorks do: for the sake of #position: and #contents<br>
 &nbsp; they won&#39;t let me open anything where those operations<br>
 &nbsp; would not work. &nbsp;Why would anyone call insane what actual<br>
 &nbsp; systems actually *do*?<br>
<br>
&nbsp;- if you are reading from a disc file, another process might<br>
 &nbsp; be writing to it at the same time. &nbsp;This is why the &#39;tail&#39;<br>
 &nbsp; command has the &#39;-f&#39; option. &nbsp;Of course, in this case the<br>
 &nbsp; whole notion of &quot;THE contents&quot; of the stream is problematic.<br>
 &nbsp; However, the strategy of determining the size *now* and<br>
 &nbsp; reading up to that will work (as indeed the &#39;tail&#39; command<br>
 &nbsp; normally does).<br>
<br>
So #contents belongs in &lt;readFileStream&gt; only,<br>
not in &lt;writeFileStream&gt;, and it requires a precondition<br>
something like<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&quot;#contents need not work for all kinds of external<br>
 &nbsp; &nbsp; &nbsp; &nbsp;file; it is implementation-defined which.&quot;<div class="Ih2E3d"><br>
<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
&nbsp;And it would be even *impossible* to<br>
detect in advance whether #contents on a socket would terminate,<br>
</blockquote>
<br></div>
Not relevant. &nbsp;Because we can&#39;t seek, we can&#39;t get the<br>
*PAST* sequence values, so it is quite certain that #contents<br>
does not make sense for a socket.<div class="Ih2E3d"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
but yet<br>
it would be useful to provide #contents on a socket.<br>
</blockquote>
<br></div>
I doubt it. &nbsp;I suspect you are thinking of reading up to the<br>
end, which is quite different from #contents.<div class="Ih2E3d"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
&nbsp;It&#39;s a problem<br>
that *programmers* sitting between a keyboard and a chair have to solve,<br>
not whoever writes the standard.<br>
</blockquote>
<br></div>
The standard needs to first give them the TOOLS.<div class="Ih2E3d"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
there is no &quot;THE ... way&quot; that the Array new: call<br>
would fail;<br>
</blockquote>
<br>
But I&#39;d expect #contents on a 500 GB data file to fail *that same* way.<br>
</blockquote>
<br></div>
I wouldn&#39;t.<div class="Ih2E3d"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

The erratum here is that #contents belongs in &lt;gettableStream&gt; and<br>
&lt;WriteStream&gt;, not in &lt;collectionStream&gt; and &lt;FileStream&gt;. &nbsp;I sent<br>
another email on the subject.<br>
</blockquote>
<br>
Except that for smallish files, #contents is quite useful.<br>
</blockquote>
<br>
Indeed. &nbsp;&lt;FileStream&gt; *is* a &lt;gettableStream&gt; isn&#39;t it?<br>
</blockquote>
<br></div>
We both made mistakes here. &nbsp;No, &lt;FileStream&gt; isn&#39;t a<br>
&lt;gettableStream&gt;, but &lt;readFileStream&gt;, which I think is what you<br>
meant, _is_.<br>
<br>
However, &lt;gettableStreams&gt; in general cannot support #contents<br>
either. &nbsp;Do we agree that #contents belongs in &lt;ReadStream&gt;,<br>
&lt;WriteStream&gt;, and &lt;fileReadStream&gt;?<div><div></div><div class="Wj3C7c"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
Paolo<br>
<br>
_______________________________________________<br>
ANSI-Smalltalk mailing list<br>
<a href="mailto:ANSI-Smalltalk@lists.openskills.org" target="_blank">ANSI-Smalltalk@lists.openskills.org</a><br>
<a href="http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk" target="_blank">http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk</a><br>
<br>
</blockquote>
<br>
<br>
_______________________________________________<br>
ANSI-Smalltalk mailing list<br>
<a href="mailto:ANSI-Smalltalk@lists.openskills.org" target="_blank">ANSI-Smalltalk@lists.openskills.org</a><br>
<a href="http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk" target="_blank">http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk</a><br>
</div></div></blockquote></div><br></div>