473,497 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

function.toString()

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.

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?

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/&c., FAQqy topics & links;
<URL:http://www.merlyn.demon.co.uk/clpb-faq.txt RAH Prins : c.l.p.b mFAQ;
<URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zipTimo Salmi's Turbo Pascal FAQ.
Dec 10 '07 #1
4 2662
On Dec 10, 5:42 pm, Dr J R Stockton <j...@merlyn.demon.co.ukwrote:
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.
Yes. I ran into this with some debugging code that inspects functions
and it is quite annoying.
>
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?
I haven't ran into any. Like most things, this seems to be IE vs.
everything else. In this rare case, I prefer IE's implementation.
Dec 11 '07 #2
In comp.lang.javascript message <41fc8017-a659-4d15-86f4-4117973b2f33@d2
1g2000prf.googlegroups.com>, Tue, 11 Dec 2007 02:54:24, David Mark
<dm***********@gmail.composted:
>On Dec 10, 5:42 pm, Dr J R Stockton <j...@merlyn.demon.co.ukwrote:
>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.

Yes. I ran into this with some debugging code that inspects functions
and it is quite annoying.
>>
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?

I haven't ran into any. Like most things, this seems to be IE vs.
everything else. In this rare case, I prefer IE's implementation.

So do I, as you will no doubt have realised if you have looked at my
site. OTOH, ISTM that it would be good if function.toString() took
an optional Boolean argument LayItOutAgain with parameter absent
maybe meaning "as previous call".

I'll keep using !/\*/.test(function(){/**/}) .

--
(c) John Stockton, Surrey, UK. replyYYWW merlyn demon co uk Turnpike 6.05.
Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html-Timo Salmi: Usenet Q&A.
Web <URL:http://www.merlyn.demon.co.uk/news-use.htm: about usage of News.
No Encoding. Quotes precede replies. Snip well. Write clearly. Mail no News.
Dec 11 '07 #3
Dr J R Stockton wrote:
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.
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]". 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.

Richard.

Dec 12 '07 #4
In comp.lang.javascript message <fj*******************@news.demon.co.uk>
, Wed, 12 Dec 2007 18:33:31, Richard Cornford
<Ri*****@litotes.demon.co.ukposted:
>Dr J R Stockton wrote:
>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.
>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.
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.
Dec 12 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2474
by: D. Shane Fowlkes | last post by:
Here's a good one. I've been using an Excel spreadsheet for the past couple of years to calculate a file's Estimated Download Time based off of a solid 50kbs connection (dial up). This is for a...
5
16875
by: Masahiro Ito | last post by:
I have column of data that have elapsed time in minutes. For example: 1:15 1:47 23:12 I like to be able to use sql server to do simple math functions. Does anyone have a simple...
4
7673
by: Paul | last post by:
Anyone have code that emulates the Nz function in Microsoft Access? In Access it is: Nz(Value as variant, Optional ValueIfNull as Variant) as Variant
4
1772
by: ali | last post by:
Hi, I'm have a base class with a virual function toString. All the derived classes will have to implement this function. Here's the code I have used: //in base.h virtual string* toString();
5
1599
by: chris | last post by:
Guys, I have the following piece of code. Could you please help me understand why b.ToString( ) cannot be called while b.foo( ) can? When I compile I get (gcc, but visual studio gives the same...
32
3465
by: David Mark | last post by:
I've got a collection of functions that accept a function or object (paired with a method name) as a callback. For the longest time I have relied on this test. (typeof cb == 'function') ...
9
4195
by: baibaichen | last post by:
hi our internal log apis support varargs, but do not support <<, it means that we have to write funciton tracing like this: printf("%s(%d,%f)", functionName,iCount,dTime); this need us...
3
1202
by: Michelle Monty | last post by:
I'm creating an application where a user creates a cable bill. The application calculates the bill based on whether the customer is a residential or business customer. I've finished the interface...
0
7120
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7160
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7196
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6878
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7373
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4583
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1405
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
649
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.