Thanks everyone! I'm still learning some parts of Pascal! I'll see if I
can accommodate for that.
Gareth aka. Kit
On Sun 29/07/18 08:14 , Sven Barth via fpc-devel
fpc-devel@lists.freepascal.org sent:
Thorsten Engler schrieb am So., 29. Juli 2018, 04:40:
type
TMyClass = class of TMyObje
Thorsten Engler schrieb am So., 29. Juli 2018,
04:40:
> type
>
> TMyClass = class of TMyObject;
>
> TMyObject = class
>
> procedure InstanceMethod; //Self = TMyObject, can be virtual
>
> class procedure ClassMethod; //Self = TMyClass, can be virtual
>
> class procedure StaticClass
variable type
end;
From: fpc-devel On Behalf Of J. Gareth
Moreton
Sent: Sunday, 29 July 2018 07:22
To: FPC developers' list
Subject: Re: [fpc-devel] Compile time functions
Aah, right. Class methods I have used in past projects, but my understanding
is that, in these instances, Self can
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
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
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
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
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
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 ('
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
On Sun 22/07/18 14:57 , Martok
list...@martoks-place.de sent:
> Am 22.07.2018 um 06:03 schrieb J. Gareth
Moreton:
>
> > Pure functions cannot be
>
> > evaluated at compile time if one of
the
> arguments is a variable (or at the very
> > least, not deterministic)
>
> Do you have an idea how to
Am 22.07.2018 um 06:03 schrieb J. Gareth Moreton:
> Pure functions cannot be
> evaluated at compile time if one of the arguments is a variable (or at the
> very
> least, not deterministic)
Do you have an idea how to prove that yet? The way I see it now, this is the
only hard issue, every other com
To follow up on this, even if you rewrote the function to use a
multiplicative formula (faster to compute overall):
function Binomial(n, r: Cardinal): Cardinal; pure;var c: Cardinal;
begin
for (r > n) then
Result := 0
else
begin
Result := 1;
if n r then
Sorry for that mess of a formatting on the code sample, Here is a much
nicer version!
function Binomial(n, r: Cardinal): Cardinal; pure;begin
if (r > n) then
Result := 0
else if (r = n) then
Result := 1 { Faster than calculating the factorials }
else
Result := Factorial(n)
An interesting read. If you can collapse an inline function into a single
assignment in most situations, then brilliant! Definitely keep that
optimisation in.
While there are many similarities and prerequisites between an inline function
and a pure function, and many simple mathematical functions
Martok schrieb am Sa., 21. Juli 2018, 17:12:
> Am 21.07.2018 um 02:08 schrieb Sven Barth via fpc-devel:
> > The main problem is that not all functions that would be eligible for
> your
> > approach are also declared as inline thus their node trees would not be
> stored
> > inside the PPU and thus
Am 21.07.2018 um 02:08 schrieb Sven Barth via fpc-devel:
> The main problem is that not all functions that would be eligible for your
> approach are also declared as inline thus their node trees would not be stored
> inside the PPU and thus you could not work with them.
I'm not sure I understand. I
On Fri, Jul 20, 2018 at 7:08 PM, Sven Barth via fpc-devel
wrote:
> Martok schrieb am Fr., 20. Juli 2018, 23:20:
>>
>>
>> What do you think?
>
>
> The main problem is that not all functions that would be eligible for your
> approach are also declared as inline thus their node trees would not be
>
Martok schrieb am Fr., 20. Juli 2018, 23:20:
>
> What do you think?
>
The main problem is that not all functions that would be eligible for your
approach are also declared as inline thus their node trees would not be
stored inside the PPU and thus you could not work with them.
Additional benefit
Hi all,
inspired by Kit's concept for pure functions, I had a deeper look at what inline
functions (and more importantly, the nodes involved in expanding them) can do.
Let me share my proof-of-concept (which may very well become a
'poof-of-concept'...). You can find my current working branch here
20 matches
Mail list logo