You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
beautiful-racket/beautiful-racket-demo/basic-demo-2/gosub.rkt

16 lines
363 B
Racket

8 years ago
#lang br
(require "goto.rkt" "line.rkt")
(provide b-gosub b-return)
(define return-stack empty)
(define (b-gosub num-expr)
(let/cc return-cc
(push! return-stack return-cc)
(b-goto num-expr)))
(define (b-return)
(unless (pair? return-stack)
(raise-line-error "return without gosub"))
(define top-return-k (pop! return-stack))
(top-return-k))