views:

126

answers:

4

Background

Perl and Ruby have the __END__ and __DATA__ tokens that allow embedding of arbitrary data directly inside a source code file.

Although this practice may not be well-advised for general-purpose programming use, it is pretty useful for "one-off" quick scripts for routine tasks.

Question:

What other programming languages support this same or similar feature, and how do they do it?

+2  A: 

Perl supports the __DATA__ marker, which you can access the contents of as though it were a regular file handle.

Anon.
Yeah, ruby does the same. I think the implementations for this language feature are essentially identical for ruby and perl.
dreftymac
+1  A: 

Fortran has a DATA statement that sounds like what you're looking for.

Jeff Hornby
The Fortran DATA statement is more akin to static variable initialization in C. It's not really the same.
Wayne Conrad
+1  A: 

Basic on the VIC20 and C64 had a "Data" command that worked something like this

100 DATA 1,2,3
110 DATA 4,5,6

Data could be read via a READ command.

I no longer have a c64 to test my code on.

sal
+1  A: 

SAS has the datalines construct which is used for embedding an external data file inside the source program, e.g. in the following program, there are 5 datalines (the terminator is the semi-colon on a line by itself)

data output;
  input name $ age;
  datalines;
Jim 14
Sarah 11
Hannah 9
Ben 9
Timothy 4
;
run;
Simon Nickerson
interesting. that looks similar to the HEREDOC convention: http://en.wikipedia.org/wiki/Heredoc
dreftymac