chicken-hackers
[Top][All Lists]
Advanced

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

Re: [Chicken-hackers] specialization


From: Felix
Subject: Re: [Chicken-hackers] specialization
Date: Mon, 08 Aug 2011 11:25:08 +0200 (CEST)

> Does this (or will this someday) generalize to user types like SRFI-9 
> records, so we can ditch most uses of record-variants?

Do you mean in terms of runtime checks? In the moment it doesn't, but one could 
add the appropriate declarations (or the macro expansion could - I have to
put more thought into that). There is always the case that global redefinitions
might break assumptions, like:

(define-record-type foo (make-foo ...) ...)

...

(set! make-foo 
  (let ((make-foo make-foo))
    (lambda ...)))

To be on the safe side, the compiler must be conservative about such 
possibilities.
One way to address this would be to add interprocedural analysis or a special
"static" mode. But I'm not sure.

> 
> Also, is the ##sys#check-* idiom still valid or do we need to rewrite it to a 
> conditional?  I.e. is this string-append optimized:

I'm not sure what "valid" means here. The "##sys#check-" procedures
are efficient and do not generate CPS calls and they generate
consistent error messages. 

> 
> (##sys#check-string x)
> (string-append x "foo")
> 
> or must we write:
> 
> (if (string? x)
>     (string-append x "foo")
>     (error "not a string"))
> 
> and in fact does this get optimized too:
> 
> (unless (string? x)
>   (error "not a string"))
> (string-append x "foo")
> 
> If I understand correctly it looks like any of the above will work.

In all cases "x" will be inferred to be of type string.


cheers,
felix



reply via email to

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