
COMEFROM - llambda
http://en.wikipedia.org/wiki/COMEFROM
======
skimbrel
COME FROM is the reason INTERCAL is among my favorite esoteric programming
languages. That and the fact that its name is for "Compiler Language With No
Pronounceable Acronym".

From Wikipedia: _An actual example in INTERCAL would be too difficult to read_

Gotta love it.

~~~
mritun
It's actually "An actual example in INTERCAL would be too difficult to
read[citation needed]"

Some people have a wicked sense of humour

------
stuartd
See also
[http://msmvps.com/blogs/jon_skeet/archive/2011/11/11/eduasyn...](http://msmvps.com/blogs/jon_skeet/archive/2011/11/11/eduasync-
part-15-implementing-comefrom-with-a-horrible-hack.aspx) for COMEFROM in C#

------
itmag
What are some more obscure control flow structures? It's easy to think that eg
conditionals, loops, goto, function calls are the only ones that exist. But
there is also stuff like jump tables and co-routines for instance.

~~~
brlewis
I don't know if it gets any more obscure than Scheme's call/cc, which is a
building block for other control flow structures. You can use it for cool
things like the Racket web server, where event-driven programming can be made
to feel like sequential, procedural-style programming. You can also use it for
sick mind twisters like ((call/cc call/cc) (call/cc call/cc))

~~~
itmag
Please explain :)

~~~
brlewis
Good explanation here: <http://lambda-the-ultimate.org/node/86#comment-3806>

But you have to read it slowly.

~~~
itmag
Mine lisp-peen is too small.

Now, off to study!

Thanks, btw.

~~~
spacemanaki
I don't think I ever really understood call/cc until I read Lisp in Small
Pieces. The author makes a great effort to implement call/cc in each of the
interpreters and compilers he presents, and examines the hairy issues that
come up when you decide to support first-class continuations.

Highly recommended.

------
skynirka
Have any examples of languages that implement this?

~~~
ryandvm
Some elements of Aspect Oriented Programming are comparable to the COMEFROM
statement.

[http://en.wikipedia.org/wiki/Aspect-
oriented_programming#See...](http://en.wikipedia.org/wiki/Aspect-
oriented_programming#See_also)

~~~
brlewis
Here's an AOP-style comefrom syntax you can play with by setting DrRacket's
language to R5RS:

    
    
      (define-syntax comefrom
        (syntax-rules ()
          ((comefrom function expr ...)
           (let ((old-function function))
             (set! function
                   (lambda args
                     (begin expr ...)
                     (apply old-function args)))))))
      
      (define (square x)
        (* x x))
      
      (define (hypotenuse a b)
        (sqrt (+ (square a) (square b))))
      
      (comefrom square
                (display "I'm a square!\n"))
      
      (hypotenuse 3 4)
    

The example in the Wikipedia article is more like this:

    
    
      (define-syntax comefrom
        (syntax-rules ()
          ((comefrom function)
           (call-with-current-continuation
            (lambda (here)
              (set! function here))))))
      
      (define (noop)
        ; Do nothing
        #t)
      
      (define (main)
        (let ((i 0))
          (comefrom noop)
          (if (< i 5)
              (begin
                (set! i (+ i 1))
                (display "Hello world!\n")
                (noop)))))
      
      (main)

