5 ms·
COMEFROM
- skynirka 15y agoHave any examples of languages that implement this?
- elevenE 15y agoIIRC, INTERCAL does implement it.
- ryandvm 15y agoSome elements of Aspect Oriented Programming are comparable to the COMEFROM statement. http://en.wikipedia.org/wiki/Aspect-oriented_programming#See_also http://en.wikipedia.org/wiki/Aspect-oriented_programming#See...
- brlewis 15y agoHere'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)
- InclinedPlane 15y agoTo some extent any inversion of control style framework works like this. It can be more or less befuddling depending on the straightforwardness of the framework. Declarative style programming such as sql, xslt, or msbuild also tend to work this way, which can be maddening to debug.
- audreyt 15y agoThere's a CPAN module for it in Perl 5 (with support for fork() on parallel comefroms): http://search.cpan.org/dist/Acme-ComeFrom/lib/Acme/ComeFrom.pm http://search.cpan.org/dist/Acme-ComeFrom/lib/Acme/ComeFrom....
- itmag 15y agoWhat 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 15y agoI 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))
- skimbrel 15y agoI remember being shown call/cc briefly in CS 61A at Berkeley and then forgetting about it until recently when I saw an article on it while I was in the middle of writing an event-driven web application using Perl and Plack. I immediately saw how useful it would be and wished I had it available to use there.
- itmag 15y agoPlease explain :)
- skimbrel 15y agoCOME 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 15y agoIt's actually "An actual example in INTERCAL would be too difficult to read[citation needed]" Some people have a wicked sense of humour
- JonnieCache 15y agoReminds me of TWAIN Toolkit Without An Interesting Name
- stuartd 15y agoSee also http://msmvps.com/blogs/jon_skeet/archive/2011/11/11/eduasync-part-15-implementing-comefrom-with-a-horrible-hack.aspx http://msmvps.com/blogs/jon_skeet/archive/2011/11/11/eduasyn... for COMEFROM in C#
- katesmith098 15y agoYou want to make $85 hourly and $7000 per month like me just working on laptop for few hours! Would you like to be your own boss!Opportunities like this don't come by often. Don't let this one pass you by! CashHuge. com