From f9d87f161987d9bbbb1c70d7c833e72823eda584 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Sun, 16 Feb 2014 20:36:07 +0100 Subject: [PATCH] Add `remhash' function --- src/compiler/compiler.lisp | 4 ++++ src/hash-table.lisp | 7 +++++++ 2 files changed, 11 insertions(+) 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)))) -- 1.7.10.4