Hi Alan!

* Alan Post <alanp...@sunflowerriver.org> [110929 05:51]:
> Looking at posixunix.scm, I find that some error messages are
> produced with ##sys#error, and others with posix-error.  What
> distinguishes these two routines?  Why would I use one but not
> the other?

(define posix-error
  (let ([strerror (foreign-lambda c-string "strerror" int)]
        [string-append string-append] )
    (lambda (type loc msg . args)
      (let ([rn (##sys#update-errno)])
        (apply ##sys#signal-hook type loc (string-append msg " - " (strerror 
rn)) args) ) ) ) )

(define ##sys#posix-error posix-error)

whereas ##sys#error just calles the À##sys#signal-hook

(define (##sys#error . args)
  (if (pair? args)
      (apply ##sys#signal-hook #:error args)
      (##sys#signal-hook #:error #f)))

So the former is a specialised convenience procedure that will add
a textual presentation of errno for you, whereas the latter is the
more general variant that hands your args to the ##sys#signal-hook.

Does this make sense for you?

Kind regards,

Christian

-- 
Who can (make) the muddy water (clear)? Let it be still, and it will
gradually become clear. Who can secure the condition of rest? Let
movement go on, and the condition of rest will gradually arise.
 -- Lao Tse. 

_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to