[fpc-pascal] Nice const array messages. Thanks!

Anthony Walter sysrpl at gmail.com
Sat Feb 13 00:39:20 CET 2016


I just noticed this really nice compiler feature. I don't know when it as
added but it's really helpful.

When defining const array like below the compiler will tell you how many
elements are missing:

const
  Food: array[0..7] of string = (
    'Apple', 'Banana', 'Cherry', 'Doughnut', 'Eclair');

Error: Expected another 3 array elements

And when you have too few elements in the array in it will make tell you
the point where it expected the array to end.

const
  Food: array[0..2] of string = (
    'Apple', 'Banana', 'Cherry',| 'Doughnut', 'Eclair');

Fatal: Syntax error, ")" expected but "," found,

And in Lazarus the caret is placed where the array should have ended "|".

This is really great feature and helps a lot when declaring array constants
with many items. Thank you to whomever added this to the compiler :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20160212/5dfe9eb4/attachment.html>


More information about the fpc-pascal mailing list