(uiop:define-package :binry-hop/debug-util
 (:use :cl)
 (:export #:io-open #:io-close #:mv-ssf #:cat)
 (:nicknames :debug-util))

(in-package :binry-hop/debug-util)

(defun io-open (&key (path #p"tmp.data") 
                (direction :io) (if-exists :supersede)
                (if-does-not-exist :create) 
                &allow-other-keys keys)
 (apply 'open path 
  (append keys
   (list :direction direction :if-exists if-exists
         :if-does-not-exist if-does-not-exist))))

(defun io-close (stream)
 (unwind-protect
  (close stream)
  (close stream :abort t)))

(defmacro mv-ssf (symbols form)
 `(multiple-value-bind ,symbols ,form
   (setf
    ,@(loop for s in symbols nconc
       `((symbol-function ',s) ,s)))))

(defun cat (&optional (path #p"tmp.data"))
 (with-open-file (in path)
  (loop for read = (read-line in nil nil) while read do (print read))))