What does "first class" mean?
Samuel A. Falvo II
kc5tja at garnet.armored.net
Sat Apr 29 14:11:27 EDT 2000
In article <slrn8gkalp.3bk.neelk at brick.cswv.com>, Neel Krishnaswami wrote:
>In Pascal or C, for example, you can't write a procedure that creates
>a function and returns it to its callers, whereas in Scheme or Python
>this is trivial.
This isn't *strictly* true. The following code, for x86 processors, returns
a function that does nothing:
typedef void NoOp();
NoOp *GenerateNoOpFunction( void )
{
char *buf;
buf = malloc( 2 );
if( buf != NULL )
{
buf[0] = 0x90; /* NOP instruction; for demonstration */
buf[1] = 0xC3; /* RET instruction */
}
return buf;
}
Sorry, I couldn't resist. :-)
Seriously, though, this technique has been used in various graphics drivers,
most often with software-only blit engines (where speed is critical).
They'd basically act as dedicated compilers. Windows 95's stock VGA device
driver does this, if memory serves me correctly.
--
KC5TJA/6, DM13, QRP-L #1447
Samuel A. Falvo II
Oceanside, CA
More information about the Python-list
mailing list