chicken-hackers
[Top][All Lists]
Advanced

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

Re: [Chicken-hackers] substring function and bounds checks


From: Michele La Monaca
Subject: Re: [Chicken-hackers] substring function and bounds checks
Date: Fri, 8 Feb 2013 02:14:45 +0100

How strange, I thought no one was interested in the discussion.
Anyway, with John's permission just a few inline clarifications.

On Thu, Feb 7, 2013 at 11:59 PM, Alex Shinn <address@hidden> wrote:
>
> [...]
> You didn't use it just to simplify, because the task
> you described in English was "give me at most N chars."

http://lists.nongnu.org/archive/html/chicken-hackers/2013-02/msg00058.html

"give me at most N chars starting from a certain position in the string"

Ok, in another mail I gave a shortened version but, well, I think the
context was clear.

> This is a common task, and always has a START of 0.

What? what? what?

> There may be cases in Python where you first want to
> take the substring from START to the end of the string,
> and then want to truncate the result to END-START chars.
> This becomes an idiom in Python, so it seems natural to

Sorry, never used Python in my life. I used it as an example because I
think it's a commonly known language. Not by me, unfortunately, so I
don't believe I completely understand what you are trying to say.

> you, but there is always a specific reason you want to
> truncate separate from the substring you are taking.
>
> In Scheme this becomes
>
>   (string-truncate (string-copy str start) max-len)
>
> You could combine these two functions
>
>   (slice str start (- max-len start))
>
> but this hides what you're actually doing

Don't think so. Really don't think so.

> and likely not as
> common, so is probably a bad idiom in Scheme.  It doesn't
> make sense to provide such artificially combined functions.

Again (last time I promise), I don't think that:

"starting from a certain position give me at most N chars"

or

"starting from a certain position give me chars up to the Nth position
or up to the end of the string whatever the first"

are "artificially combined functions". They are exactly what they mean.

Anyway, I think I had enough of that. I respect your opinions, please
try to respect mine and let's stop this discussion.

Regards,
Michele



reply via email to

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