[fpc-pascal] Underscores in numerical literals - grouping

Stephen Chrzanowski pontiac76 at gmail.com
Mon Nov 21 16:52:43 CET 2016


I like the concept, but, if I'm using a constant that goes beyond the
millions, I'd add a comment to what the number is in US format, and tag on
what exactly it means, or make the variable name itself mean something.
Because reading

const maxLongint = $7fffffff;

or

const maxLongint = 2147483647;

is a bit of a pain, I agree.

That said, underscores aren't what I'd use.

I love the idea of the IDE (ANY IDE, not just Pascal based) doing some kind
of code highlight for large numbers.  Something simple, like underlining
every other group of 3 in large numbers, or every other hex pair, or every
8 binary set.

As for the mono-spaced, no, not ridiculous.   If memory serves me correct,
I believe you're as old-school as I am when it comes to code (My teeth cut
on Vic-20), but I've always preferred mono-spaced fonts in my IDE versus
variable width, JUST on the primary basis of legibility of the code itself,
ignoring the 'gravy' of lining up text within the code.  I always
terminal/system/consolas, even in Notepad/PSPad.  I barely tolerate
variable width font in GMail as I can't change the font easily (But you've
sparked an idea >:]  ).  Figuring out if I'm using a capital I versus a
lower l versus a | is quite annoying (Capital EYE versus lower ELL versus
pipe).  Most of the apps I write (for myself) are list based, or require
special formatting are typically fixed width as aligning text is much
easier, and I don't have to code special considerations for W and 1 width
differences.  Forget about the form UI, but even lining up variable
declarations and definitions, procedure, function declarations within
classes, much easier with fixed width.


On Mon, Nov 21, 2016 at 9:46 AM, Graeme Geldenhuys <
mailinglists at geldenhuys.co.uk> wrote:

> I don't know about you, but I like this idea implemented in Java 7 and
> later.
>
> http://jasdhir.blogspot.co.uk/2016/11/using-underscores-in-literals.html
>
>
> I always find it hard to read long numeric literals.
>
>
> Alternatively, without needing compiler changes, the IDE's and
> programmer editors should become more clever in how they display source
> code (think Elastic Tabstops), and automatically display numeric
> literals with slight increase in [render] spacing between certain number
> groups. Binary literals could be grouped every eight digits, whereas Hex
> could be grouped every 4 and Decimals every 3 digits. The age old rule
> of programmer source code always being in a mono-spaced font is
> ridiculous for this day and age.
>
> Regards,
>   Graeme
>
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20161121/ac9191fb/attachment.html>


More information about the fpc-pascal mailing list