Content deleted Content added
→Higher-order functions in Perl: Extra example on Rosetta Code |
C/C== |
||
Line 173:
There is also [http://rosettacode.org/wiki/First-class_functions#Perl this]. --[[User:Paddy3118|Paddy]] ([[User talk:Paddy3118|talk]]) 16:23, 26 September 2009 (UTC)
I disagree with various statements concerning whether or not this is generally available in C - or that it must somehow require specific hardware. Consider the following:
<code>
// imports first_class dll.
#include <first_class.h>
class dll_data;
class first_class;
main (char* args)
{
dll_data *dll_data = new dll_data (int N, args);
char *new_c_source;
bool quit = false;
while (!quit)
{
first_class::load_dll ();
quit = first_class::run (dll_data);
new_c_source = dll_data->new_source;
first_class::unload_dll ();
if (new_c_source!=NULL)
first_class::recomplie_dll (dll_data->new_source);
}
}
</code>
Windows actually has a "LoadModule" function (I think) that allows you to load dlls when you want them or need them, allowing you to do things like have one version of a program that can use different DLL's according to different OS, or whatever. These can then be loaded during execution rather then when the program first starts up (automatically) and thus avoiding the dreaded "required DLL not found error". The process can even be applied recursively, so that DLL's which have various complicated and interacting dependencies can be linked in and out, etc. In my simple example I am suggesting a kind of persistent data block type (which could also be modified if needed by using placement new, casting to a void pointer, and/or realloc as needed).
Then there is the issue of "Active X" and so on. I'm not sure how you would do this in Linux, although I am aware that Linux/Uxix variants to support some kind of _popen (char *filename -- etc) method which allows an application to create a new process and communicate with it via a named pipe and thus incur no more essential performance penalty other than whatever mighg be associated with named pipes. Lots of things could be dynamically modified this way -- such as MPEG encoders, database engines, etc. The pipes in such cases can be used for streaming the otherwise computationally intensive data -- even to the point that it becomes imaginable to create applications that could be run for months or even years (I have seen Linux boxes with uptime over 1 year)
|