[fpc-devel] Multiple variable initialization
Ozz Nixon
ozznixon at gmail.com
Sun Mar 25 21:47:43 CEST 2018
Pre pre-initialization, I do it as a compile option:
Modern Pascal v2.0.0 (LINUX,CPU64,X86_64,LITTLEENDIAN,1180323)
Copyright (c) 2000..2017 by Ozz Nixon (Modern Pascal
Solutions, LLC).
■ Produces Cross-Platform 32bit/64bit Encrypted Binaries.
/usr/bin/mp2 [options] sourcefile [modifiers]
options:
-2 286 instructions -3 386 instructions
-6 64bit instructions -o objfpc compatible
-g compile to binary -t syntax check only
-p[0|1|2] Pack EXE -r<path> Resource dirs
-v version display -q syntax & method check
-? this screen -h history log
modifiers: (all are on by default)
-a- $A- Assert Support Off -m- $M- Auto-Initialization Off
-b- $B- Boolean Short Circuit Off -o- $O- Overflow Checking Off
-c- $C- New C Operators Off -p- $P- Auto-Properties Off
-d- $D- Full Disposal Off -r- $R- Range Protection Off
-f- $F- Autoinvoke Functions Off -s- $S- Enums Scoped Off
-h- $H- Hint of unused variables Off -x- $X- Extended Syntax Off
-j- $J- Constant Address Off -z- $Z- Case supports CONTINUE
Off
-l- $L- Lazy Semicolon Off
All numeric values are 0, 0.0, Booleans 0 aka False, Strings = '' (blank),
PChar and Pointers = Nil. * Now my product is to accent FPC not replace it
in anyway. I use a separate code base, and use FPC to compile my compiler.
My binaries are like .java or .Net managed binaries. I only have just over
1,000 end-users and we try to stick 100% compatible to Turbo Pascal 7, but
support Delphi-isms and FPC-isms. It only takes a couple extra lines in asm
to $M+ in my compiler (It has saved many customers who just assumed, I said
"var a:longint" then a:=a+some_value (actually true PascalDevs never do
that, it is my migrated clients who seem to insist on a+=some_value and
then wonder why a!=some_value). So, I made MPC default to $M+.
For FPC, I would default to true Pascal, A is an address, you get whats
there unless you initialize it, and most code I see, except for loops, A is
never being assigned 0 its is always being assigned a value from
input_source. So save the few uSec and don't pre-init.
My 2 cents from the script world...
O.
On Sun, Mar 25, 2018 at 2:38 AM Alexander Grotewohl <alex at dcclost.com>
wrote:
> It sounds more like you're making a case for all integers to be
> initialized to zero by default. I still fail to see any practical uses
> other than wanting to not type "integer" twice.
>
> Alex
>
>
> On 03/24/2018 11:20 AM, Ondrej Pokorny wrote:
> > On 24.03.2018 15:46, Alexander Grotewohl wrote:
> >> The patch is to put them on separate lines. Preferably with
> >> meaningful comments for each. If FPC was changed at the whim of every
> >> programmer we'd end up with a huge mess that no longer resembles pascal.
> >
> > Please tell me who decides about the borderline between whim and
> > usefulness.
> >
> > E.g. FPC supports initializing local variables, which Delphi and (if I
> > am not mistaken) ISO Pascal don't support:
> >
> > procedure Test;
> > var
> > A: Integer = 0;
> > begin
> > end;
> >
> > Is it a whim as well? If FPC has this extension, why not to support
> >
> > procedure Test;
> > var
> > A, B: Integer = 0;
> > begin
> > end;
> >
> > ?
> >
> > Ondrej
> > _______________________________________________
> > fpc-devel maillist - fpc-devel at lists.freepascal.org
> > http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>
> _______________________________________________
> fpc-devel maillist - fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20180325/0dce89e7/attachment.html>
More information about the fpc-devel
mailing list