De Feliwiki
#lang r6rs
(library (core (1))
(export make-functions-group)
(import (rnrs base)
(rnrs hashtables))
; Example:
; (make-eq-hashtable-done ('key1 'value1) ('key2 'value2) ...)
(define-syntax make-eq-hashtable-done
(syntax-rules ()
((_ (key content) ...)
(let ((tab (make-eq-hashtable)))
(hashtable-set! tab key content) ...
tab))))
; Example:
; (make-functions-group <params> ('<field1> <body> ...)
; ('<field2> <body> ...) ...)
; How to use after:
; (<functions-group> 'field1 params ...)
(define-syntax make-functions-group
(syntax-rules ()
((_ <params> (function-name <body> ...) ...)
(let [(tab
(make-eq-hashtable-done
(function-name (lambda (<params>) <body> ...)) ...))
]
(lambda params
((hashtable-ref tab (car params) (lambda ? #f))
(cdr params)))))))
; Example:
;(define a (make-functions-group
; <params>
; ('id <params>)
; ('get-value "oi")))
)