chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] difference between ##sys#error and posix-error?


From: Christian Kellermann
Subject: Re: [Chicken-users] difference between ##sys#error and posix-error?
Date: Thu, 29 Sep 2011 09:36:05 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

Hi Alan!

* Alan Post <address@hidden> [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. 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]