Skip to main content

First-class object



Is the on which can dynamically be created, destroyed at runtime during the execution of program,and pass as an argument to other functions. In some languages like javascript and python functions are also first class objects.


Ex. Passing function as an argument in Python:


          >>> def op(a,b,fun):
            return fun(a,b)


    >>> def sum(a,b):
            return a+b


    >>> op(1,2,sum)
    3



Ex. Dynamically defined function in javascript:


var supriseMe = function () {

alert("Boo!");

supriseMe = function () {
alert(" boooooooo!");
};
};
// using the self-defining function
supriseMe(); // Boo!
supriseMe(); // boooooboo!

Comments

Popular posts from this blog

Installing MS SQL Server driver on Ubuntu Linux

Although making a connection to SQL Server can be done using unixODBC and FreeTDS, it does not work with some collations on SQL Server 2008. Recently, Microsoft released an ODBC driver for Linux that works on 64-bit systems only. Installing the driver is tricky. I begin by installing the build-essential, which is required for compiling from source. Checkinstall can be installed if you want to add the following application to the package manager. $ sudo apt-get install build-essential  Download unixODBC-2.3.0  and Microsoft ODBC dirver  and extract. $ sudo wget ftp://ftp.unixodbc.org/pub/unixODBC/unixODBC-2.3.0.tar.gz $ tar xvf unixODBC-2.3.0.tar.gz $ wget http://download.microsoft.com/download/6/A/B/6AB27E13-46AE-4CE9-AFFD-406367CADC1D/Linux6/sqlncli-11.0.1790.0.tar.gz $ tar xvf sqlncli-11.0.1790.0.tar.gz  Install the unixodbc using the following commands: $ ./configure --disable-gui --disable-drivers --enable-iconv --with-iconv-char-enc=UTF8 --with-ico...

Installing pyodbc on ubuntu

Installing pyodbc is straight forward but if  getting     "error: command 'gcc' failed with exit status 1"  when installing pyodbc, make sure you have installed  requirements  as below. sudo apt-get install unixODBC-dev g++ pip install pyodbc

Installing Django on IIS 7 Using PyISAPIe

PyISAPIe is an ISAPI extension which can be downlod from here . Download the latest extension according to installed python version. Just make sure that ISAPI and ISAPI filters has been installed on IIS (During IIS installation these two component should have checked). Copy PyISAPIe.dll file and Http folder into your Django website project.Example: Suppose your website folder path is: "C:\Python25\Lib\site-packages\MySite" "C:\Python25\Lib\site-packages\MySite\PyISAPIe.dll" and "C:\Python25\Lib\site-packages\MySite\Http" will be the result. Copy and replace the isap.py from "PyISAPIe\Examples\Django" folder to "C:\Python25\Lib\site-packages\MySite\Http" IIS need to have access to your project folder and also django folder. so you need to give access "Network Service" to these folder. Right click on site folder "C:\Python25\Lib\site-packages\MySite"  click on properties. On properties window choose the sec...