[futurebasic] Re: [FB] NSLog as method caller

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 2017 : Group Archive : Group : All Groups

From: Bernie <bernie.fblist@...>
Date: Thu, 27 Apr 2017 10:47:16 +0100
Steve wrote:

> It's news to me that NSLog is capable of making method calls, 

Strictly speaking, NSLog isn’t actually capable of making method calls. It’s just a function, like any other, that can accept the returned value (directly) from another function or method.

> ...and I'm not sure that it's a good idea.

I’m sure, when designing these programming languages, someone has already weighed up the pros and cons of nested methods/functions. We have to design our apps around the rules, and if that means storing the returned value in a variable for later use, then we just do it.

You and I use something like this all the time without ever thinking about it.
// ---------------
[[MyObject alloc] init];

And do similar in good ol’ FB
// ---------------
local fn NextWindowNum as long
dim as long wndNum
wndNum = 1
while ( window(-wndNum) )
end fn = wndNum

local fn BuildWindow( wndNum as long ) as WindowRef
dim as WindowRef w
appearance window wndNum,,(0,0)-(480,360),_kDocumentWindowClass
get window 1, @w
end fn = w

fn SetWindowTitleWithCFString( fn BuildWindow( fn NextWindowNum() ), @"My Window" )