[fpc-devel] Multiple variable initialization

Ozz Nixon ozznixon at gmail.com
Sat Mar 24 19:04:07 CET 2018


As an extension, it makes sense - but I would make it a forced command line
switch and obscure $modeswitch. So the code can easily be ported to other
pascal compilers, or versions of FPC down the road. I spend 8 to 12 hours a
day porting Delphi (versions) of code to FPC. And the XE series really made
a mess of the language. I spend hours in FPC's core code, as I am making my
script engine compatible with FPC's code (to be the interpreter for FPC
source)...

I agree, especially from a script world, I would expect to see:
var a,b,c,d,e:String='';

as it looks like a script engines extension to:
const a,b,c,d:String='';

// and in Delphi $J+ aka {$WRITEABLECONST ON} making constant read/write -
you have basically produced what you are asking for. So, maybe FPC already
supports this?

* Now side note, you can define variable types in JavaScript (wrote my own
ECMA compliant script engine in 2000 (DXJavaScript) for Delphi):
var x = new Number(0);
var y = new String("Hello World!");

Of course, x and y are JavaScript objects at their core - so they can be
any type later in the code. But, JavaScript does support type definition in
the code. Number==Float==Integer.

Ozz


On Sat, Mar 24, 2018 at 1:13 PM Ondrej Pokorny <lazarus at kluug.net> wrote:

> On 24.03.2018 16:51, Florian Klaempfl wrote:
> > Am 24.03.2018 um 11:46 schrieb Ondrej Pokorny:
> >> Is there a reason why multiple variable initialization is forbidden?
> >>
> >> program Test;
> >> var
> >>    A: Integer = 0;    // allowed
> >>    B, C: Integer = 0; // not allowed
> >> begin
> >> end.
> >>
> >> Will a patch be applied that allows it?
> > As the first one is supported, I see no logical reason the second
> > shouldn't be supported, of course assigning 0 to B and C.
>
> Good to know there's somebody with the same point-of-view. Thanks :)
>
> Ondrej
> _______________________________________________
> 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/d53c0255/attachment.html>


More information about the fpc-devel mailing list