[fpc-pascal] Array assignment, and not-a-number
Jonas Maebe
jonas.maebe at elis.ugent.be
Mon Apr 15 18:00:21 CEST 2013
On 15 Apr 2013, at 16:48, Mark Morgan Lloyd wrote:
> I was having a bit of fun earlier while waiting for a call. Am I correct in believing that something like
>
> type t1= array of integer;
>
> var a1: t1;
> x: integer;
>
> a1 := [1,2,3,4,5];
>
> can't be done at present, irrespective of any custom definition of the := operator?
Maybe if you overload the assignment operator for "t2=set of byte" to "t1" assignments, but I'm not certain. It's definitely not something we explicitly support.
> Is there an accessible not-a-number constant, to allow me to do something like
>
> var reduce: double= NAN;
>
> x := reduce + a1;
>
> with an appropriate definition of the + operator without risk that an error would try to evaluate it as an ordinary arithmetic expression?
We don't have constant to identify a qNaN. I don't even know whether all architectures support them. Currently, the only way to achieve the above is by masking exceptions for invalid floating point operations: math.SetExceptionMask(math.GetExceptionMask + [exInvalidOp]).
You cannot overload/override operators that have a built-in meaning in the language (such as double+double).
Jonas
More information about the fpc-pascal
mailing list