In comp.lang.javascript message <fjp9hl$sku$1$830fa7a5@news.demon.co.uk>
, Wed, 12 Dec 2007 18:33:31, Richard Cornford
<Richard@litotes.demon.co.ukposted:
Quote:
>Dr J R Stockton wrote:
Quote:
>Take a general user-defined function F.
>>
>In IE4 & 6 (& IIRC 7), F.toString() gives the function as
>written, with the original comment and whitespace.
>>
>In FireFox 2 and Opera 9, F.toString() apparently regenerates
>the function from a quasi-tokenised form, both losing comment
>and inserting new whitespace; the whitespacing is similar but
>not the same.
>
>And (in the aspects stated) both fully comply with the specification,
>which explicitly states that white space in the representation of the
>function is implementation dependant.
.... -dependent, to be exact. It says more than that explicitly; but it
leaves the combining of string literals implicitly allowed. I was aware
of 16262 15.3.4.2.
Quote:
Quote:
>Are there any other systems in which the behaviour of F.toString()
>is significantly different from both the IE type and the FF/O
>type? If so, which, and what do they do?
>
>In all Opera versions before 7, if a string included a regular
>expression literal that literal would be represented in the function's
>- toString - output as "[object]".
I can live with that. There can't be many users of Opera<7 left.
Quote:
That was (arguably, but probably) a bug, but it does illustrate the
>problems with assuming too much from of the - toString - method of
>functions, and one of the dangers in trying to take a function's -
>toString - output and - eval - it back into a function object.
I've no (present) intention of doing that. Thanks.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk DOS 3.3, 6.20 ; WinXP.
Web <URL:http://www.merlyn.demon.co.uk/- FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm- also batprogs.htm.