Options Paremeters Arguments Flags

在不嚴格的情況下肚邢,parameter和argument是可以混用的谬运。
Java或通常的編程語言中离福,parameter指代函數(shù)聲明中的變量;而argument指代函數(shù)被調(diào)用時傳遞的實際輸入。
在Shell或命令行中猿挚,argument的含義和Java是類似的咐旧,指代調(diào)用或運行時的輸入值。但parameter的含義有點晦澀和不實用绩蜻。若干結(jié)合option铣墨,一個簡單而實用的區(qū)分是:argument是統(tǒng)稱,option是--或-開頭的argument办绝,而parameter看成option的值伊约。

There are no consistent definitions of the terms "option", "argument", and "flag", and there is no central authority within the software development world that could enforce their usage. This happens with much terminology: after 30+ years of using the word "directory", I now have to deal with people using the word "folder" who have been confused by Microsoft's new-speak.
There are different ways that consensus definitions for terms can come about in programming. In the case of "argument"/"option"/"flag", canonical manuals and tutorials for programming languages have helped to enforce usage, as has the terms used in common libraries.
For instance, the things you put on the command line after a command are often called "arguments" to the command, by analogy with arguments to a function call, and this is probably partly because they are called "arguments" in the C manual (hence argc and argv). The argparse Python library also helps to enforce the term "argument". However, I have also seen them being called "parameters".
The term "option" is derived from "optional", which implies they can be left out. The getopt C library is one use of this term. But there is precedent for "options" that are not actually optional: for example, the argparse manual states that one can create a "required option" (although it also says that this is "generally considered bad form"). Options are often preceded by a single (-) or double (--, long-option) dash, but there are well-known commands that do not require or enforce dash usage for options (e.g., tar, ps, and dd). An option can itself take an argument (e.g., -w80 and --color=always), or occasionally multiple arguments.
"Flags" are, in my experience, the same as options, but usually do not take arguments themselves and essentially represent boolean on-off switches.
On a broader note, since every programmer has the option to try and look up some standard way of doing things and naming things, but can also reinvent the wheel without much extra cost, naming is never going to be consistent. And once you have documented your code, and it is clear what new meaning you have given to these words by giving examples, those names and meanings might just stick if there are enough people who pick them up from your code.

參考

argument、parameter以及option有什么區(qū)別孕蝉?

Linux中命令選項及參數(shù)簡介

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末屡律,一起剝皮案震驚了整個濱河市,隨后出現(xiàn)的幾起案子降淮,更是在濱河造成了極大的恐慌超埋,老刑警劉巖,帶你破解...
    沈念sama閱讀 222,104評論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件佳鳖,死亡現(xiàn)場離奇詭異霍殴,居然都是意外死亡,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,816評論 3 399
  • 文/潘曉璐 我一進店門嘶窄,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事荠卷。” “怎么了棚点?”我有些...
    開封第一講書人閱讀 168,697評論 0 360
  • 文/不壞的土叔 我叫張陵冲甘,是天一觀的道長。 經(jīng)常有香客問我叁鉴,道長土涝,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,836評論 1 298
  • 正文 為了忘掉前任幌墓,我火速辦了婚禮但壮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘常侣。我一直安慰自己蜡饵,他們只是感情好,可當我...
    茶點故事閱讀 68,851評論 6 397
  • 文/花漫 我一把揭開白布胳施。 她就那樣靜靜地躺著溯祸,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上焦辅,一...
    開封第一講書人閱讀 52,441評論 1 310
  • 那天博杖,我揣著相機與錄音,去河邊找鬼筷登。 笑死剃根,一個胖子當著我的面吹牛,可吹牛的內(nèi)容都是我干的前方。 我是一名探鬼主播跟继,決...
    沈念sama閱讀 40,992評論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼镣丑!你這毒婦竟也來了舔糖?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,899評論 0 276
  • 序言:老撾萬榮一對情侶失蹤莺匠,失蹤者是張志新(化名)和其女友劉穎金吗,沒想到半個月后,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體趣竣,經(jīng)...
    沈念sama閱讀 46,457評論 1 318
  • 正文 獨居荒郊野嶺守林人離奇死亡摇庙,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 38,529評論 3 341
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了遥缕。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片卫袒。...
    茶點故事閱讀 40,664評論 1 352
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖单匣,靈堂內(nèi)的尸體忽然破棺而出夕凝,到底是詐尸還是另有隱情,我是刑警寧澤户秤,帶...
    沈念sama閱讀 36,346評論 5 350
  • 正文 年R本政府宣布码秉,位于F島的核電站,受9級特大地震影響鸡号,放射性物質(zhì)發(fā)生泄漏转砖。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 42,025評論 3 334
  • 文/蒙蒙 一鲸伴、第九天 我趴在偏房一處隱蔽的房頂上張望府蔗。 院中可真熱鬧,春花似錦汞窗、人聲如沸姓赤。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,511評論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽模捂。三九已至捶朵,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間狂男,已是汗流浹背综看。 一陣腳步聲響...
    開封第一講書人閱讀 33,611評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留岖食,地道東北人红碑。 一個月前我還...
    沈念sama閱讀 49,081評論 3 377
  • 正文 我出身青樓,卻偏偏與公主長得像泡垃,于是被迫代替她去往敵國和親析珊。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 45,675評論 2 359

推薦閱讀更多精彩內(nèi)容