feat: created first high level API, initialize and close a dict and work with it through a macro

This commit is contained in:
noether 2026-07-13 01:54:37 -03:00
commit 15911d6e49
2 changed files with 18 additions and 1 deletions

View file

@ -1 +1,17 @@
(in-package :monastery)
;; useful macros
(defmacro with-dict ((dict filepath) &body body)
"opens the dictionary path, executes the operations and closes automatically"
`(let ((,dict (dict-init ,filepath)))
(unwind-protect (progn ,@body)
(dict-close ,dict))))
;; functions
(defun dict-init (filepath)
"receives the dictionary filepath and opens the file")
(defun dict-close (dict)
"receives the dictionary instance and closes it")

View file

@ -1,5 +1,6 @@
(defpackage :monastery
(:use #:cl #:cffi #:cffi-ops))
(:use #:cl #:cffi #:cffi-ops)
(:export #:dict-init #:dict-close #:with-dict))
(in-package :monastery)