Just a note..... I was talking generally about the different
approaches you might take to decide how deal with any situation to
make the decision. Not that split function or CFMX behaviour. I
could have been clearer about that.
Gary
[PS - but it was 6am after having had only 4 hours sleep after the
staff Christmas Party - *smile*.]
On Sat, 4 Dec 2004 13:54:24 +1300, Adam Cameron <[EMAIL PROTECTED]> wrote:
>
>
> >Personally, I would return an empty array, with one empty element, the
> rationale being:
> >...
> >shouldnt the behaviour be the same? (not that cold fusion agrees with this
> rationale...)
>
> With these things, I always try to mirror as closely as possible CF's
> behaviour (whether the behaviour makes sense or not). So I'd return
> arrayNew(). My rationale here is that CF has set a precendent, and it's
> more predictable if custom functions follow CF's lead.
>
> (Obviously CF's precedent when it comes to lists is an annoyingly daft one,
> butâ oh well).
>
>
> 1. IF an empty string was an invalid input (i.e. you just should NOT be
> having an empty string at that point) - you should check for it in the
> function and throw the error
>
> I think that's dangerous ground there. Generally, if a zero-length string
> is inappropriate "at that stage", it should be tested for by the calling
> code, and the function should not be called at all. It is not the business
> of a split() function (in this example) to decide that a zero-length string
> is inappropriate. I think it's much rarer for a zero-length string to be a
> completely unacceptable value for a string argument.
>
> I note that in CF, this fails:
> REReplace('test string','','foo')
> However in JS, the equivalent passes:
> s1 = "test string";
> S2 = s1.replace("", "foo");
>
> I agree with JS.
>
> CF doesn't seem to automatically fail many of its string functions on
> zero-length strings.
>
> But, yeah, your point stands that there's no hard-and-fast rule with these
> things.
> --
>
> Adam Cameron
> Senior Developer
> Straker Interactive
>
> e: [EMAIL PROTECTED]
> t: +64 9 3095252
> f: +64 9 3092797
> w: www.straker.co.nz
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at
[EMAIL PROTECTED]