foo、bar到底是什么意思
生活随笔
收集整理的這篇文章主要介紹了
foo、bar到底是什么意思
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在學習編程語言的過程中,尤其使用的是英文的書籍,我們經常發現一些foo、bar、baz之類的名字,要么是變量的名字,要么是文件的名字。。。深究起來完全不明所以。這到底是什么意思呢?
示例
下面是《C++17 STL Cookbook》這本書的一些用例:
//foo用做類名 class foo { public:static std::string &standard_string() {static std::string s{"some standard string"};return s;} };還有:
//用作文件名 path p {"testdir/foobar.txt"};同樣其他語言里也有這種情況,《The Go Programming Language》這本書使用了大量此類名字:
f, err = os.Open("foo.txt") // 用作文件名 //用做字符串 fmt.Println(Equal([]string{"foo"}, []string{"bar"}))解釋
那這些單詞傳達給我們的意思是什么呢?實際上這些東西跟我們中文里的張三、李四、王五這類詞屬于一類,表示當前命名“無關緊要”,不影響當前概念的表達。
其他資料
維基百科里有比較專業的解釋:
The terms foobar (/?fu?bɑ?r/), or foo and others are used as placeholder names (also referred to as metasyntactic variables) in computer programming or computer-related documentation.[1] They have been used to name entities such as variables, functions, and commands whose exact identity is unimportant and serve only to demonstrate a concept.直譯過來就是:
foobar或者foo等諸如此類的措辭在計算機編程或計算機相關文檔中被用作占位符名字(也稱為元語法變量)。它們通常被用來命名一些變量、函數或命令等此類實體,而這些實體通常不重要,而且僅僅用來演示一個概念。請關注我的公眾號哦。
總結
以上是生活随笔為你收集整理的foo、bar到底是什么意思的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [BJWC2018]Border 的四种
- 下一篇: 原生Android之(6.0及以上)权限