align substring and list-copy with similar functions with start and end arguments #206

Open
opened 2024-09-27 17:43:51 +00:00 by ecraven · 6 comments

All the other subcollection-accessors (string-copy, vector-copy, bytevector-copy, and so on) take three forms:

(copy object)
(copy object start)
(copy object start end)

I propose that substring be amended to also support this usage, so either the last argument or both can be left off.

All the other subcollection-accessors (`string-copy`, `vector-copy`, `bytevector-copy`, and so on) take three forms: ``` (copy object) (copy object start) (copy object start end) ``` I propose that `substring` be amended to also support this usage, so either the last argument or both can be left off.

Agreed.

Agreed.
dpk added the
Foundations
label 2024-09-27 17:52:04 +00:00
dpk added this to the Valued Fascicle milestone 2024-09-27 17:52:08 +00:00
Owner

substring can become a binding alias of string-copy without issue.

`substring` can become a binding alias of `string-copy` without issue.
Author

note that I don't mention list-copy here. abstractly, it might be fine to give it start and end too, but I think – given there's no efficient implementation for that – that's probably not a good idea ;)

note that I *don't* mention `list-copy` here. abstractly, it might be fine to give it `start` and `end` too, but I think – given there's no efficient implementation for that – that's probably not a good idea ;)
Owner

note that I don't mention list-copy here. abstractly, it might be fine to give it start and end too, but I think – given there's no efficient implementation for that – that's probably not a good idea ;)

It is as efficient as list-copy without start and end.

> note that I *don't* mention `list-copy` here. abstractly, it might be fine to give it `start` and `end` too, but I think – given there's no efficient implementation for that – that's probably not a good idea ;) It is as efficient as `list-copy` without `start` and `end`.
Owner

It is as efficient as list-copy without start and end.

Yes. There are times when you need it, and for short lists, the performance will be immaterial in many situations. We should include it.

> It is as efficient as `list-copy` without `start` and `end`. Yes. There are times when you need it, and for short lists, the performance will be immaterial in many situations. We should include it.
dpk changed title from [feature request] align substring with all other similar functions by making the start and end argument optional. to align substring and list-copy with similar functions with start and end arguments 2024-09-27 18:18:36 +00:00

The one-argument version will make less sense if “newly allocated” is ever dropped from the spec, but the (substring string start) version will always be nice to have.

The one-argument version will make less sense if “newly allocated” is ever dropped from the spec, but the `(substring string start)` version will always be nice to have.
dpk added the
Cleanup
label 2024-09-27 21:36:20 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
5 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: scheme/r7rs#206
No description provided.