method-signature

Why does the Objective-C compiler need to know method signatures?

拈花ヽ惹草 提交于 2020-01-14 13:12:42
问题 Why does the Objective-C compiler need to know at compile-time the signature of the methods that will be invoked on objects when it could defer that to runtime (i.e., dynamic binding)? For example, if I write [foo someMethod] , why it is necessary for the compiler to know the signature of someMethod ? 回答1: Because of calling conventions at a minimum (with ARC, there are more reasons, but calling conventions have always been a problem). You may have been told that [foo someMethod] is converted

calling COM method with Foo(…, [out] BSTR * value) from VBScript

时光怂恿深爱的人放手 提交于 2020-01-13 10:50:08
问题 Ist it possible to cal a COM method with the signature HRESULT Foo(BSTR in, [out] BSTR * out1, [out] BSTR * out2) from VBScript? The following: Dim a; Dim b; component.Foo "something", a, b gives an error about incompatible types. I still could change the signature of the method. 回答1: Looks like output parameters are not supported; while ByRef / [in, out] parameters are, but only on VARIANT parameters. From the following KB article: INFO: Type mismatch errors when you pass parameters from an

Delegates and ParamArray - Workaround Suggestions?

只谈情不闲聊 提交于 2019-12-30 18:35:08
问题 Some predefined methods contain a ParamArray in their signature. Delegates, however, cannot contain a ParamArray in their signature. Question: Assume you wish to create a delegation mechanism for a specific method which requires a ParamArray. How would you work around this constraint? EDIT: just to make clear, assume you cannot change the method signatures themselves (pre-defined methods, defined by some 3rd party, be it Microsoft or not). EDIT2: The real deal here is keeping the syntax sugar

Does a method's signature in Java include its return type?

谁说我不能喝 提交于 2019-12-27 10:36:29
问题 Does the method signature in a Java class/interface include its return type? Example: Does Java know the difference between those two methods: public class Foo { public int myMethod(int param) {} public char myMethod(int param) {} } Or is it maybe only the method name and parameters list that matter? 回答1: Quoting from Oracle Docs: Definition: Two of the components of a method declaration comprise the method signature —the method's name and the parameter types. Since the question was edited to

What are the possible operators for traits in a where clause in Rust?

。_饼干妹妹 提交于 2019-12-24 09:28:19
问题 I'm learning Rust and got to the chapter on trait bounds. In that chapter, they give an example with the + (plus) operator to enumerate all required traits in a where clause. What other operators are allowed on traits in Rust? I searched but I wasn't able to find any documentation about this. Does Rust support 'or' notation, brackets, negation? 回答1: 'or' notation No. Such a thing doesn't make sense to me — what would the code do if something could be A OR B ? brackets No, unless you count the

Is method signature in PHP a MUST or SHOULD?

烂漫一生 提交于 2019-12-24 05:39:08
问题 I mean if it's called with $request which is not instance of sfWebRequest ,will it be fatal,or just a warning? class jobActions extends sfActions { public function executeIndex(sfWebRequest $request) { $this->jobeet_job_list = Doctrine::getTable('JobeetJob') ->createQuery('a') ->execute(); } // ... } 回答1: It will be a catchable fatal error. Here is an example: class MyObj {} function act(MyObj $o) { echo "ok\n"; } function handle_errors($errno, $str, $file, $line, $context) { echo "Caught

Is method signature in PHP a MUST or SHOULD?

这一生的挚爱 提交于 2019-12-24 05:39:07
问题 I mean if it's called with $request which is not instance of sfWebRequest ,will it be fatal,or just a warning? class jobActions extends sfActions { public function executeIndex(sfWebRequest $request) { $this->jobeet_job_list = Doctrine::getTable('JobeetJob') ->createQuery('a') ->execute(); } // ... } 回答1: It will be a catchable fatal error. Here is an example: class MyObj {} function act(MyObj $o) { echo "ok\n"; } function handle_errors($errno, $str, $file, $line, $context) { echo "Caught

How to implement python method with signature like ([start ,] stop [, step]), i.e. default keyword argument on the left

不想你离开。 提交于 2019-12-22 08:43:44
问题 Since in python 3.X the build-id range() function returns no longer a list but an iterable, some old code fails as I use range() to conveniently generate lists I need. So I try to implement my own lrange function like this: def lrange(start = 0, stop, step = 1): ret = [] while start < stop: ret.append(start) start += step return ret giving me a "non-default argument follows default argument" interpreter error. If I look at Python's range() it seems to be possible. I posted this question

Determining if an Objective-C method is variadic during runtime

断了今生、忘了曾经 提交于 2019-12-22 07:53:30
问题 Is there a way to find out -- at runtime -- whether a given method is of variadic type? Something like method_getTypeEncoding() ; that won't tell me whether a method accepts variable number of arguments. Or is there maybe a trick to tell so? 回答1: Robert's comment is correct. Consider: @interface Boogity @end @implementation Boogity - (void)methodWithOneIntArg:(int)a {;} - (void)variadicMethodWithIDSentinel:(id)a, ... {;} @end Running strings on the resulting binary produces (there was also

Determining if an Objective-C method is variadic during runtime

Deadly 提交于 2019-12-22 07:52:22
问题 Is there a way to find out -- at runtime -- whether a given method is of variadic type? Something like method_getTypeEncoding() ; that won't tell me whether a method accepts variable number of arguments. Or is there maybe a trick to tell so? 回答1: Robert's comment is correct. Consider: @interface Boogity @end @implementation Boogity - (void)methodWithOneIntArg:(int)a {;} - (void)variadicMethodWithIDSentinel:(id)a, ... {;} @end Running strings on the resulting binary produces (there was also