Re: lc() with undefined arg



Tassilo v. Parseval <tassilo.von.parseval@xxxxxxxxxxxxxx> wrote in comp.lang.perl.misc:
> Also sprach ced@xxxxxxxxxxxxxxxxxxxxx:
>
> > Tassilo v. Parseval wrote:

[...]

> But I don't see how the functions mentioned in this thread fall into
> this category. Meanwhile, I found one other builtin that wont warn on
> undef: 'reverse' in scalar context.
>
> What is worse about these cases is the fact that after applying any of
> these functions, the value is no longer undef but the empty string. In a
> context of a program these two values might have a very different
> meaning and silently transforming one into the other is wrong.

That's only a consequence of some functions stringifying their argument,
the same goes for hash keys. I wouldn't worry about it, a programmer
doesn't expect a function like lc to return its argument unchanged. I think
it's just a missing "uninitialized" warning -- add that and reverse and
lc fit right in.

Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
.



Relevant Pages

  • .bottom of TextWidthHeight
    ... Within the With block of "sRect" ... Variable in question: ".Bottom" ... properly calculate the .Bottom variable where the rowsource of a listbox is ... Have the code arbutarily put in a string value that is not an empty string ...
    (microsoft.public.access.formscoding)
  • Re: strange return value
    ... the fact that it's returning an actual empty string is ... but normal behavior for Perl's idea of a boolean. ... "Reply" at the bottom of the article headers. ...
    (comp.lang.perl.misc)
  • Re: /(foo|)/ vs /(foo)?/
    ... > While looking at someone else's code I came across a regular ... // matches an empty string, so $1 is an empty string ... A subtle but relevant difference. ... "Reply" at the bottom of the article headers. ...
    (comp.lang.perl.misc)
  • Re: Use of uninitialized value in substitution (s///)
    ... >> Perl converts the undefined value to an empty string, ... My point is that warning or not, the substitution seems to ... so the purpose of the substitution is attained. ... "Reply" at the bottom of the article headers. ...
    (comp.lang.perl.misc)
  • Re: How to access a multi-dimensional array?
    ... > No need for the scalarhere; @content is already in scalar context: ... render_table(@$_{qw(header type chart)}) for @content; ... "Reply" at the bottom of the article headers. ... Prev by Date: ...
    (comp.lang.perl.misc)