XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next

go


Type:   -   special form (fsubr)
Source:   -   xlcont.c

Syntax

(go tag-symbol)
tag-symbol - a symbol
returns - never returns a value

Description

The 'go' special form allows 'goto' style branching within 'block' constructs [do , do* , dolist , dotimes , tagbody , loop , prog and prog*]. The 'tag-symbol' is the 'label' and must exist somewhere within the 'block' that the 'go' occurs within. Otherwise an error will be generated:

error: no target for GO

'go' never returns a value. If the 'tag-symbol' exists, then the execution will continue immediately after the'tag-symbol'.

Examples

(defun foo (i j)                   ; define FOO
  (prog ()                         ; with a PROG
         (print "begin")
   start (print j)                 ; tag - START
         (setq j (1- j))
         (if (eql i j) (GO start)  ; 2-way branch
                       (GO end))
         (print "hello")           ; won't ever be reached
   end   (print "done")            ; tag - END
         (return 42)))

(foo 1 2)                          ; prints  "begin" 2 1 "done"
                                   ;   returns 42

(foo 2 1)                          ; prints  "begin" 1 "done"
                                   ;   returns 42

Note: Although 'go' will accept a 'tag-symbol' that is not a symbol, it will not find this improper 'tag-symbol'. An error will be generated:

error: no target for GO

See the go special form in the XLISP 2.0 manual.

  Back to Top


XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next