[Question]
  [
Your task is to reverse the order in which some `prints` get executed.
---
**Specs:**  
Your code will be in this form: 
```
//some lines of code
/*code*/ print "Line1" /*code*/
/*code*/ print "Line2" /*code*/
/*code*/ print "Line3" /*code*/
/*code*/ print "Line4" /*code*/
//some lines of code
```
You will have to `print` (or `echo`, or `write`, or equivalent) those strings **from the fourth to the first.**
* You decide which lines of your program must `print` the strings, but they must be **adjacent**;
* Every line can contain only one `print`, and cannot exceed *60 bytes* in length;
* Since this is [popularity-contest](/questions/tagged/popularity-contest "show questions tagged 'popularity-contest'"), be creative and avoid to write just a `goto` or a simple `for(i){if(i=4)print"Line1";if(i=3)...}`
* The most upvoted answer in 2 weeks wins this.
* Your output **MUST** be `Line4 Line3 Line2 Line1` **OR** `Line4Line3Line2Line1` **OR** `Line4\nLine3\nLine2\nLine1`(where `\n` is a newline), and it must be generated only by executing those `prints` backwards.
Happy coding!
**UPDATE:** Contest is over! Thank you all :)
  
[Answer]
## Commodore 64 BASIC
```
40 print "Line 1"
30 print "Line 2"
20 print "Line 3"
10 print "Line 4"
```
[Answer]
## PHP
Abusing precedence... :-)
```
!print "Line1\n".
!print "Line2\n".
!print "Line3\n".
!print "Line4\n";
```
[Answer]
## C
Undefined behavior is the most exciting kind of behavior!
```
f(){}
main()
{
   f(printf("Line 1\n"), 
     printf("Line 2\n"), 
     printf("Line 3\n"), 
     printf("Line 4\n"));
}
```
Actual output may vary depending on your compiler, linker, operating system, and processor :)
[Answer]
# Java
Using reflection
```
public class ReversePrint {
    public static void main(String[]a) {
        System.out.println("Line1");
        System.out.println("Line2");
        System.out.println("Line3");
        System.out.println("Line4");
    }
    static {
        try{
            Field f=String.class.getDeclaredField("value");
            f.setAccessible(true);
            f.set("Line1","Line4".toCharArray());
            f.set("Line2","Line3".toCharArray());
            f.set("Line3","Line2 ".trim().toCharArray());
            f.set("Line4","Line1 ".trim().toCharArray());
        }catch(Exception e){}
    }
}
```
Output:
```
Line4
Line3
Line2
Line1
```
An explanation of why this works can be found [here](https://stackoverflow.com/a/20945113/597419).
[Answer]
## C (and sort-of Python)
New version, using a macro to fit the question format perfectly.
Following Quincunx's comment, I added `return` to make it nicer. 
It also works in Python, but it prints in correct order.
```
#define print"\n",printf(
#define return"\n"))));}
#define def main(){0?
def main():
    print "Line 1"
    print "Line 2"
    print "Line 3"
    print "Line 4"
    return
main();
```
Original version - the two are practically the same, after macro substitution:
```
main(){
    printf("Line 1\n",
    printf("Line 2\n",
    printf("Line 3\n",
    printf("Line 4\n",
    0))));
}
```
[Answer]
## ES6 (using backwards mode ;)
Wow, it looks like the designers of ECMAScript had some incredible foresight when they made [backwards mode](http://wiki.ecmascript.org/doku.php?id=harmony:backwards_mode) part of the spec:
```
// activate backwards mode:
'use backwardsˈ; \* mode backwards in now *\
code of lines some ⧵\
\*code*\ "Line1" print \*code*\
\*code*\ "Line2" print \*code*\
\*code*\ "Line3" print \*code*\
\*code*\ "Line4" print \*code*\
code of lines some ⧵\
⁏ˈforwards useˈ // back to ˈnormal'.
// So simple! No need to do anything this complicated:
split('"').reduce((L,o,l)=>(l%2?o:'')+L,'')
```
Output (evaluation, really):
```
"Line4Line3Line2Line1"
```
Note that it's *exactly* of the form requested, with only slight backwardification to fit [the syntax of the mode](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/Backwards_mode). Note also that this mode is only supported in recent versions of Firefox [at the moment](http://caniuse.com/use-backwards).
*Final note: Actually, there is no backwards mode. But this is still a valid script that runs in Firefox (copy the whole thing). :D*
---
### ES6 "lax mode"
**BONUS**: Here's an updated version that doesn't use backwards mode, but uses the newly-specified "lax mode" where the JS engine will just try to guess what the code is supposed to do, regardless of adherence to any specified JS syntax (basically the antithesis of strict mode):
```
// activate "lax" mode:
`use laxˋ; // also works: ˋuse relaxˋ, ˋuse guessingˋ, ˋuse whatevsˋ, etc.
//some lines of code
/*code*/ print "Line1" /*code*/
/*code*/ print "Line2" /*code*/
/*code*/ print "Line3" /*code*/
/*code*/ print "Line4" /*code*/
//some lines of code
ˋuse normalˋ; // same as ˋuse default`.
// Again, compare to inferior, illegible "traditional" ES6:
split('"').reduce((L,o,l)=>(l%2?o:'')+L,'')
```
Please note that "[lax mode](https://developer.mozilla.org/docs/Web/JavaScript/Reference/template_strings)" is currently only available in Firefox >= 34. ;P
[Answer]
# C
```
main()
{
  int i = 0;
  for(; i == 0; printf("Line 1\n"))
    for(; i == 0; printf("Line 2\n"))
      for(; i == 0; printf("Line 3\n"))
        for(; i == 0; printf("Line 4\n"))
          i = 1;
}
```
[Answer]
## Ruby
```
print 'Line1' unless
print 'Line2' unless
print 'Line3' unless
print 'Line4'
```
Edit: Alternatively,
```
def method_missing(meth,*)
  puts meth.to_s.sub('print'){}
end
printLine1(
printLine2(
printLine3(
printLine4)))
```
[Answer]
# PHP
I know, this is madness...
```
goto d;
a: print "Line1\n"; goto end;
b: print "Line2\n"; goto a;
c: print "Line3\n"; goto b;
d: print "Line4\n"; goto c;
end: exit;
```
[Answer]
## Haskell
This is almost idiomatic Haskell, as the program now looks like a right-to-left function composition. If the function wasn't print, but something that would return a (useful) value the operator declaration would be unnecessary and the code would be something you'd see in libraries.
```
a << b = (const a =<< b)
main = putStrLn "Line1"
    << putStrLn "Line2"
    << putStrLn "Line3"
    << putStrLn "Line4"
```
[Answer]
## Perl
```
use threads;
$a=threads->create(sub {sleep(5); print("Line1\n");});
$b=threads->create(sub {sleep(4); print("Line2\n");});
$c=threads->create(sub {sleep(3); print("Line3\n");});
$d=threads->create(sub {sleep(2); print("Line4\n");});
$a->join();
$b->join();
$c->join();
$d->join();
```
[Answer]
# HTML + CSS
```
<p>Line 1</p>
<p>Line 2</p>
<p>Line 3</p>
<p>Line 4</p>
```
CSS:
```
body {margin-top:7em}
p + p {margin-top:-4em}
```
See [jsFiddle](http://jsfiddle.net/udU4X/1/).
Edit:  
To conform to the rules better, here is a variant in XML, that actually uses `print`.
```
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="style.css"?>
<root>
  <print>Line 1</print>
  <print>Line 2</print>
  <print>Line 3</print>
  <print>Line 4</print>
</root>
```
where style.css should be
```
* {display:block; margin-top:3em}
print + print {margin-top:-3em}
```
# HTML without CSS
And for the heck of it, here's one without CSS.
```
<table>
<tfoot><tr><td><table><tfoot><tr><td>Line 1</tr></tfoot>
<tbody><tr><td>                      Line 2</table></tfoot>
<tbody><tr><td><table><tfoot><tr><td>Line 3</tr></tfoot>
<tbody><tr><td>                      Line 4</table></tbody>
</table>
```
[Fiddle](http://jsfiddle.net/m45Y2/1/).
[Answer]
# C++
```
#include <iostream>
#define Q(x,y) x ## y
#define P(x,y) Q(x, y)
#define print S P(s, __LINE__) =
struct S { const char *s; S(const char *s): s(s) {} ~S() { std::cout << s << std::endl; } };
int main() {
    print "Line1";
    print "Line2";
    print "Line3";
    print "Line4";
}
```
(Local variables are destroyed in reverse order of declaration.)
# C++11
```
#include <iostream>
int main() {
    struct S { void (*f)(); S(void (*f)()): f(f) {} ~S() { f(); } } s[] = {
        {[](){ std::cout << "Line1" << std::endl; }},
        {[](){ std::cout << "Line2" << std::endl; }},
        {[](){ std::cout << "Line3" << std::endl; }},
        {[](){ std::cout << "Line4" << std::endl; }},
    };
}
```
(Much the same, but using lambdas and an array data member instead.)
[Answer]
# Haskell
```
main = sequence_ $ reverse [
    putStr "Line1",
    putStr "Line2",
    putStr "Line3",
    putStr "Line4"]
```
[Answer]
# Javascript
```
setTimeout(function(){console.log("Line 1");},900);
setTimeout(function(){console.log("Line 2");},800);
setTimeout(function(){console.log("Line 3");},700);
setTimeout(function(){console.log("Line 4");},600);
```
[Answer]
# C
Trying to make defiance of the tips in the question as creative as possible:
```
#include <stdio.h>
#define print if (i == __LINE__) puts
static unsigned i;
int main(void) {
  while (--i) {
    print("Line 1");
    print("Line 2");
    print("Line 3");
    print("Line 4");
  }
  return 0;
}
```
[Answer]
## Bash
In memory of the revered [SleepSort](https://codegolf.stackexchange.com/a/16452/11422) and [SleepAdd](https://codegolf.stackexchange.com/a/16316/11422), I present to you... **SleepReverse**:
```
#!/bin/bash
function print(){(sleep $((4-$1));echo "Line $1";)&}
print 1
print 2
print 3
print 4
```
[Answer]
# BF
Assumes cell-wrapping.
```
++++[->+
----[> (line 1) .[-]<]++++
---[> (line 2) .[-]<]+++
--[> (line 3) .[-]<]++
-[> (line 4) .[-]<]+
<]
```
**Why it works**
The first and last lines compose of a loop that repeats four times (counter = `cell0`).
Inside the loop, there is a counter variable (`cell1`) that is increased every run.
Each lines checks if decreasing by four, three, two, or one equals zero. Therefore, on the first run, the counter is one and the last line is executed, on the second run, the third line is executed, etc.
The `(line 1)` shows where you should make the text that is printed. The arrows in the loops allocate `cell2` for this purpose. The `[-]` cleans out `cell2` after you use it.
[Answer]
## Java
```
import java.io.PrintStream;
import java.util.concurrent.FutureTask;
public class Print {
  public static void main(String[] args) {
    new FutureTask<PrintStream>(new Runnable() {
      public void run() {
        new FutureTask<PrintStream>(new Runnable() {
          public void run() {
            new FutureTask<PrintStream>(new Runnable() {
              public void run() {
                System.out.append("Line1"); }
            }, System.out.append("Line2")).run(); }
        }, System.out.append("Line3")).run(); }
    }, System.out.append("Line4")).run();
  }
}
```
It's all in the right timing... ;-)
[Answer]
## Bash
Here comes the double-faced script:
```
#!/bin/bash
s=1
if [ $s -ne 0 ]; then tac $0 | bash; exit; fi
s=0
echo "Line1"
echo "Line2"
echo "Line3"
echo "Line4"
```
[Answer]
# Python 3
```
import atexit
atexit.register(print,"Line1")
atexit.register(print,"Line2")
atexit.register(print,"Line3")
atexit.register(print,"Line4")
```
[Answer]
## Common Lisp № 1
It's easy to write a `ngorp` macro that executes its forms in reverse order:
```
(macrolet ((ngorp (&body ydob) `(progn ,@(reverse ydob))))
  (ngorp
   (write-line "Line 1")
   (write-line "Line 2")
   (write-line "Line 3")
   (write-line "Line 4")))
```
```
Line 4
Line 3
Line 2
Line 1
```
## Common Lisp № 2
Here's one that takes the problem very literally; the code from the question appears in program without modification:
```
(macrolet ((execute-prints-backwards (&body body)
             `(progn 
                ,@(nreverse (mapcar (lambda (string)
                                      (list 'write-line string))
                                    (remove-if-not 'stringp body))))))
  (execute-prints-backwards
//some lines of code
/*code*/ print "Line1" /*code*/
/*code*/ print "Line2" /*code*/
/*code*/ print "Line3" /*code*/
/*code*/ print "Line4" /*code*/
//some lines of code
  ))
```
```
Line4
Line3
Line2
Line1
```
[Answer]
# PHP
Another `eval` variant:
```
$lines=array_slice(file(__FILE__),-4); // get last 4 lines of current file
eval(implode('',array_reverse($lines)));exit; // eval lines reversed and exit
print "Line1\n";
print "Line2\n";
print "Line3\n";
print "Line4\n";
```
[Answer]
# F#
```
let inline (?) f g x = g x; f x
(printfn "Line1%s") ?
 (printfn "Line2%s") ?
  (printfn "Line3%s") ?
   (printfn "Line4%s") ""
```
Just created a custom operator that executes functions in reverse order.
[Answer]
# Go (Golang)
```
package main
import "fmt"
func main() {
    defer fmt.Println("Line 1")
    defer fmt.Println("Line 2")
    defer fmt.Println("Line 3")
    defer fmt.Println("Line 4")
}
```
Try it out: <http://play.golang.org/p/fjsJLwOFn2>
[Answer]
# Python3
```
print("Line1",
print("Line2",
print("Line3",
print("Line4") or '') or '') or '')
```
Can be 6 bytes shorter by removing all spaces in last line.
[Answer]
## Javascript
```
[
  "console.log('Line1')",
  "console.log('Line2')",
  "console.log('Line3')",
  "console.log('Line4')"
].reverse().forEach(function(e){eval(e)})
```
## C++11
```
#include <iostream>
#include <vector>
#include <algorithm>
int main() {
    std::vector<std::function<void()>> functors;
    functors.push_back([] { std::cout << "Line1"; });
    functors.push_back([] { std::cout << "Line2"; });
    functors.push_back([] { std::cout << "Line3"; });
    functors.push_back([] { std::cout << "Line4"; });
    std::reverse(functors.begin(),functors.end());
    std::for_each (functors.begin(), functors.end(), [](std::function<void()> f) {f();});
    return 0;
}
```
[Answer]
**Batch**
```
echo off
call :revers ^
echo.line1 ^
echo.line2 ^
echo.line3 ^
echo.line4
:revers
if not "%2"=="" call :revers %2 %3 %4 %5 %6 %7 %8 %9
%1
```
[Answer]
# C#
Instead of directly calling the Run method, I'm creating a dynamic method that contains a copy of Run's IL bytecode, except that the load-string opcode operands are swapped. Which causes the new method to display the strings in reverse order.
```
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
namespace TestApp
{
    class Program
    {
        public static void Run()
        {
            Console.WriteLine("Line 1");
            Console.WriteLine("Line 2");
            Console.WriteLine("Line 3");
            Console.WriteLine("Line 4");
        }
        static void Main(string[] args)
        {
            var method = typeof(Program).GetMethod("Run");
            var il = method.GetMethodBody().GetILAsByteArray();
            var loadStringOperands = new Stack<int>();
            for (int i = 0; i < il.Length; i++)
            {
                if (il[i] == OpCodes.Ldstr.Value)
                {
                    loadStringOperands.Push(BitConverter.ToInt32(il, i + 1));
                    i += 4;
                }
            }
            var run = new DynamicMethod("Run", typeof(void), null);
            var gen = run.GetILGenerator(il.Length);
            for (int i = 0; i < il.Length; i++)
            {
                if (il[i] == OpCodes.Ldstr.Value)
                {
                    var str = method.Module.ResolveString(loadStringOperands.Pop());
                    gen.Emit(OpCodes.Ldstr, str);
                    i += 4;
                }
                else if (il[i] == OpCodes.Call.Value)
                {
                    var mInfo = method.Module.ResolveMethod(BitConverter.ToInt32(il, i + 1)) as MethodInfo;
                    gen.Emit(OpCodes.Call, mInfo);
                    i += 4;
                }
                else if (il[i] == OpCodes.Ret.Value)
                {
                    gen.Emit(OpCodes.Ret);
                }
            }
            run.Invoke(null, null);
        }
    }
}
```
[Answer]
# Python
yet another solution using `eval()`
```
a = [
"print('Line1')",
"print('Line2')",
"print('Line3')",
"print('Line4')"]
for line in reversed(a):
    eval(line)
```
it's not very complex, but easy to understand.
]