[fpc-pascal] Re: Why this evaluates on "if" wrong ?

L L at z505.com
Mon Oct 29 17:06:35 CET 2007

> >
> > The end user is using a high level language and should not care whether the
> > computer is digital or analog.
> Unfortunately, there is a problem.  One can try to hide it (as calculators
> attempt to do), but in the longer run that is going to be unsuccessful
> and even dangerous.

Same as ansistring.. it can be dangerous to hide all the intricate details of a
pchar/bytearray, which is what ansistring does. But ansistrings are really
useful for 'every day' use.

It took about 30 years for someone to finally invent the ansistring because all
those other people thought that something like an ansistring would be too
slow/dangerous on the current hardware available. And maybe back then it was. So
we used Pchar and 255string and it limited our thinking back then (and I wasn't
born back then in the 70's so I shouldn't talk, but I've looked over history and
can see patterns).

Eventually, people realize that programming languages should be 'easy to use' by
default, and learn that you should be able to escape this 'easy to use' system
by using other types or turning off switches (i.e. range checking, {$H+} etc.).
So my point is.. I hope we have solutions.. and we do.. currency and others.
Currency just seems to be kind of hack compared to something more like a TCasio
would be.. We should have something like that. Most people that use programming
languages are using them as general purpose tools... and if they want to do
engineering then they can pull in the engineering library in their uses clause.
But by default, we should have TCasio available. Currency seems to be close..
but maybe not close enough to a casio calculator. Plus, it's called currency..
which is dedicated for currency, not calculating every day math (patches
welcome, yes yes I know).

My point mainly was that we have high level types like ansistrings, so why not
have good decimal type that acts just like a calculator. Could be called
'TCasio'. Don't call it that, I'm kidding on the type name.

Lately during parsing I've had to defeat the compiler by using uniquestring and
setlength.. but ansistrings are still worth it because in general this is what
people need to be doing.. adding/concatenating strings of unknown final lengths

I assume in general, pascal is used for every day programming.. not scientic
computing. I assume that most people would want to do every day math like on a
Casio calculator.. and only some people would want to do engineering.. so those
folks can pull in the engineering units when they need to.

> The mathematical structures of floating point numbers and of real numbers
> do not match, and cannot be made to match faithfully.
> See e.g. any good textbook on numerical mathematics.  However, most
> of those texts are not so accessible to the layman.  I have written
> a short article on it for secondary educations, that I hope is more
> accessible:
> Gyula Horvath, Tom Verhoeff.
> ``Numerical Difficulties in Pre-University Informatics Education
>   and Competitions'',
> Informatics in Education, Vol. 2, Number 1, pp.21-38.
> <http://www.win.tue.nl/~wstomv/publications/INFE012-final.pdf>
> URL checked OK

I will download and read, thanks.

> (Sidenote: If your program only needs to deal with decimal fractions,
> then it is stronly advised not to use Real/Single/Double, but e.g. Currency.
> Floating-point numbers are useful in scientific and engineering applications.)

Absolutely agree and was the point I was trying to make.. there are some times
when you just want a computer to concatenate strings.. and there are times when
you really want the computer to act like  regular old calculator. So we
shouldn't limit our thinking to 255 strings and shouldn't limit our thinking to
floats/extended/double. We should have floats/extended/double available and 255
strings available for when we need them.. but maybe we should also have a TCasio
and Currency available too.

Mainly, it seems now my point is that we have a 'currency' type that maybe isn't
the best we could have.. and quite possibly we are limiting our thinking around
this currency type and these float types. Remember back when 255 string was 'the
thing' to use.. and no one would possibly think of an ansistring since it didn't
exist at the time and couldn't POSSIBLY be useful to use since 255 was enough..
or that pchars were enough when 255strings weren't fit?

Just being devils advocate as always.. trying to encourage creative thought and


More information about the fpc-pascal mailing list