[Vm-dev] Sometimes it's too easy, part II
siguctua at gmail.com
Thu Jan 26 20:20:16 UTC 2017
with C i was always wondering, why C standard does not provides
an unsigned integer type which size strictly corresponds to size of pointer
sizeof(some standard uint) == sizeof(void*)
that would solve so many problems and make thing so much easier..
instead they had this:
Data Type: *ptrdiff_t*
This is the signed integer type of the result of subtracting two pointers.
For example, with the declaration char *p1, *p2;, the expression p2 - p1 is
of type ptrdiff_t. This will probably be one of the standard signed integer
types (short int, int or long int), but might be a nonstandard type that
exists only for this purpose.
it is easy to see, that sizeof(ptrdiff_t) should be _at least_ the
sizeof(void*), else it won't be able to cover all possible values when
taking difference between two pointers..
alas, it is signed.. and alas, nothing says that it cannot be _more_ than
size of pointer in memory.. simply because you can always fit values that
take 32 bits into 64-bit value holder..
One could say, that there's size_t that could be used as a unsigned
alternative to ptrdiff_t,
unfortunately, ISO gives no guarantees that its size corresponds to pointer
Btw,look what i found :)
that could be useful for implementing small-int arithmetics in plain C..
unfortunately this is extension, and don't shoot for proposing to use
non-standard C herecy :)
On 26 January 2017 at 21:37, 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