the @ symbol within handles

2 ビュー (過去 30 日間)
William
William 2011 年 9 月 13 日
hello,
I cannot seem to figure out what the "@" means in handles
Here is the example code
set(handles.axisGroup, 'SelectionChangeFcn', @axisGroup_SelectionChangeFcn);
is that a pass by reference notation as in C++?
Thanks

採用された回答

Walter Roberson
Walter Roberson 2011 年 9 月 13 日
No, it is not a pass-by-reference notation. It creates a function pointer object, with the function pointer object then being passed by value. The function pointer object may contain a lot more information than just a reference to the code: it may contain a complete p-coded version of the code and it may contain references to local variables.
Technically speaking, the @ notation creates a "closure" -- though it will be a near trivial closure if it is not being used as an anonymous function or if the routine being referenced does not have an 'end' statement matching the 'function' statement (which is interpreted as a signal to create a complete closure rather than to use the older style plain "reference to a routine")
  1 件のコメント
David Young
David Young 2011 年 9 月 13 日
I had no idea that including the final 'end' in a single-function m-file had any effect on the compiler. I'm delighted to learn that my obsessive inclusion of it in all my new functions and any old functions that I revisit has a purpose!

サインインしてコメントする。

その他の回答 (1 件)

the cyclist
the cyclist 2011 年 9 月 13 日

カテゴリ

Help Center および File ExchangeFunction Creation についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by