[fpc-devel] Multiple variable initialization
Ozz Nixon
ozznixon at gmail.com
Sat Mar 24 16:15:28 CET 2018
Actually (for clarity) JavaScript does allow multi-initialization, however,
does not require type:
var a=0,b=0,c=0; // all are zero
// and if your presetting to zero due to Pascal not pre-initializing
variables, javascript does, so:
var a,b,c; // all are zero
var a=b=c=1; // C and most JavaScript engines all three are 1
var a,b,c=2; // in certain JavaScript engines only initializes C ==2, a and
b are zero.
some Pascal Dialets do support
var a:=b:=c:=3; // all are 3
Ozz
On Sat, Mar 24, 2018 at 10:59 AM Mattias Gaertner <nc-gaertnma at netcologne.de>
wrote:
> On Sat, 24 Mar 2018 15:41:15 +0100 (CET)
> Michael Van Canneyt <michael at freepascal.org> wrote:
>
> > On Sat, 24 Mar 2018, Ondrej Pokorny wrote:
> >
> > > Is there a reason why multiple variable initialization is forbidden?
> > >
> > > program Test;
> > > var
> > > A: Integer = 0; // allowed
> > > B, C: Integer = 0; // not allowed
> >
> > I think this is confusing to read.
> > Are B and C both initialized, or only B ?
>
> The "integer" is applied to both. It would be inconsistent to apply the
> =0 only to C.
>
>
> > Javascript also does not allow this, I think, and for once with good
> reason.
>
> Since when is JS a role model for Pascal?
>
> Mattias
> _______________________________________________
> 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/20180324/43782339/attachment.html>
More information about the fpc-devel
mailing list