SRL Archive - FAQ

Is this supposed to be able to compile?


rj

2014-03-16 22:21:39

Don't ask how I got to this point. All I know is that this compiles:

function lol():function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:function:boolean;
begin
end;

begin

end.

Clarity

2014-03-16 22:40:03

A function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a function that results in a boolean?

Sure I guess.

(I don't know if that's what it actually means)

Brandon

2014-03-16 22:43:20

From: Clarity
A function that results..
Sure I guess.

(I don't know if that's what it actually means)




function foo: boolean;
begin
writeln('Here');
end;

function lol():function:function:function:function:boolean;
begin
Result := @(Foo);
end;

var
T: function: Boolean;
begin
T := lol();
T();
end.


Is equivalent to:


function foo: boolean;
begin
writeln('Here');
end;

function lol():function:boolean;
begin
Result := @(Foo);
end;

var
T: function: Boolean;
begin
T := lol();
T();
end.

Both return a pointer to a function with no extra indirections..


Think that's weird? Check out:


function foo(I: Integer): boolean;
begin
writeln(I);
end;

begin
foo()()()()()()(3);
end.

or


Function Bleh: Boolean;
begin
writeln('Bleh');
end;

Function meh(H, W: String): Function:Boolean;
begin
writeln(H, W);
Result := @(Bleh);
end;

function foo(I: Integer; S: Single): Function(H, W: String): Function:Boolean;
begin
writeln(I);
writeln(S);
Result := @(Meh);
end;

begin
foo(3, 5)()()('Hello', ' World')()()()()()()()();
foo(3, 5)('Hello', ' World')();
end.

for semi-obfuscation and chain calling..

Clarity

2014-03-16 22:53:35

Heh, I figured I was off. Interesting though, thanks for clarifying.

Brotein

2014-03-17 01:42:41

From: Clarity
Heh, I figured I was off. Interesting though, thanks for clarifying.


Get it?

rj

2014-03-17 06:25:21

From: Brandon
…



Nice, nice didn't even know I could return a function of a function

NKN

2014-03-17 08:51:25

This thread has been a roller coaster ride the entire time.