[Vm-dev] Sometimes it's too easy, part II
nicolas.cellier.aka.nice at gmail.com
Thu Jan 26 20:25:35 UTC 2017
1) Slang must be able to code boolean and arithmetic expressions without
the need of type hint.
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
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.
So far, sqInt is defined as default type and works well for 1).
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.
I much prefer unsigned, because it's almost free from UB. With signed, we
just don't have right to overflow, that's crazy...
But if we switch to unsigned, my fear is to have to add many type hints...
Because telling automatically which arithmetic expressions requires signed,
and which would work with unsigned is not easy.
for example, for( i=size-1;i >= 0; i--) isn't going to do what we want.
Nor c = a - b; if ( c < 0 ) ...
Declaring sqOop as a union could help 2) but would hardly fit 1).
Maybe type inference can solve it entirely, and it's not a problem?
Declaring sqOop as (char *) would not support 2)
And we could not compare oops any more because it's UB!
We could eventually use slang type inference and force (usqInt) oop1 <
I don't like this option and much prefer explicit char *pointerForOop(sqOop
oop) and sqOop oopForPointer(char *).
2017-01-26 20:37 GMT+01:00 John McIntosh <johnmci at smalltalkconsulting.com>:
> Sent from my iPhone
> > On Jan 26, 2017, at 10:58, David T. Lewis <lewis at mail.msen.com> wrote:
> > +1
> > Dave
> >> Surely since weâ€™re concerned about (ab)use of signed values for
> >> to words we ought to define a â€˜properâ€™ sqOop thing and use that
> >> instead of a slightly cleaned up derivative of how the Slang default was
> >> left as â€˜intâ€™ twenty years ago?
> >> Yes, any change means a bunch of work to do but isnâ€™t that always the
> >> price to improve things?
> >> tim
> >> --
> >> tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
> >> Strange OpCodes: LB: connect Line-voltage to BITNET
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Vm-dev