Closure is not a pair.
* module/mes/base.mes (closure_p, mes_car, mes_cdr): New function. (pair_p): Closure is not a pair. * NEWS: Mention it. * psyntax-0.mes (self-evaluating?): Add closure?.
This commit is contained in:
parent
c93096fe5f
commit
2390d46a63
2
NEWS
2
NEWS
|
@ -22,6 +22,8 @@ block-comments are all handled by the Scheme reader later.
|
|||
*** Lambda* and define* are now supported.
|
||||
*** #;-comment is now supported.
|
||||
*** Non-nested #| |#-comment is now supported.
|
||||
** Noteworthy bug fixes
|
||||
*** Closure is not a pair.
|
||||
* Changes in 0.3 since 0.2
|
||||
** Core
|
||||
*** Number-based rather than pointer-based cells.
|
||||
|
|
|
@ -59,5 +59,5 @@
|
|||
(define (procedure? p)
|
||||
(cond ((builtin? p) #t)
|
||||
((and (pair? p) (eq? (car p) 'lambda)))
|
||||
((and (pair? p) (eq? (car p) '*closure*)))
|
||||
((closure? p) #t)
|
||||
(#t #f)))
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
(define annotation? (lambda (x) #f))
|
||||
(define (self-evaluating? x)
|
||||
(or (boolean? x) (number? x) (string? x) (char? x) (null? x)))
|
||||
(or (boolean? x) (number? x) (string? x) (char? x) (null? x) (closure? x)))
|
||||
|
||||
(define (void) (if #f #f))
|
||||
|
||||
|
|
|
@ -95,4 +95,10 @@ exit $?
|
|||
"noexpand")
|
||||
(pass-if "closure 9" (sc-expand))))
|
||||
|
||||
(pass-if "closure is procedure"
|
||||
(procedure? (lambda () #t)))
|
||||
|
||||
(pass-if-not "closure is not a pair"
|
||||
(pair? (lambda () #t)))
|
||||
|
||||
(result 'report)
|
||||
|
|
20
type.c
20
type.c
|
@ -26,6 +26,24 @@ char_p (SCM x)
|
|||
return TYPE (x) == CHAR ? cell_t : cell_f;
|
||||
}
|
||||
|
||||
SCM
|
||||
closure_p (SCM x)
|
||||
{
|
||||
return (TYPE (x) == PAIR && CAR (x) == cell_closure) ? cell_t : cell_f;
|
||||
}
|
||||
|
||||
SCM
|
||||
mes_car (SCM x)
|
||||
{
|
||||
return CAR (x);
|
||||
}
|
||||
|
||||
SCM
|
||||
mes_cdr (SCM x)
|
||||
{
|
||||
return CDR (x);
|
||||
}
|
||||
|
||||
SCM
|
||||
keyword_p (SCM x)
|
||||
{
|
||||
|
@ -47,7 +65,7 @@ number_p (SCM x)
|
|||
SCM
|
||||
pair_p (SCM x)
|
||||
{
|
||||
return TYPE (x) == PAIR ? cell_t : cell_f;
|
||||
return (TYPE (x) == PAIR && CAR (x) != cell_closure) ? cell_t : cell_f;
|
||||
}
|
||||
|
||||
SCM
|
||||
|
|
Loading…
Reference in a new issue