* srfi-13 string-any tail call
@ 2004-12-06 21:08 Kevin Ryde
2004-12-22 16:54 ` Marius Vollmer
0 siblings, 1 reply; 4+ messages in thread
From: Kevin Ryde @ 2004-12-06 21:08 UTC (permalink / raw)
I'm thinking of the following wrapper around the string-any C code to
get a tail call on the last pred test, per the srfi-13 spec. It's not
too pretty, but at least it'll be right. I guess in the head it could
tie into eval now that string-any is in the core.
(define (string-any char_pred s . rest)
(let ((start (if (null? rest)
0 (car rest)))
(end (if (or (null? rest) (null? (cdr rest)))
(string-length s) (cadr rest))))
(if (and (procedure? char_pred)
(> end start)
(<= end (string-length s))) ;; let c-code handle range
error
(or (string-any-c-code char_pred s start (1- end))
(char_pred (string-ref s (1- end))))
(string-any-c-code char_pred s start end))))
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: srfi-13 string-any tail call
2004-12-06 21:08 srfi-13 string-any tail call Kevin Ryde
@ 2004-12-22 16:54 ` Marius Vollmer
2004-12-22 21:30 ` Kevin Ryde
0 siblings, 1 reply; 4+ messages in thread
From: Marius Vollmer @ 2004-12-22 16:54 UTC (permalink / raw)
Kevin Ryde <user42@zip.com.au> writes:
> I guess in the head it could tie into eval now that string-any is in
> the core.
Yes. It would be nice in general to have a new kind of 'trampoline'
subr that returns a function+args to call in a tail-recursive way.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: srfi-13 string-any tail call
2004-12-22 16:54 ` Marius Vollmer
@ 2004-12-22 21:30 ` Kevin Ryde
2004-12-23 4:16 ` Marius Vollmer
0 siblings, 1 reply; 4+ messages in thread
From: Kevin Ryde @ 2004-12-22 21:30 UTC (permalink / raw)
Cc: guile-devel
Marius Vollmer <marius.vollmer@uni-dortmund.de> writes:
>
> Yes. It would be nice in general to have a new kind of 'trampoline'
> subr that returns a function+args to call in a tail-recursive way.
Or func+args in some new magic type, so a subr can return either a
value or a new place to goto.
I was wanting `catch' to do a tail call to its handler so the handler
could recurse to continue on the rest of some data. `catch' would be
a case of either returning a value (from the body) or the handler to
jump to.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: srfi-13 string-any tail call
2004-12-22 21:30 ` Kevin Ryde
@ 2004-12-23 4:16 ` Marius Vollmer
0 siblings, 0 replies; 4+ messages in thread
From: Marius Vollmer @ 2004-12-23 4:16 UTC (permalink / raw)
Kevin Ryde <user42@zip.com.au> writes:
> Marius Vollmer <marius.vollmer@uni-dortmund.de> writes:
> >
> > Yes. It would be nice in general to have a new kind of 'trampoline'
> > subr that returns a function+args to call in a tail-recursive way.
>
> Or func+args in some new magic type, so a subr can return either a
> value or a new place to goto.
Hmm, a value can be returned by using 'identity' as the function to
tail-call, but which method is more efficient is probably hard to say.
> I was wanting `catch' to do a tail call to its handler so the handler
> could recurse to continue on the rest of some data.
That would be very nice.
--
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-12-23 4:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-12-06 21:08 srfi-13 string-any tail call Kevin Ryde
2004-12-22 16:54 ` Marius Vollmer
2004-12-22 21:30 ` Kevin Ryde
2004-12-23 4:16 ` Marius Vollmer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).