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: Alex Shinn
Subject: Re: [Chicken-hackers] substring function and bounds checks
Date: Fri, 8 Feb 2013 11:36:46 +0900

On Fri, Feb 8, 2013 at 10:45 AM, John Cowan <address@hidden> wrote:
Alex Shinn scripsit:

> Can you provide a real-world example where you'd want to use this
> function?

I used to use it all the time in Perl, where it is the normal behavior
of the substr() function, to pull a fixed-width field out of a line of
text without having to worry about short lines.  If the field was at the
end of the line, the result was short;

This is where you have a contradiction - the field is "fixed width"
but the full width is not available, which means you have an invalid
format.

Could you be more specific in your example?  If the goal is to
extract the last field, then you use substr with no end param.
If the goal is to take a fixed field you should be taking that.  If
the format allows either then the format itself is ambiguous, which
means you have a _much_ bigger problem than whatever language
idioms you use.

-- 
Alex


reply via email to

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