Re: [fpc-pascal] Record operator for assignment

2017-05-08 Thread Jürgen Hestermann
Am 2017-05-08 um 05:47 schrieb nore...@z505.com: > It's similar to this feature: > x,y,z := 1, 12, 7 > It's neat to be able to assign multiple variables on a single line. But necessary? mandatory? It's not even neat. It would bloat the Pascal language unneccesarily (as many other additions have

Re: [fpc-pascal] Record operator for assignment

2017-05-07 Thread Ryan Joseph
> On May 8, 2017, at 10:47 AM, nore...@z505.com wrote: > > It's always easier said than done, to say "Why can't" and then have to write > the actual parser code to do it ;-) Yes indeed. I just looked over svn to see where Sven added his new dynamic array initializers and I’m still totally conf

Re: [fpc-pascal] Record operator for assignment

2017-05-07 Thread noreply
On 2017-04-28 01:01, Ryan Joseph wrote: On Apr 28, 2017, at 12:43 PM, Sven Barth via fpc-pascal wrote: It would introduce an ambiguity as "(x" could also complete to other expressions (e.g. "(x + y) * 2" or even merely "(x)"). Especially older Pascal compilers were geared towards the simplic

Re: [fpc-pascal] Record operator for assignment

2017-05-04 Thread Ryan Joseph
> On May 4, 2017, at 4:27 PM, Marco van de Voort wrote: > > Scripting languages often already by default initialize a datatructure, and > then such language constructs only performs additional initialization. > > Pascal and similar lowlevel languages don't by default initialize them, and > the

Re: [fpc-pascal] Record operator for assignment

2017-05-04 Thread Sven Barth via fpc-pascal
Am 04.05.2017 10:37 schrieb "Ryan Joseph" : > > > > On Apr 28, 2017, at 3:51 PM, Ryan Joseph wrote: > > > > I almost struck out there. ;) There’s at least a possibility for anyone interested. A few years ago I looked at the compiler source and decided it was beyond me to even understand the code b

Re: [fpc-pascal] Record operator for assignment

2017-05-04 Thread Marco van de Voort
In our previous episode, Ryan Joseph said: > All structures have an automatically-generated memberwise initializer, which > you can use to initialize the member properties of new structure instances. > Initial values for the properties of the new instance can be passed to the > memberwise initia

Re: [fpc-pascal] Record operator for assignment

2017-05-04 Thread Ryan Joseph
> On Apr 28, 2017, at 3:51 PM, Ryan Joseph wrote: > > I almost struck out there. ;) There’s at least a possibility for anyone > interested. A few years ago I looked at the compiler source and decided it > was beyond me to even understand the code base well enough to do anything. > How do peop

Re: [fpc-pascal] Record operator for assignment

2017-04-28 Thread Sven Barth via fpc-pascal
Am 28.04.2017 14:09 schrieb "Mark Morgan Lloyd" < markmll.fpc-pas...@telemetry.co.uk>: > Is there any way that the length of an array being used for that sort of job can be defined by what's put into it, rather than having to be predefined? No, there is not. Though I already had the idea that such

Re: [fpc-pascal] Record operator for assignment

2017-04-28 Thread Mark Morgan Lloyd
On 28/04/17 04:30, Ryan Joseph wrote: Instead of making constructors and doing busy work It would be nice if Free Pascal could let you assign records outside of type blocks like: rec := (x: 0; y: 0; z: 0); Why isn’t this possible btw? I saw some C++ code do this and it seems like an obvious sol

Re: [fpc-pascal] Record operator for assignment

2017-04-28 Thread Sven Barth via fpc-pascal
Am 28.04.2017 09:23 schrieb "Ryan Joseph" : > > > > On Apr 28, 2017, at 1:06 PM, Sven Barth via fpc-pascal < fpc-pascal@lists.freepascal.org> wrote: > > > > No, I mean > > > > rec := (x + y) * 2; > > > > The compiler has to differentiate these two. > > I see. It’s the parenthesis that are problemat

Re: [fpc-pascal] Record operator for assignment

2017-04-28 Thread LacaK
I see. It’s the parenthesis that are problematic. I guess the solution would be curly brackets: rec := {x: 1; y: 2; z: 1} or some magic function like writeln: rec := TMyRec(x: 1; y: 2; z: 1) rec := @(x: 1; y: 2; z: 1) etc… or use like dynamic array constructor: (MyArr := TMyDynArrType.Cre

Re: [fpc-pascal] Record operator for assignment

2017-04-28 Thread Ryan Joseph
> On Apr 28, 2017, at 1:06 PM, Sven Barth via fpc-pascal > wrote: > > No, I mean > > rec := (x + y) * 2; > > The compiler has to differentiate these two. I see. It’s the parenthesis that are problematic. I guess the solution would be curly brackets: rec := {x: 1; y: 2; z: 1} or some magic

Re: [fpc-pascal] Record operator for assignment

2017-04-27 Thread Sven Barth via fpc-pascal
On 28.04.2017 08:01, Ryan Joseph wrote: > >> On Apr 28, 2017, at 12:43 PM, Sven Barth via fpc-pascal >> wrote: >> >> It would introduce an ambiguity as "(x" could also complete to other >> expressions (e.g. "(x + y) * 2" or even merely "(x)"). Especially older >> Pascal compilers were geared t

Re: [fpc-pascal] Record operator for assignment

2017-04-27 Thread Ryan Joseph
> On Apr 28, 2017, at 12:43 PM, Sven Barth via fpc-pascal > wrote: > > It would introduce an ambiguity as "(x" could also complete to other > expressions (e.g. "(x + y) * 2" or even merely "(x)"). Especially older > Pascal compilers were geared towards the simplicity of the language and thus

Re: [fpc-pascal] Record operator for assignment

2017-04-27 Thread Sven Barth via fpc-pascal
Am 28.04.2017 06:06 schrieb "Ryan Joseph" : > > Instead of making constructors and doing busy work It would be nice if Free Pascal could let you assign records outside of type blocks like: > > rec := (x: 0; y: 0; z: 0); > > Why isn’t this possible btw? I saw some C++ code do this and it seems like

Re: [fpc-pascal] Record operator for assignment

2017-04-27 Thread Ryan Joseph
> On Apr 28, 2017, at 12:21 PM, LacaK wrote: > > you can workaround this by using typed constant for instance. Something like: > > const > DEFAULT_REC: TMyRec = (x: 0; y: 0; z: 0 ); > var > rec: TMyRec; > begin > rec := DEFAULT_REC; // or rec := Default(TMyRec) if you want zeroes > ... > >

Re: [fpc-pascal] Record operator for assignment

2017-04-27 Thread LacaK
Instead of making constructors and doing busy work It would be nice if Free Pascal could let you assign records outside of type blocks like: rec := (x: 0; y: 0; z: 0); you can workaround this by using typed constant for instance. Something like: const DEFAULT_REC: TMyRec = (x: 0; y: 0; z:

[fpc-pascal] Record operator for assignment

2017-04-27 Thread Ryan Joseph
Instead of making constructors and doing busy work It would be nice if Free Pascal could let you assign records outside of type blocks like: rec := (x: 0; y: 0; z: 0); Why isn’t this possible btw? I saw some C++ code do this and it seems like an obvious solution that should have existed 20 year