標籤:

foo到底是什麼意思?

學編程的人對這三個字母的組合肯定不陌生,很多示例函數名都叫這個,當然也有人寫fun作為示例函數名的的,fun就比較好理解了,是function的縮寫,但foo是什麼意思呢?為什麼用這個來作為函數名呢?


foo還有bar都是無意義的代名詞,就好像中文裡面的「某某「,「張三李四」差不多。據說foo最早起源於漢字」福「。


善用維基:Foobar


在計算機程序設計與計算機技術的相關文檔中,術語foobar是一個常見的無名氏化名,常被作為「偽變數」使用。 從技術上講,「foobar」很可能在1960年代至1970年代初通過迪吉多的系統手冊傳播開來。另一種說法是,「foobar」可能來源於電子學中反轉的foo信號;這是因為如果一個數字信號是低電平有效,那麼在信號標記上方一般會標有一根水平橫線,而橫線的英文即為「bar」。在《新黑客辭典》中,還提到「foo」可能早於「FUBAR」出現。

http://zh.wikipedia.org/zh-cn/Foo


你幸福嗎?

我姓foo吧。


誰說fun是function了 fun就是fun


Foobar



foo bar baz = 無名氏 = 張三李四小明小張


就是 @vczh 常用的Fuck, Shit, (逃


好吧,我一直以為是fool的縮寫


我聽說是由fubar(fucked up beyond any repair)而來的


function的簡寫通常是func


最近在看 "Learn python the hard way", 發現這個foo,特來分享。根據我的理解,foo應該是「某」的意思,就是僅僅是一個general的表達方式。


我google了一下, 發現沒有很好的中文答案。這個問題,在維基百科上有很好的回答。在這裡翻譯給大家。

譯文:

術語foobar, foo, bar, bazqux經常在計算機編程或計算機相關的文檔中被用作佔位符的名字。當變數,函數,或命令本身不太重要的時候,foobar, foo,bar, bazqux就被用來充當這些實體的名字,這樣做的目的僅僅是闡述一個概念,說明一個想法。這些術語本身相對於使用的場景來說沒有任何意義。Foobar經常被單獨使用;而當需要多個實體舉例的時候,foo,bar,和baz則經常被按順序使用。

原文:

The terms foobar, foo, bar, baz and qux are sometimes 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 purpose is unimportant and serve only to demonstrate a concept. The words themselves have no meaning in this usage. Foobar is sometimes used alone; foo, bar, and baz are sometimes used in that order, when multiple entities are needed.

// C code example

#include &

int foobar(int *pi)

{

*pi = 1024;

return *pi;

}

int main()

{

char foo[] = "Hello,";

char bar[] = "World!";

printf("%s %s
", foo, bar);

int baz = foobar();

printf("%d, baz");

return 0;

}


Etymology of "Foo"

1. Introduction

Approximately 212 RFCs, or about 7% of RFCs issued so far, starting

with [RFC269], contain the terms `foo, `bar, or `foobar used as a

metasyntactic variable without any proper explanation or definition.

This may seem trivial, but a number of newcomers, especially if

English is not their native language, have had problems in

understanding the origin of those terms. This document rectifies

that deficiency.

Section 2 below describes the definition and etymology of these words

and Section 3 interprets them as acronyms.

As an Appendix, we include a table of RFC occurrences of these words

as metasyntactic variables.

2. Definition and Etymology

bar /bar/ n. [JARGON]

1. The second metasyntactic variable, after foo and before baz.

"Suppose we have two functions: FOO and BAR. FOO calls BAR...."

2. Often appended to foo to produce foobar.

foo /foo/

1. interj. Term of disgust.

2. Used very generally as a sample name for absolutely anything, esp.

programs and files (esp. scratch files).

3. First on the standard list of metasyntactic variables used in

syntax examples (bar, baz, qux, quux, corge, grault, garply,

waldo, fred, plugh, xyzzy, thud). [JARGON]

When used in connection with `bar it is generally traced to the

WW II era Army slang acronym FUBAR (`Fucked Up Beyond All

Repair), later modified to foobar. Early versions of the Jargon

File [JARGON] interpreted this change as a post-war

bowdlerization, but it now seems more likely that FUBAR was itself

a derivative of `foo perhaps influenced by German `furchtbar

(terrible) - `foobar may actually have been the original form.

For, it seems, the word `foo itself had an immediate prewar

history in comic strips and cartoons. In the 1938 Warner Brothers

cartoon directed by Robert Clampett, "The Daffy Doc", a very early

version of Daffy Duck holds up a sign saying "SILENCE IS FOO!"

`FOO and `BAR also occurred in Walt Kellys "Pogo" strips. The

earliest documented uses were in the surrealist "Smokey Stover"

comic strip by Bill Holman about a fireman. This comic strip

appeared in various American comics including "Everybodys"

between about 1930 and 1952. It frequently included the word

"FOO" on license plates of cars, in nonsense sayings in the

background of some frames such as "He who foos last foos best" or

"Many smoke but foo men chew", and had Smokey say "Where theres

foo, theres fire". Bill Holman, the author of the strip, filled

it with odd jokes and personal contrivances, including other

nonsense phrases such as "Notary Sojac" and "1506 nix nix".

According to the Warner Brothers Cartoon Companion [WBCC] Holman

claimed to have found the word "foo" on the bottom of a Chinese

figurine. This is plausible; Chinese statuettes often have

apotropaic inscriptions, and this may have been the Chinese word

`fu (sometimes transliterated `foo), which can mean "happiness"

when spoken with the proper tone (the lion-dog guardians flanking

the steps of many Chinese restaurants are properly called "fu

dogs") [PERS]. English speakers reception of Holmans `foo

nonsense word was undoubtedly influenced by Yiddish `feh and

English `fooey and `fool. [JARGON, FOLDOC]

Holmans strip featured a firetruck called the Foomobile that rode

on two wheels. The comic strip was tremendously popular in the

late 1930s, and legend has it that a manufacturer in Indiana even

produced an operable version of Holmans Foomobile. According to

the Encyclopedia of American Comics [EAC], `Foo fever swept the

U.S., finding its way into popular songs and generating over 500

`Foo Clubs. The fad left `foo references embedded in popular

culture (including the couple of appearances in Warner Brothers

cartoons of 1938-39) but with their origins rapidly forgotten.

[JARGON]

One place they are known to have remained live is in the U.S.

military during the WWII years. In 1944-45, the term `foo

fighters [FF] was in use by radar operators for the kind of

mysterious or spurious trace that would later be called a UFO (the

older term resurfaced in popular American usage in 1995 via the

name of one of the better grunge-rock bands [BFF]). Informants

connected the term to the Smokey Stover strip [PERS].

The U.S. and British militaries frequently swapped slang terms

during the war. Period sources reported that `FOO became a

semi-legendary subject of WWII British-army graffiti more or less

equivalent to the American Kilroy [WORDS]. Where British troops

went, the graffito "FOO was here" or something similar showed up.

Several slang dictionaries aver that FOO probably came from

Forward Observation Officer, but this (like the contemporaneous

"FUBAR") was probably a backronym [JARGON]. Forty years later,

Paul Dicksons excellent book "Words" [WORDS] traced "Foo" to an

unspecified British naval magazine in 1946, quoting as follows:

"Mr. Foo is a mysterious Second World War product, gifted with

bitter omniscience and sarcasm."

Earlier versions of the Jargon File suggested the possibility that

hacker usage actually sprang from "FOO, Lampoons and Parody", the

title of a comic book first issued in September 1958, a joint

project of Charles and Robert Crumb. Though Robert Crumb (then in

his mid-teens) later became one of the most important and

influential artists in underground comics, this venture was hardly

a success; indeed, the brothers later burned most of the existing

copies in disgust. The title FOO was featured in large letters on

the front cover. However, very few copies of this comic actually

circulated, and students of Crumbs `oeuvre have established that

this title was a reference to the earlier Smokey Stover comics.

The Crumbs may also have been influenced by a short-lived Canadian

parody magazine named `Foo published in 1951-52. [JARGON]

An old-time member reports that in the 1959 "Dictionary of the

TMRC Language", compiled at TMRC (the Tech Model Railroad Club at

MIT) there was an entry for Foo. The current on-line version, in

which "Foo" is the only word coded to appear red, has the

following [TMRC]:

Foo: The sacred syllable (FOO MANI PADME HUM); to be spoken

only when under obligation to commune with the Deity. Our first

obligation is to keep the Foo Counters turning.

This definition used Bill Holmans nonsense word, then only two

decades old and demonstrably still live in popular culture and

slang, to make a "ha ha only serious" analogy with esoteric

Tibetan Buddhism. Todays hackers would find it difficult to

resist elaborating a joke like that, and it is not likely 1959s

were any less susceptible. [JARGON]

4. [EF] Prince Foo was the last ruler of Pheebor and owner of the

Phee Helm, about 400 years before the reign of Entharion. When

Foo was beheaded by someone he called an "eastern fop" from

Borphee, the glorious age of Pheebor ended, and Borphee rose to

the prominence it now enjoys.

5. [OED] A 13th-16th century usage for the devil or any other enemy.

The earliest citation it gives is from the year 1366, Chaucer A B

C (84): "Lat not our alder foo [devil] make his bobance [boast]".

Chaucers "Foo" is probably related to modern English "foe".

6. Rare species of dog.

A spitz-type dog discovered to exist after having long been

considered extinct, the Chinese Foo Dog, or Sacred Dog of

Sinkiang, may have originated through a crossing of Northern

European hunting dogs and the ancient Chow Chow from Mongolia or

be the missing link between the Chinese Wolf and the Chow Chow.

It probably derives its name from foochow, of the kind or style

prevalent in Foochow, of or from the city of Foochow (now Minhow)

in southeast China. [DOG]

foobar n.

[JARGON] A widely used metasyntactic variable; see foo for

etymology. Probably originally propagated through DECsystem

manuals by Digital Equipment Corporation (DEC) in 1960s and early

1970s; confirmed sightings there go back to 1972. Hackers do not

generally use this to mean FUBAR in either the slang or jargon

sense. It has been plausibly suggested that "foobar" spread among

early computer engineers partly because of FUBAR and partly

because "foo bar" parses in electronics techspeak as an inverted

foo signal.

foo-fighter n.

World War II term for Unidentified Flying Objects (UFOs) noted by

both German and British military. See [FF] and entry above for

"foo".

3. Acronyms

The following information is derived primarily from the compilations

at University Cork College & and Acronym

Finder & generally filtered for computer

usage.

.bar:

Generic file extension which is not meant to imply anything about

the file type.

BAR:

Base Address Register

Buffer Address Register

FOO:

Forward Observation Observer.

FOO Of Oberlin. An organization whose name is a recursive

acronym. Motto: The FOO, the Proud, the FOO. See

&.

File Open for Output. An NFILE error code [RFC1037].

Eastlake, et al. Informational [Page 5]

RFC 3092 Etymology of "Foo" 1 April 2001

FOOBAR:

FTP Operation Over Big Address Records [RFC1639]. (Particularly

appropriate given that the first RFC to use "foo", [RFC269], was

also about file transfer.)

FUBAR:

Failed UniBus Address Register - in a VAX, from Digital Equipment

Corporation Engineering.

Fucked Up Beyond All Recognition/Repair - From US Military in

World War II. Sometimes sanitized to "Fouled Up ...".

FUBARD - Past tense of FUBAR.

Security Considerations

Security issues are not discussed in this memo.

References

[BFF] "Best of Foo Fighters: Signature Licks", Troy Stetina, Foo

Fighters, October 2000, Hal Leonard Publishing Corporation,

ISBN 063401470.

[DOG] &.

[EAC] "Encyclopedia of American Comics", Ron Goulart, 1990, Facts

on File.

[EF] "Encyclopedia Frobozzica",

&

[FF] Foo Fighters - "The Rainbow Conspiracy", Brad Steiger,

Sherry Hansen Steiger, December 1998, Kensington Publishing

Corp., ISBN 1575663635. - Computer UFO Network

& particularly

&.

[FOLDOC] "Free On-Line Dictionary Of Computing",

&.

[JARGON] The Jargon File. See &. Last

printed as "The New Hackers Dictionary", Eric S. Raymond,

3rd Edition, MIT Press, ISBN 0-262-68092-0, 1996.

[OED] "The Oxford English Dictionary", J. A. Simpson, 1989,

Oxford University Press, ISBN 0198611862.

[PERS] Personal communications.

[RFC269] Brodie, H., "Some Experience with File Transfer", RFC 269,

December 1971.

[RFC1037] Greenberg, B. and S. Keene, "NFILE - A File Access

Protocol", RFC 1037, December 1987.

[RFC1639] Piscitello, D., "FTP Operation Over Big Address Records

(FOOBAR)", RFC 1639, June 1994.

[RFC2606] Eastlake, D. and A. Panitz, "Reserved Top Level DNS Names",

BCP 32, RFC 2606, June 1999.

[TMRC] The Tech Model Railroad Club (The Model Railroad Club of

the Massachusetts Institute of Technology) Dictionary,

&.

[WBCC] "Warner Brothers Cartoon Companion",

&.

[WORDS] "Words", Paul Dickson, ISBN 0-440-52260-7, Dell, 1982.

來源:RFC[3092]


fun是function的簡寫?

不是fun?

不是寫個函數樂呵樂呵的意思?


分頁阅读: 1 2