Jump to content

Talk:Here document

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 91.154.87.201 (talk) at 14:48, 23 March 2012 (→‎History of the concept?: v7 manpage first mention?). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Does anybody know - is it pronounced "hear dok" or "heh red oc" (sorry for bad attempts at spelling phonetically!) 213.253.35.7 13:08, 20 September 2006 (UTC)[reply]

While I haven't heard it said often, it's always been "hear dok" (two syllables), presumably because it's a contraction of "here document". Mairi 17:10, 20 September 2006 (UTC)[reply]

todo ;; add 'Nowdoc' to PHP section

I don't have much knowledge of this topic, perhaps someone who does could add the distinction between 'Heredoc' and 'Nowdoc' in PHP? They're delimited and behave slightly differently. 196.210.216.244 (talk) 03:48, 5 July 2010 (UTC)[reply]

reference: http://www.php.net/manual/en/language.types.string.php

todo ;; add interpolation

add content on meaning of interpolation drefty.mac 04:05, 27 October 2006 (UTC)[reply]

Back to the future!

I really like the back to the future example for windows power shell (whoever did that). It's funny and very creative. Unfortunately, it's also quite long. I hate to ask, but can you please cut it down substantially? At least so it is at least close to the size of the other examples. Thanks! dr.ef.tymac 19:48, 24 November 2006 (UTC)[reply]

Never mind about shortening it, in reconsideration, the perl example is long also. But still, a more straightfoward example seems appropriate. It just seems like a bit much to demonstrate the difference between the two output results. dr.ef.tymac 19:51, 24 November 2006 (UTC)[reply]

"Here" ??

What does the word "Here" refer to? or what's its etymology? Dofstead 17:25, 6 March 2007 (UTC)[reply]

Probably here as in "a complete document right here". As opposed to theredoc (just found this myself: [1]). 193.143.216.169 11:54, 11 June 2007 (UTC)[reply]

Too wide definition

The article defines "here" documents as convenient multi-line string literals, and gives examples including Python's triple-quoted strings. I am almost sure this is incorrect. In Bourne shell, Perl and I guess a few more, the essential feature of a here document is that it isn't a string literal! It is an input stream, like a temporary file containing that string. It's indented to be fed as standard input to some external command. The tr(1) example in the article is typical. JöG (talk) 11:01, 16 February 2008 (UTC)[reply]

...and I guess that in PHP everything is heredoc by default, until you introduce any code with "php" tags. --Kubanczyk (talk) 22:37, 29 April 2008 (UTC)[reply]
JöG is correct. Almost everything in this article is wrong, because heredocs in the shell aren't string literals, they are file literals ... then perl borrowed the syntax but used it for string literals. Calling Python's """...""" literals "here documents" is stupid, but this misuse of the terminology has even found its way into the Python page. -- 98.108.206.178 (talk) 11:06, 29 March 2011 (UTC)[reply]
I agree. I would propose to narrow the definition to constructs where the user can designate an arbitrary, custom string as a tag, and then have all the lines up to that tag are included in the string. This will eliminate the Python triple-quoted strings, since triple quote is not a custom string. --208.80.119.67 (talk) 00:59, 7 September 2011 (UTC)[reply]

History of the concept?

Does anyone know the history of the heredoc - who thought of the heredoc? what was the first implementation? etc? Kwertii (talk) 09:46, 7 August 2008 (UTC)[reply]

It is a Unix concept. Unix was originally sold to AT&T management as an office tool. Thus the implementation of Unix contains a number of text processing tools for formatting, etc., such as the boilerplate input found in this 'here document'; this arose in the 1970s. --Ancheta Wis (talk) 04:30, 19 July 2009 (UTC)[reply]
What ridiculous drivel. The heredoc was introduced in UNIX but it had nothing to do with "office tools" or "text processing tools" -- it was a feature of the Bourne shell, allowing inline definition of temp files. -- 98.108.206.178 (talk) 11:01, 29 March 2011 (UTC)[reply]
I see it in V7, but not in V6, sh(1). http://minnie.tuhs.org/cgi-bin/utree.pl?file=V7/usr/man/man1/sh.1. I think this (or better) should be in the article. 91.154.87.201 (talk) 14:48, 23 March 2012 (UTC)[reply]

delimiting identifier in string literal

Isn't there a vulnerability of the delimiting identifier accidentally occurring within the string literal? --Abdull (talk) 23:07, 27 January 2010 (UTC)[reply]

No, "literals" are compile-time constructs in the source code. A string literal only serves to represent a sequence of characters. At runtime it is just a sequence of characters like any other string. "Vulnerabilities" which are runtime things therefore are not relevant. --208.80.119.67 (talk) 01:01, 7 September 2011 (UTC)[reply]

Dreadful, tedious examples!

These examples are absolutely awful! They're long and tedious and pretty much worthless. If anyone actually needed such language-specific detail of how Powershell or Perl or some other language implemented all the various bells, whistles and go-fasters in its version of a here document, it is ridiculous to imagine that this is where they'd look to find it. The whole article appears to be the hodgepodge result of the fans of these various languages not wanting to be outdone by fans of the competing languages in listing all the remarkable reasons why their favorite language is best. This just doesn't need to be here. If no one objects in the next few days, I'm going to delete a lot of this junk and trim the article down (unless someone else beats me to it!) Msnicki (talk) 08:07, 24 October 2010 (UTC)[reply]

I've added the "External links" section, with a link to a Rosetta Code task on here documents that fulfils the same function as the list of language examples here. But is that enough to warrant removing the examples in this entry ? --Paddy (talk) 11:27, 7 September 2011 (UTC)[reply]

Bug in PHP ?

I don't know PHP but, looking at:

echo strtolower($toprint);

I would expect the output to be converted in lower case and look like:

hey joe smith! you can actually assign the heredoc section to a variable!

rather than the current:

Hey Joe Smith! You can actually assign the heredoc section to a variable!

Am I wrong?

I have no way to test it... Jack-cnv (talk) 12:00, 28 February 2012 (UTC)[reply]

TCL

"Tcl has no special syntax for heredocs, because the ordinary string syntaxes already allow embedded newlines and preserve indentation."

This is a non-sequitur. The ordinary string syntaxes of Perl, Ruby and PHP allow embedded newlines and preserve indentation; yet all three also support heredoc syntax.

Given that Tcl doesn't support heredocs, why are there Tcl examples at all? — Preceding unsigned comment added by 109.155.240.244 (talk) 14:20, 5 March 2012 (UTC)[reply]