[fpc-pascal] Record operator for assignment

Ryan Joseph ryan at thealchemistguild.com
Thu May 4 10:06:24 CEST 2017


> On Apr 28, 2017, at 3:51 PM, Ryan Joseph <ryan at thealchemistguild.com> 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 people get into this any ways? The learning curve is so steep it’s a miracle anyone is able to contribute.

I was looking at a Swift language guide (Apple’s new language) and they have this exact same syntax for initializing structs (like a default constructor that Pascal is missing).

From their guide “vga" is a struct with 2 fields: width and height. Swift uses labels in functions (like Objective-C) but the end result is that it looks identical to the Pascal syntax for defining constant records.

======

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 initializer by name:

var vga = Resolution(width: 640, height: 480)

Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list