Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2010-01

Why limit string constant to 255?

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jichao Yang

Hi all,I have one question about the free pascal programming language: why limit string constant to 255?

write('a x 256');
would produce 'Error: Constant string can't be longer than 255 chars',with fpc 2.4.0 default/objfpc/delphi/tp model. But gnu pascal would compile this well.

On the other side,I see no meaning to limit constant string to 255 chars.Sometimes,I would need to construct some constant string longer than 255 chars,then I could only use the '+' operator,but it seems rather silly and inconvenient. (is there any other way to do this?please feel free to correct me).And there should be no compatibility problem with
the legacy code:they should compile well.

So why the limit?

regards.
jcyangzh.

Jonas Maebe
to Jichao Yang
Jichao Yang wrote
I have one question about the free pascal programming language: why limit string constant to 255?

It's an implementation limit of the scanner (which uses shortstrings for speed reasons).

Jonas