Ok, I'm sure that subject is confusing, but I noticed the following
curious code on the main page of the "Vitamin" web developer's page
<http://www.thinkvitami n.com/>:
<script type="text/javascript">
//<![CDATA[
(function(id) {
document.write( '<script type="text/javascript" src="' +
'http://www.northmay.co m/deck/deck' + id + '_js.php?' +
(new Date().getTime( )) + '"></' + 'script>');
})("VM");
//]]>
</script>
The key thing I noticed is that this is defining an inline function,
and calling it immediately. This is a very curious technique. I
could almost see doing this if you had several repeated strings you
wanted to substitute, but this example only uses the func parameter
once.
Otherwise, what is the point of doing it this way? 2 1381
On Apr 12, 10:35 pm, "david.karr " <davidmichaelk. ..@gmail.comwro te:
Ok, I'm sure that subject is confusing, but I noticed the following
curious code on the main page of the "Vitamin" web developer's page
<http://www.thinkvitami n.com/>:
<script type="text/javascript">
//<![CDATA[
(function(id) {
document.write( '<script type="text/javascript" src="' +
'http://www.northmay.co m/deck/deck'+ id + '_js.php?' +
(new Date().getTime( )) + '"></' + 'script>');
})("VM");
//]]>
</script>
The key thing I noticed is that this is defining an inline function,
and calling it immediately. This is a very curious technique. I
could almost see doing this if you had several repeated strings you
wanted to substitute, but this example only uses the func parameter
once.
Otherwise, what is the point of doing it this way?
In the particular case you have posted it is nothing but a "show up
case". The author either wanted to show someone how cool he is or -
most probably - he was feeling himself cooler by doing that. How
strange it might be, the latter reason always had a great impact on
coding practice trends - the "squeeze crypt" has the same roots btw.
Overall a function declaration wrapped into expression has some useful
applications. JScript and JavaScript are treating them a bit
differently, but for anonymous function such difference is not very
important.
"david.karr " <da************ **@gmail.comwri tes:
Ok, I'm sure that subject is confusing, but I noticed the following
curious code on the main page of the "Vitamin" web developer's page
<http://www.thinkvitami n.com/>:
<script type="text/javascript">
//<![CDATA[
CDATA? That suggests that this is an XHTML document ....
(function(id) {
document.write( '<script type="text/javascript" src="' +
.... but document.write generally doesn't work for properly parsed
XHTML documents.
'http://www.northmay.co m/deck/deck' + id + '_js.php?' +
(new Date().getTime( )) + '"></' + 'script>');
And here the string is split into two after the "</", where it
should, according to the HTML specification, have been split
between those two, i.e., '"><' + '/script>'.
})("VM");
//]]>
</script>
The key thing I noticed is that this is defining an inline function,
and calling it immediately. This is a very curious technique. I
could almost see doing this if you had several repeated strings you
wanted to substitute, but this example only uses the func parameter
once.
That is the typical use. That, and creating local variables without
poluting the global namespace.
I don't believe there is any idea to this. It's probably just someone
who have inlined a function declaration, or code generated by a
server-side script that is prepared to be more general.
Otherwise, what is the point of doing it this way?
None, in this case.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.' This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Senthilraja |
last post by:
I have the following program using templates. Someone please let me know
the syntax to be used for defining the member functions push, pop etc.
as non-inline functions.
#include <iostream>
using namespace std;
template<class T, int size = 50>
class Stack
{
|
by: Chris Mantoulidis |
last post by:
I am not clear with the use of the keyword inline... I believe you add
it do a function when you implement the function inside the header
file where the class is stored...
But is that all? What am I missing?
If that's all, then why did Bjarne even bother adding it to the
language?
If that's not all, what else can I do with "inline"?
|
by: Richard Hayden |
last post by:
Hi,
I have the following code:
/******************************** file1.c
#include <iostream>
extern void dummy();
inline int testfunc() {
|
by: Patrick Laurent |
last post by:
Hello
I have a program with many many inlined template functions
It is essential for the execution speed that every (or almost every)
function marked as inlined, becomes really inlined by the compiler.
I already compiled the program with Intel Compiler (ICL) on Visual C++, and
it works fine and fast. I verified that the functions are really inlined.
But with GCC 3.4 (Linux+Cygwin) or ICC (Linux), The same program is about 5
|
by: junky_fellow |
last post by:
What is an inline function ?
When should we declare a particular function as inline ?
If a function is declared to be inline, does that mean
that the entire code for that function is subtituted there
just like macros ? Then why not use macros ?
| |
by: Wu Shaohua |
last post by:
Hi Guys,
1. As we know usually we should not define a constructor as inline. I also
learned if we define a member function inside the class this member function
will be automatically be inline'ed. My question is:
If I define a constructor (including its body) or another large member
function inside the class, the constructor or the member function is inline
or not? why?
2. I learned that if the member function is big we should not...
|
by: Amal P |
last post by:
Hi,
This is the program that i made to test the usage of inline
function. I am using vc 6.0 compiler. Please see the below program.
int NonInline( int a, int b )
{
return ( a b )? a: b;
}
|
by: jg |
last post by:
Does C++ standard require an inline function be generated all the
time ?
For example,
#include <iostream>
using namespace std;
inline int foo()
{
|
by: lucifer |
last post by:
Hi
I have a little problem regarding inline functions ,does declaring a
function inside the class definition make it inline or not.
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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 we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |