麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > Perl > 正文

Perl中的符號 ->;、=>; 和 :: 分別表示什么意思?

2020-06-04 20:33:19
字體:
來源:轉載
供稿:網友

What do the ->, => and :: symbols mean?

  The -> is the "infix dereference operator". In other words it is the means by which one calls a sub with a pass by reference (among other things you can do with ->). As stated above most things in calls to perl/Tk routines are passed by reference. The -> is used in perl just as in C or C++. (Most of the widget primitives are elements of the Tk:: "perl class".) A simple example of dereferencing would be: $x = { def => bar }; # $x is a reference to an anon. hash print $x->{def},"/n"; # prints ``bar''

  Note that in the case of calling perl/Tk subs there may be more than one way to call by reference. Compare my($top) = MainWindow->new;

  with my($top) = new MainWindow;

  But in general you will be making extensive use of calls like: $top -> Widge-type;

  There is a clear and succint discussion of references, dereferences, and even closures in man perlref(1) or see the perl 5 info page at: http://www.metronet.com/perlinfo/perl5.html

  The use of the => operator is quite common in perl/Tk scripts. Quoting from man perlop(1):

  The => digraph is simply a synonym for the comma operator. It's useful for documenting arguments that come in pairs.

  You could say that => is used for aesthetic or organizational reasons. Note in the following how hard it is to keep track of whether or not every -option has an argument: $query -> Button(-in,/$reply,-side,'left',-padx,2m,-pady, 2m,-ipadx,2m,-ipady,1m)->pack(-side,'bottom');

  As opposed to: $query ->Button( -in => /$reply, -side => 'left', -padx => 2m, -pady => 2m, -ipadx => 2m, -ipady => 1m )->pack(-side => 'bottom');

  By the way if you wanted the numeric "greater than or equal" you would use >= not =>.

  While the :: symbol can be thought of as similar to the period in a C struct, it is much more akin to the :: class scope operator in C++: a.b.c; /* something in C */ a::b::c(); // function in C++ $a::b::c; # a scalar in Perl 5 @a::b::c; # a list in Perl 5 %a::b::c; # an associative array or "hash" in Perl 5 &a::b::c; # a function in Perl 5

  It is also analogous to the single forward quotation mark in perl 4: $main'foo; # a $foo scalar in perl 4 $main::foo; # a $foo scalar in Perl 5

  For backward compatibility perl 5 allows you to refer to $main'foo but $main::foo is recommended.

  譯文:

  符號->,=>和::分別表示什么意思?

  ‘- >'符號是“插入式解引用操作符”(infix dereference operator)。換句話說,它是調用由引用傳遞參數的子程序的方法(當然,還有其它的作用)。正如我們上面所提到的,在調用Perl/Tk的函數的時候,大部分參數都是通過引用傳遞的。Perl中的‘->'功能就和它們在C或C++中一樣。(大部分原始的組件都是Tk中的Perl類的元素。)下面是一個簡單的解引用的例子:

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 日韩av在线资源 | 中文在线观看视频 | 国产精品v片在线观看不卡 成人一区二区三区在线 | 高清国产在线 | 成人做爰s片免费看网站 | 国产高潮国产高潮久久久91 | 日韩99| 91久久国产露脸精品免费 | 国产视频在线播放 | 欧美wwwsss9999 | 成人免费在线观看视频 | 成人偷拍片视频在线观看 | 亚洲一区二区三区视频 | 337p日本欧洲亚洲大胆精蜜臀 | 色中色综合 | 欧美精品激情在线 | 草草视频免费 | 欧美一级全黄 | 成人免费福利视频 | 一日本道久久久精品国产 | 国产成人精品免高潮在线观看 | 免费黄色在线 | 免费毛片视频 | 麻豆视频在线观看免费网站 | 国产一级一国产一级毛片 | 黄色av网| 成人免费视频视频在线观看 免费 | 日本精品久久久久 | 手机在线看片国产 | 国产精品一区二区x88av | 狠狠色噜噜狠狠狠米奇9999 | 免费高潮在线国 | 欧洲精品久久久 | 色99999| 成人在线观看地址 | 国产欧美精品综合一区 | 国产一区二区三区四区五区在线 | 亚洲综合无码一区二区 | 日本精品二区 | 久久久久北条麻妃免费看 | 羞羞的动漫在线观看 |