From kfm-devel Sat Jul 28 13:29:41 2001 From: Harri Porten Date: Sat, 28 Jul 2001 13:29:41 +0000 To: kfm-devel Subject: Re: what's the return value of kjs-functions that appear to be void? X-MARC-Message: https://marc.info/?l=kfm-devel&m=99632701129597 On Sat, 28 Jul 2001, Tobias Anton wrote: > for the following patch, we're not sure about the result of the function: > > @@ -1074,8 +1074,9 @@ Completion WindowFunc::tryExecute(const > case Focus: > - result = Undefined(); > - // TODO > + if (widget) > + widget->setActiveWindow(); > + return Completion(Normal); > break; > > should it rather be Undefined()? > + result = Undefined(); > and later: > return Completion(ReturnValue, result); Yes. Assuming focus() doesn't return anything. > What's the difference in the meaning of: > Completion(Normal); > and: > Completion(ReturnValue, Undefined()); The first denotes leaving a function body without a return, break, continue or throw statement. The later should be used when you want to mimmick a simple return; (or return undefined;) statement. The completion type is checked after a statement is executed and can lead to e.g. abortion of execution or a different reaction on using a function as constructor via 'new'. The difference between a *undefined* ReturnValue completion or a Normal completion is not so big, though. > If the first is the Case, it would need to be changed in manymany places in > kjs_window and probably elsewhere. Where for example ? Note that completions are only used in ::execute() functions (tryExecute() here). get() and put() just return simple values or Undefined() if none. Harri.