[fpc-pascal] Better usage of "with"

Ryan Joseph ryan at thealchemistguild.com
Thu Jun 14 11:58:44 CEST 2018



> On Jun 14, 2018, at 4:44 PM, Ryan Joseph <ryan at thealchemistguild.com> wrote:
> 
> Something I tried was using properties like this but it didn’t work. Is that something properties could do? It feels like they should be able to reach into records fields that since everything is known to the property as time of declaration.
> 
> property Position: TVec2D read entity^.position;

I just did a test and found out property does indeed access record fields (that’s great to know) but when I made it a pointer that’s when it broke. Why not make properties do this?

type
	TEntity = record
		position: TVec2;
	end;
	TEntityPtr = ^TEntity;

type
	TDoor = record
		entity: TEntityPtr;
		state: boolean;
		property position: TVec2 read entity^.position;
	end;


Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list