Re: Dynamically resizing a buffer
"Flash Gordon" <spam@flash-gordon.me.ukwro te in message
news:ck60q4x2tf .ln2@news.flash-gordon.me.uk...
<snip>
>
Not if one is being sensible.
>
>
I have spent years programming in assembler where I would use shifts and
years spent programming in high level languages where I would not.
>
yeah, I also use assembler...
otherwise:
I always used shifts, never thought much of it.
I use shifts where I think shifts, I had never thought to think divides...
if I were thinking of a divide, than i/3 is an obvious difference from i/2.
if I was not, it is not.
it is a non-obvious jump from 'i>>1' to 'i/3', unless one first thinks that
'i>>1' is actually 'i/2'...
>
A trivial mistake that does not get made if you code what you want to
express instead of trying to use tricks. That is part of the point.
>
'want to express'?...
this implies certain things, ie, that what I would want to express is
different from the code I would write to express it.
do you ask me, if my grammar is unusual, if it is because I am not writing
what I am meaning to express?...
it is a similar question IMO...
'tricks'?...
shifts are a basic operator, I don't see why they would be viewed as any
kind of trick...
do we call pointers and casts tricks as well?... typical code is riddled
with the things, nothing sinister there...
now, does one think in terms of arithmetic ops or in terms of bitwise
ops?...
does one do their everyday arithmetic (internally) in decimal or in hex?...
if we read something do we see the text, hear words, or see imagery?...
this kind of issue has not come up in any time in recent memory...
so, one thinks in hex and writes in decimal, or vice versa, not usually that
important.
and, if one happens to be thinking in hex right, then a shift is more
intuitive than a divide.
does one think of the money in their wallet as 300 or 0x12C?...
does one think in british or metric units?...
or does one use whatever system happens to seem more natural at that
instant?...
up to them really. it only matters that when someone asks that they give the
right number, and when they read that they don't get confused...
one typically doesn't know the magic going on even in ones' own head...
>
Exponential is also a natural growth curve, if you don't believe me check
how populations grow in nature, for at least some it is exponential until
a crash.
>
when applied recursively, this is exponential...
yeah...
"Flash Gordon" <spam@flash-gordon.me.ukwro te in message
news:ck60q4x2tf .ln2@news.flash-gordon.me.uk...
cr88192 wrote, On 23/08/07 11:12:
>>
>not optimizations. shifts are how one typically does these things...
>not optimizations. shifts are how one typically does these things...
Not if one is being sensible.
>
>it is much the same as why we call int variables i, j, and k I think, or
>many other common practices. after enough years, and enough code, one
>largely forgets any such reasoning, all rote response really...
>many other common practices. after enough years, and enough code, one
>largely forgets any such reasoning, all rote response really...
I have spent years programming in assembler where I would use shifts and
years spent programming in high level languages where I would not.
>
otherwise:
I always used shifts, never thought much of it.
I use shifts where I think shifts, I had never thought to think divides...
if I were thinking of a divide, than i/3 is an obvious difference from i/2.
if I was not, it is not.
it is a non-obvious jump from 'i>>1' to 'i/3', unless one first thinks that
'i>>1' is actually 'i/2'...
>actually, had I been thinking of compiler behavior much at all, I would
>have realized that 'i/3' actually becomes a fixed point multiply by a
>reciprocal. no such reasoning was used in this case.
>>
>this was a trivial and obvious mistake is all.
>have realized that 'i/3' actually becomes a fixed point multiply by a
>reciprocal. no such reasoning was used in this case.
>>
>this was a trivial and obvious mistake is all.
A trivial mistake that does not get made if you code what you want to
express instead of trying to use tricks. That is part of the point.
>
this implies certain things, ie, that what I would want to express is
different from the code I would write to express it.
do you ask me, if my grammar is unusual, if it is because I am not writing
what I am meaning to express?...
it is a similar question IMO...
Whatever the reason for you learning to use such tricks it is well past
time you learned not to use them excpet where it is proved that you need
to.
>
time you learned not to use them excpet where it is proved that you need
to.
>
shifts are a basic operator, I don't see why they would be viewed as any
kind of trick...
do we call pointers and casts tricks as well?... typical code is riddled
with the things, nothing sinister there...
now, does one think in terms of arithmetic ops or in terms of bitwise
ops?...
does one do their everyday arithmetic (internally) in decimal or in hex?...
if we read something do we see the text, hear words, or see imagery?...
this kind of issue has not come up in any time in recent memory...
so, one thinks in hex and writes in decimal, or vice versa, not usually that
important.
and, if one happens to be thinking in hex right, then a shift is more
intuitive than a divide.
does one think of the money in their wallet as 300 or 0x12C?...
does one think in british or metric units?...
or does one use whatever system happens to seem more natural at that
instant?...
up to them really. it only matters that when someone asks that they give the
right number, and when they read that they don't get confused...
one typically doesn't know the magic going on even in ones' own head...
>>
>4/3 is a natural growth curve. something around this ratio should
>presumably work good as a general mean case.
>4/3 is a natural growth curve. something around this ratio should
>presumably work good as a general mean case.
Exponential is also a natural growth curve, if you don't believe me check
how populations grow in nature, for at least some it is exponential until
a crash.
>
The best growth curve depends on the situation. For some thing I know that
in the foreseeable future I need space for 10 foos and if it grows beyond
that it will be unlikely to be by much, so I start with 10 and use a small
linear growth (saves having to revisit the code unless something very
strange happens). For other things that would be completely stupid.
in the foreseeable future I need space for 10 foos and if it grows beyond
that it will be unlikely to be by much, so I start with 10 and use a small
linear growth (saves having to revisit the code unless something very
strange happens). For other things that would be completely stupid.
--
Flash Gordon
Flash Gordon
Comment