I'm getting there. I keep getting distracted or lost though! Hardware failures don't help!
I'm trying a different approach this time and writing a whitepaper like I've done with my more major changes for Free Pascal, so I can describe its uses and how it works etc. It can be updated of course, but it means I have something to refer to if I lose my way, and others can better add to the concept.
In the case of that PrintColor example, I don't think it could be inlined, for example, due to the call to IntToStr, among other things (like if you call PrintColor with a non-constant actual parameter), but if IntToStr were a pure function as well (and there's no reason why it can't), then logically GenerateColorCode could easily be pure.
I'm glad there's still interest in pure functions. It may be a while though, and I'm being tempted with a bounty and Patreon pledges to implement "static single assignment" into the Free Pascal Compiler. That will take some research to see if it's even possible and not prone to completely breaking things!
First things first though, I've got a bug to fix in AArch64, and on the same platform, I'm almost finshed implementing the optimisation that turns division by a constant into a multiplication and shift.
Gareth aka. Kit
Ryan Joseph wrote 13 lines
> On Nov 22, 2020, at 10:09 AM, J. Gareth Moreton via fpc-devel wrote:
>
> Personally I'd write the function as something like "function GenerateColorCode(codes: array of Byte): ansistring;", mostly in anticipation of pure functions, because then the compiler can just replace the call with the relevant string at compile time, but that's a long way off!
That would great. Hopefully this gets finished some day.
Regards,
Ryan Joseph
_______________________________________________
fpc-devel maillist -
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel