Re: [Scheme-reports] vector-insert
Vassil Nikolov 22 Aug 2014 20:54 UTC
On Fri, 22 Aug 2014 14:37:47 -0400, John Cowan <cowan@mercury.ccil.org> said:
> Vassil Nikolov scripsit:
>> Is it thinkable here to advise the user
>> simply to call `vector-append' and rely
>> on an optimizing compiler to avoid
>> unnecessary copying of the subvectors
>> that are apparently constructed afresh
>> just to be thrown away almost
>> immediately?
> If you like, certainly. But SRFI 43 (and
> R7RS-small, which incorporate parts of
> it) have lots of "start end" argument
> pairs precisely to avoid the need for
> such optimization.
Quite so, and these are very useful
indeed, but this approach (sometimes)
involves its own trade-offs. For
example, if we are content with a
two-argument append (concatenate)
operation, it is (reasonably) easy to add
optional parameters start1, end1, start2,
and end2. If, however, we insist on
being able to append an arbitrary number
of arguments in a single call, I don't
know if either of the following is
obviously better than the other: to
complicate [*] or proliferate the
interfaces, or to pass the buck on to the
compiler.
To a large degree, this is a matter of
language design style (or "philosophy").
_________
[*] If we wish to be able to use the
append operation easily with a reduce
(fold) operation, say, that would
constraint the interface of the
append operation with regards e.g. to
additional parameters such as
start-end pars.
> The alternative would be shared
> subvectors, but that would need to be a
> primitive capability.
True, and a different kettle of fish,
with its own usefulness and cost. I
would argue that such a feature should be
considered independently of
("orthogonally to") the others.
---Vassil.
--
Vassil Nikolov | Васил Николов | <vnikolov@pobox.com>
"Be careful how you fix what you don't understand." (Brooks 2010, 185)
_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports