This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: string-append/shared


Chris Dean wrote:

How about the patch below?  We add a few new methods to FString and
implement string_append.java and string_append_shared.java in terms of
the new functions.

This is good, but I'm trying to reduce the number of classes in kawa/standard. At least when you can conveniently express the same algorithm in Scheme with similar performance, then I prefer to use code in kawa/lib or gnu/kawa/slib.

In this case the string-append and string-append-shared should be
in kawa/lib/strings.scm:

(define (string-append #!rest (args :: <Object[]>)) :: <string>
  (let ((str :: <string> (make <string>)))
     (invoke str 'addAllStrings args)
     str)))

For the shared version we might consider:

(define (string-append/shared (arg1 :: <string>) (args :: <Object[]>)) :: <string>
(invoke arg1 'addAllStrings args)
arg1))


However, that requires at least one argument, and the specification is
unclear whether it is allowed to call string-append/shared with no
arguments.  (It doesn't make sense unless you view /shared as an
optimization hint - which I guess it is.)  So perhaps transcribing
your Java version in string_append_shared to Scheme would be best.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]