Re: [fpc-pascal] Streaming classes?

2009-10-22 Thread leledumbo

> I have no clue what its used for or why I would want to use it

You can save the "state" of your program and restore it later, particularly
useful for games. AFAIK, it's one of the best way to implement "save" in
games.
-- 
View this message in context: 
http://www.nabble.com/Streaming-classes--tp25959847p26008325.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] array [boolean] and typecasting fail

2009-10-22 Thread David Emerson
It appears that, in a special case here, the boolean typecast is not 
being done properly/completely, and thus an array is being indexed out 
of bounds. If I compile with rangechecking, I get a rangecheck error; 
without, I get garbage and an EAccessError exception! (trash and crash)

uses math;

type
  rounding_func = function (x : extended) : longint;

const
  t_or_f : array [boolean] of string = ('false', 'true');
  ceil_or_floor : array [boolean] of rounding_func = (@floor, @ceil);

var
  b : boolean;

begin
  b := boolean (6 and 4);
  writeln (t_or_f [b]);
  writeln (ceil_or_floor [b] (2.5));
end.

I was previously using boolean (6 and 4) as the array index directly, 
but I thought the example was easier to read this way, and it still 
crashes for me. Using fpc 2.2.4-3 and (mostly) debian 5.0.3 stable

This smells like a bug to me.

Cheers,
David.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal