Re: [fpc-devel] Compile time functions

2018-07-28 Thread Thorsten Engler
type TMyClass = class of TMyObject; TMyObject = class procedure InstanceMethod; //Self = TMyObject, can be virtual class procedure ClassMethod; //Self = TMyClass, can be virtual class procedure StaticClassMethod; static; //no Self, really just a global procedure in a scoped na

Re: [fpc-devel] Compile time functions

2018-07-28 Thread J. Gareth Moreton
Aah, right.  Class methods I have used in past projects, but my understanding is that, in these instances, Self can still be accessed, but represents the class rather than the object, can be called without an instantiated object, and still have the issues that they can be virtual and overridden (s

Re: [fpc-devel] Compile time functions

2018-07-28 Thread Dmitry Boyarintsev
These are known as “class” methods (rather than “static”) in object pascal. Thanks, Dmitry On Saturday, July 28, 2018, J. Gareth Moreton wrote: > Aah, right. > > I'm probably being rather dumb here from not having used them before, but > do you mean things like this? > > type > TNewClass = cl

Re: [fpc-devel] Compile time functions

2018-07-28 Thread J. Gareth Moreton
Aah, right. I'm probably being rather dumb here from not having used them before, but do you mean things like this? type   TNewClass = class    function Special: Boolean; static; end; I gather you can't access Self in such methods. Gareth aka. Kit On Sat 28/07/18 20:37 , "Sven Barth" pa

Re: [fpc-devel] Adapting MakeFile to make subfolders for targets with sub architectures

2018-07-28 Thread Christo
On Thu, 2018-07-26 at 22:19 +0200, Florian Klämpfl wrote: > Well, I got also stuck on the fpmake problem :( Yes, it appears to me that fpmkunit lack support for subarch & ABI at the moment, else it would have been easy to modify TPackage.GetUnitsOutputDir in a similar way. __

Re: [fpc-devel] Compile time functions

2018-07-28 Thread Sven Barth via fpc-devel
J. Gareth Moreton schrieb am Sa., 28. Juli 2018, 19:34: > I did wonder about that, but wasn't sure how it would affect things where > inheritance is concerned. I dare ask, do you have an example of a class > method that you would consider pure? > They don't have inheritance. If they have the mo

Re: [fpc-devel] Compile time functions

2018-07-28 Thread J. Gareth Moreton
I did wonder about that, but wasn't sure how it would affect things where inheritance is concerned.  I dare ask, do you have an example of a class method that you would consider pure? And yes, object methods can't be pure because accessing the fields of the current object (Self) is internally de

Re: [fpc-devel] Compile time functions

2018-07-28 Thread Sven Barth via fpc-devel
J. Gareth Moreton schrieb am Sa., 28. Juli 2018, 18:49: > Another little progress update with implementing pure functions. > > 1. In my code (not submitted yet), the compiler now recognises and accepts > the 'pure' directive. There are a number of other directives that it can't > be used with ('

Re: [fpc-devel] Compile time functions

2018-07-28 Thread J. Gareth Moreton
Another little progress update with implementing pure functions. 1. In my code (not submitted yet), the compiler now recognises and accepts the 'pure' directive.  There are a number of other directives that it can't be used with ('noreturn' being one of them) and it can't be used on object method

Re: [fpc-devel] Typed constants question

2018-07-28 Thread J. Gareth Moreton
Given I want to be conservative with pure functions so it's near-impossible to write something that breaks the compiler or cause unexpected behaviour in the compiled binary, I'll treat the accessing of such a constant as "impure" for reasons of safety.  My work-in-progress already detects accessin

Re: [fpc-devel] Typed constants question

2018-07-28 Thread Marco van de Voort
In our previous episode, J. Gareth Moreton said: > For a more fundamental question... why are typed and untyped constants > treated differently? Turbo Pascal allowed to write them, depending on a switch. $J. Delphi adds {$writeableconst on} iirc. But even when this is off, you can't be sure it

[fpc-devel] Typed constants question

2018-07-28 Thread J. Gareth Moreton
So I have a question about constants. While programming pure functions, I noticed that typed and untyped constants are treated differently.  Something like "const Pi = 3.14159", even if declared outside of the current function, is propagated directly in expressions - the node construction shows