From: David Vázquez Date: Sun, 16 Feb 2014 19:36:07 +0000 (+0100) Subject: Add `remhash' function X-Git-Url: http://repo.macrolet.net/gitweb/?p=jscl.git;a=commitdiff_plain;h=f9d87f161987d9bbbb1c70d7c833e72823eda584 Add `remhash' function --- diff --git a/src/compiler/compiler.lisp b/src/compiler/compiler.lisp index 644ac6a..60860b3 100644 --- a/src/compiler/compiler.lisp +++ b/src/compiler/compiler.lisp @@ -1267,6 +1267,10 @@ (define-builtin in (key object) `(bool (in (call |xstring| ,key) ,object))) +(define-builtin delete-property (key object) + `(selfcall + (delete (property ,object (call |xstring| ,key))))) + (define-builtin map-for-in (function object) `(selfcall (var (f ,function) diff --git a/src/hash-table.lisp b/src/hash-table.lisp index e598150..8125e9e 100644 --- a/src/hash-table.lisp +++ b/src/hash-table.lisp @@ -100,3 +100,10 @@ ,g!new-value) `(gethash ,g!new-value ,g!key ,g!hash-table) ; accessing form ))) + + +(defun remhash (key hash-table) + (let ((obj (caddr hash-table)) + (hash (funcall (cadr hash-table) key))) + (prog1 (in hash obj) + (delete-property hash obj))))