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-3/go.rkt

19 lines
441 B
Racket

8 years ago
#lang br
(require "structs.rkt" "line.rkt")
(provide b-goto b-gosub b-return)
(define (b-goto num-expr)
(raise (change-line-signal num-expr)))
(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))