Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

(Let me know if this is the wrong SE for this)

Why is a Here Document (or Heredoc) called that? Wikipedia didn't have anything to say on that particular subject. I did find unix docs describing a "Here is document", is that the original form?

share|improve this question
add comment

4 Answers

up vote 8 down vote accepted

Some teleprinters* had a sequence of a dozen or two characters that could be programmed (mechanically) into the unit and was sent when the host sent an ENQ character or the operator pressed the HERE IS key on the keyboard. A number of glass-tube terminals had the same feature.

A "here-is" document in shells and programming languages that support the same construct serves essentially the same purpose: it's a canned sequence of characters that doesn't change unless the program does.

*These are also the origin of the term tty that appears in Unix.

share|improve this answer
    
Aha! That's the kind of trivia I was looking for :D Thanks! –  Yamikuronue Apr 12 '12 at 14:50
2  
Sometimes it pays to be old. –  Blrfl Apr 12 '12 at 14:53
    
+1 for a great history lesson –  Dan Ray Apr 12 '12 at 20:22
add comment

Because it's all data from << HERE

all the way

down

to

right about

wait for it

HERE;

share|improve this answer
add comment

Well, the document is right here. Here it is. It's a logical name for the thing, yeah?

When people speak of 'here documents' they are generally speaking of a unit of data that is embedded into code. That data will be displayed to a user or used to compose a request to a server or to write information to a log or to update a configuration file, or, or, or,or... It's a mistake to overload the name with meanings and connotations. It's a programming technique and it has a name.

share|improve this answer
2  
Since when is a prettily formatted string a "document" necessarily? The one implies data connotation that a heredoc doesn't necessarily have. +1 for making me smile though :) –  Yamikuronue Apr 11 '12 at 15:18
7  
I hate to get all Forrest Gump on you, but a document is as a document does. When people speak of 'here documents' they are generally speaking of a unit of data that is embedded into code. That data will be displayed to a user or used to compose a request to a server or to write information to a log or to update a configuration file, or, or, or,or... It's a mistake to overload the name with meanings and connotations. It's a programming technique and it has a name. –  Adam Crossland Apr 11 '12 at 15:47
    
Huh. Maybe it's a regional linguistics thing: I usually see "document" used as "The kind of file you'd make in Word" and "file" or "data" for more generic uses. The term "Heredata" would make more sense to me >.> –  Yamikuronue Apr 12 '12 at 12:27
1  
The 'here document' idea predates Word by many years. –  Adam Crossland Apr 12 '12 at 13:17
    
Sure, but I wouldn't call a picture a 'document', even if it fulfills some of the technical requirements outlined in Wikipedia –  Yamikuronue Apr 12 '12 at 13:39
add comment

It's called a here document because it is 'here', in the source file that needs it, rather than being elsewhere, as a separate file. I guess looking deeper into it would be rather like trying to analyse the term '4 wheel drive' in great depth.

It can be very convenient to have your data within your code.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.