<div dir="ltr">Hi David,<div class="gmail_extra"><br><div class="gmail_quote">On Sun, Mar 25, 2018 at 6:21 PM, David T. Lewis <span dir="ltr"><<a href="mailto:lewis@mail.msen.com" target="_blank">lewis@mail.msen.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Hi Eliot,<br>
<br>
I have not given this much thought, but just to get the discussion going<br>
I'll answer from the POV of maintaining a package like OSProcess. As the<br>
maintainer, I would be happier to just fix my code and be done with it,<br>
as opposed to trying to answer questions from various people who might<br>
or might not have have yet another obscure preference set.<br></blockquote><div><br></div><div>Good :-)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">But the counter argument is that not all of the useful external packages<br>
have active maintainers, and we don't want to set up a situation where<br>
those packages cannot be used. I don't know if that would be the case<br>
here, but if so we would be well advised to provide a preference to keep<br>
those packages useable.<br></blockquote><div><br></div><div>But since it's trivial to fix these issues I'm not worried by this.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
<br>
If we do add a preference, then I would rather that the default be to<br>
simply raise an error (your preferred state of affairs), and the preference<br>
would exist only in the interest of allowing existing (unmaintained?)<br>
packages to be loaded and run.<br>
<br>
Off topic for your question, but just for my own understanding - why is<br>
it good for a ByteArray to be read-only? I would have thought that it<br>
would be just an array of things that happen to be very small positive<br>
integers (sorry I am sure this has been discussed before).<br></blockquote><div><br></div><div>This example applies to strings, arrays and byte arrays:</div><div><br></div><div>Object>>modifyLiteral</div><div><div><span class="gmail-Apple-tab-span" style="white-space:pre">   </span>| stream |</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>stream := ReadWriteStream on: #[1 2 3 4] from: 1 to: 4.</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>{stream contents. stream reset; nextPut: 255; setToEnd; contents}</div></div><div><br></div><div>In the current system, the first time this is run it answers #(#[1 2 3 4] #[255 2 3 4]) and thereafter (or until it is recompiled) it answers #(#[255 2 3 4] #[255 2 3 4]).  Ugh :-).  With read-only literals it raises an error; the at:put: in nextPut: fails and raises ModificationForbidden.  Note that such modification of literals is invisible unless one decompiles the method.  The source of the method remains unchanged, cloaking the bug.</div><div><br></div><div>Note that changing the example to</div><div><br></div><div><div>Object>>modifyCopyOfLiteral</div><div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>| stream |</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>stream := ReadWriteStream on: #[1 2 3 4] copy from: 1 to: 4.</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">   </span>{stream contents. stream reset; nextPut: 255; setToEnd; contents}</div></div></div><div><br></div><div>causes the method to behave unsurprisingly.  Hence my claim that fixing these issues is trivial (deepCopy can be used to produce a mutable copy of a literal array of literals, for example).</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Dave<br>
<div class="gmail-HOEnZb"><div class="gmail-h5"><br>
<br>
On Sun, Mar 25, 2018 at 04:18:32PM -0700, Eliot Miranda wrote:<br>
> Hi All,<br>
><br>
>     the VM now has support for read only objects, and the first logical<br>
> application is for literals, making boxed floats, strings, symbols, arrays<br>
> and byte arrays read-only.  Doing so is trivial; only two methods need to<br>
> be modified (see attached).  AFAIA little or no core code is broken by<br>
> making literals read-only.  However, when I ran the test suite with<br>
> read-only literals in place, several tests were broken.  These are things<br>
> like creating null-terminated strings for testing OSProcess, by replacing<br>
> spaces in string literals with zeros, etc.<br>
><br>
> When we added read-only literals to VisualWorks in something like vw7.0 the<br>
> balance of opinion was that we should not break user code.  Hence we<br>
> implemented a preference scheme with three states:<br>
><br>
> - By default, an attempt to modify a read-only literal would silently make<br>
> the literal mutable temporarily,update it and then reenable read-onlyness.<br>
> - A second state would issue a warning to the transcript, while doing what<br>
> the default did.<br>
> - The third state would raise an error<br>
><br>
> Remember that all one needs to do to fix code that modifies literals is to<br>
> send copy to the literal before modifying the copy, since copies of<br>
> read-only literals are mutable.<br>
><br>
> I was on the side of only raising an error, but was overruled :-).  I<br>
> wonder what this community thinks.  If there are strong views that user<br>
> code should continue to function unchanged (even though it is modifying<br>
> literals, which is so so wrong :-) ) I'm happy to implement a scheme<br>
> similar to that for VisualWorks.  But I'd rather not have to and simply<br>
> have people fix their code within a system that raises an error whenever an<br>
> attempt is made to modify a literal, and is as simple as possible, but no<br>
> simpler ;-)  Thoughts, opinions?<br>
><br>
><br>
> _,,,^..^,,,_<br>
> best, Eliot<br>
<br>
<br>
><br>
<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>