diff --git a/include/mes/builtins.h b/include/mes/builtins.h index 1c7463db..8b473dbd 100644 --- a/include/mes/builtins.h +++ b/include/mes/builtins.h @@ -63,9 +63,9 @@ struct scm *gc (); /* src/hash.c */ struct scm *hashq (struct scm *x, struct scm *size); struct scm *hash (struct scm *x, struct scm *size); -struct scm *hashq_get_handle (struct scm *table, struct scm *key, struct scm *dflt); -struct scm *hashq_ref (struct scm *table, struct scm *key, struct scm *dflt); -struct scm *hash_ref (struct scm *table, struct scm *key, struct scm *dflt); +struct scm *hashq_get_handle_ (struct scm *table, struct scm *key, struct scm *dflt); +struct scm *hashq_ref_ (struct scm *table, struct scm *key, struct scm *dflt); +struct scm *hash_ref_ (struct scm *table, struct scm *key, struct scm *dflt); struct scm *hashq_set_x (struct scm *table, struct scm *key, struct scm *value); struct scm *hash_set_x (struct scm *table, struct scm *key, struct scm *value); struct scm *hash_table_printer (struct scm *table); diff --git a/mes/module/mes/scm.mes b/mes/module/mes/scm.mes index dadd3589..b119742b 100644 --- a/mes/module/mes/scm.mes +++ b/mes/module/mes/scm.mes @@ -190,6 +190,18 @@ (lambda args (proc (apply (apply compose rest) args))))) + +;; Hash + +(define (hashq-get-handle table key . rest) + (core:hashq-get-handle table key (and (pair? rest) (car rest)))) + +(define (hashq-ref table key . rest) + (core:hashq-ref table key (and (pair? rest) (car rest)))) + +(define (hash-ref table key . rest) + (core:hash-ref table key (and (pair? rest) (car rest)))) + ;; Vector (define (vector . rest) (list->vector rest)) diff --git a/src/builtins.c b/src/builtins.c index 558fd1d9..f86e696a 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -173,9 +173,9 @@ mes_builtins (struct scm *a) /*:((internal)) */ /* src/hash.c */ a = init_builtin (builtin_type, "hashq", 2, &hashq, a); a = init_builtin (builtin_type, "hash", 2, &hash, a); - a = init_builtin (builtin_type, "hashq-get-handle", 3, &hashq_get_handle, a); - a = init_builtin (builtin_type, "hashq-ref", 3, &hashq_ref, a); - a = init_builtin (builtin_type, "hash-ref", 3, &hash_ref, a); + a = init_builtin (builtin_type, "core:hashq-get-handle", 3, &hashq_get_handle_, a); + a = init_builtin (builtin_type, "core:hashq-ref", 3, &hashq_ref_, a); + a = init_builtin (builtin_type, "core:hash-ref", 3, &hash_ref_, a); a = init_builtin (builtin_type, "hashq-set!", 3, &hashq_set_x, a); a = init_builtin (builtin_type, "hash-set!", 3, &hash_set_x, a); a = init_builtin (builtin_type, "hash-table-printer", 1, &hash_table_printer, a); diff --git a/src/eval-apply.c b/src/eval-apply.c index d0a8a463..19306452 100644 --- a/src/eval-apply.c +++ b/src/eval-apply.c @@ -158,7 +158,7 @@ struct scm * macro_get_handle (struct scm *name) /*:((internal)) */ { if (name->type == TSYMBOL) - return hashq_get_handle (g_macros, name, cell_nil); + return hashq_get_handle_ (g_macros, name, cell_nil); return cell_f; } diff --git a/src/hash.c b/src/hash.c index 877674f6..ee574c03 100644 --- a/src/hash.c +++ b/src/hash.c @@ -70,7 +70,7 @@ hash (struct scm *x, struct scm *size) } struct scm * -hashq_get_handle (struct scm *table, struct scm *key, struct scm *dflt) +hashq_get_handle_ (struct scm *table, struct scm *key, struct scm *dflt) { struct scm *s = struct_ref_ (table, 3); long size = s->value; @@ -86,16 +86,16 @@ hashq_get_handle (struct scm *table, struct scm *key, struct scm *dflt) } struct scm * -hashq_ref (struct scm *table, struct scm *key, struct scm *dflt) +hashq_ref_ (struct scm *table, struct scm *key, struct scm *dflt) { - struct scm *x = hashq_get_handle (table, key, dflt); + struct scm *x = hashq_get_handle_ (table, key, dflt); if (x != cell_f) x = x->cdr; return x; } struct scm * -hash_ref (struct scm *table, struct scm *key, struct scm *dflt) +hash_ref_ (struct scm *table, struct scm *key, struct scm *dflt) { struct scm *s = struct_ref_ (table, 3); long size = s->value; diff --git a/src/module.c b/src/module.c index 98c382f0..413910ff 100644 --- a/src/module.c +++ b/src/module.c @@ -93,7 +93,7 @@ module_variable (struct scm *module, struct scm *name) { module = M0; struct scm *globals = struct_ref_ (module, 5); - x = hashq_get_handle (globals, name, cell_f); + x = hashq_get_handle_ (globals, name, cell_f); } return x; } diff --git a/src/string.c b/src/string.c index 171cb7b5..fe013309 100644 --- a/src/string.c +++ b/src/string.c @@ -114,7 +114,7 @@ keyword_to_string (struct scm *keyword) struct scm * string_to_symbol (struct scm *string) { - struct scm *x = hash_ref (g_symbols, string, cell_f); + struct scm *x = hash_ref_ (g_symbols, string, cell_f); if (x == cell_f) x = make_symbol (string); return x;