Hi Ludovic, 

> The ‘service’ form returns a procedure, but ‘register-service!’ expects
> a ‘hop-service’ instance.  The fact that ‘procedure-attr’ is used to
> link the two is an implementation detail, so users should probably not
> rely on it.
> 
> Thus, I propose this patch to allow procedures as returned by ‘service’
> to be passed to ‘register-service!’:
> 
> 
> diff -r 042aab3880b5 runtime/service.scm
> --- a/runtime/service.scm     Tue Sep 17 11:07:02 2013 +0200
> +++ b/runtime/service.scm     Thu Oct 03 17:28:41 2013 +0200
> @@@ -456,7 +456,10 @@@
>  ;*    register-service! ...                                            */
>  ;*---------------------------------------------------------------------*/
>  (define (register-service! svc)
> -   (with-access::hop-service svc (path id)
> +   (with-access::hop-service (if (procedure? svc)
> +                                 (procedure-attr svc)
> +                                 svc)
> +         (path id)
>        (let ((sz (hashtable-size *service-table*)))
>        (hop-verb 4 (hop-color 1 "" "REG. SERVICE ")
>           "(" (/fx sz 2) "): "
> 
> WDYT?
I'm not sure. 

I prefer to avoid this kind of ad-hoc polymorphism as much as
possible. Here, it makes it impossible to type register-service for no
real benefice. Also, register-service! is a private function and _must_
not be used directly as there is no guarantee that it will be supported
as is in future versions.

-- 
Manuel

Reply via email to