mit-scheme-devel
[Top][All Lists]
Advanced

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

Re: [MIT-Scheme-devel] SUBSTRING and SET-STRING-MAXIMUM-LENGTH!


From: Chris Hanson
Subject: Re: [MIT-Scheme-devel] SUBSTRING and SET-STRING-MAXIMUM-LENGTH!
Date: Sun, 6 Sep 2009 01:01:50 -0700

I suggest starting with EDWIN-SET-STRING-MAXIMUM-LENGTH! in
"edwin/utils.scm".  That solution should be faster in compiled code.
If you look in that file a little further down, you'll see that it's
only used when compiled.

Some variation of this hackery should provide a reasonable solution.

On Sat, Sep 5, 2009 at 10:03 PM, Taylor R Campbell<address@hidden> wrote:
>   Date: Sat, 5 Sep 2009 21:50:24 -0700
>   From: Joe Marshall <address@hidden>
>
>   I just pushed a change that restored everything to the way it was.
>   I'll try to figure out a way to implement string-head! that is portable.
>
> Why do we need something portable?  What's wrong with this?
>
> (define (string-head! string end)
>  (guarantee-string string 'STRING-HEAD!)
>  (guarantee-substring-end-index end
>                                 (string-maximum-length string)
>                                 'STRING-HEAD!)
>  (set-string-maximum-length! string end)
>  ;; SET-STRING-MAXIMUM-LENGTH! has no effect in some implementations
>  ;; of the microcode.  If so, just copy the head.
>  (if (fix:= end (string-maximum-length string))
>      string
>      (%substring string 0 end)))
>




reply via email to

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