<div dir="ltr"><div><div><div><div>Some requirements:<br><br>1) Slang must be able to code boolean and arithmetic expressions without the need of type hint.<br><div><br></div>2) If we still want to support 32bits image on 64bits VM,
 then it would be good to avoid implicit conversions between machine 
pointer (char *) and oop. We should allways use char 
*pointerForOop(sqOop oop) and sqOop oopForPointer(char *).<br><br>3) we must avoid as much as possible to invoke UB, or the compiled code will start to crash or behave wrongly as soon as we use an optimization flag, and this will get worse at each C compiler version.<br><br></div><div>So far, sqInt is defined as default type and works well for 1).<br></div><div>We have to cast to unsigned here and there though to avoid UB (like left shifting a signed value, or testing for overflow in post condition). But also to avoid unwanted sign extension when we manipulate chnuks of bit (like high and low part) - we had several bugs with that.<br><br>I much prefer unsigned, because it's almost free from UB. With signed, we just don't have right to overflow, that's crazy...<br>But if we switch to unsigned, my fear is to have to add many type hints...<br><div>Because telling automatically which arithmetic expressions requires signed, and which would work with unsigned is not easy.</div></div><div>for example, for( i=size-1;i >= 0; i--)  isn't going to do what we want.<br></div><div>Nor c = a - b; if ( c < 0 ) ...</div></div></div><br></div><div>Declaring sqOop as a union could help 2) but would hardly fit 1).<br><div>Maybe type inference can solve it entirely, and it's not a problem?<br><br></div><div>Declaring sqOop as (char *) would not support 2)<br>And we could not compare oops any more because it's UB!<br></div><div>We could eventually use slang type inference and force (usqInt) oop1 < (usqInt) oop2...<br></div><div>I don't like this option and much prefer explicit char 
*pointerForOop(sqOop oop) and sqOop oopForPointer(char *).</div><div><div><div><div><br></div></div></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-01-26 20:37 GMT+01:00 John McIntosh <span dir="ltr"><<a href="mailto:johnmci@smalltalkconsulting.com" target="_blank">johnmci@smalltalkconsulting.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> <br>+1<br>
<br>
Sent from my iPhone<br>
<br>
> On Jan 26, 2017, at 10:58, David T. Lewis <<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>> wrote:<br>
><br>
><br>
> +1<br>
><br>
> Dave<br>
><br>
>><br>
>> Surely since we’re concerned about (ab)use of signed values for pointers<br>
>> to words we ought to define a â€˜proper’ sqOop thing and use that<br>
>> instead of a slightly cleaned up derivative of how the Slang default was<br>
>> left as â€˜int’ twenty years ago?<br>
>><br>
>> Yes, any change means a bunch of work to do but isn’t that always the<br>
>> price to improve things?<br>
>><br>
>> tim<br>
>> --<br>
>> tim Rowledge; <a href="mailto:tim@rowledge.org">tim@rowledge.org</a>; <a href="http://www.rowledge.org/tim" rel="noreferrer" target="_blank">http://www.rowledge.org/tim</a><br>
>> Strange OpCodes: LB: connect Line-voltage to BITNET<br>
>><br>
>><br>
>><br>
><br>
><br>
<br></blockquote></div><br></div>