Article View: comp.lang.misc
Article #3371Lisp/C Wars
From: Joseph Allen
Date: Thu, 04 Apr 1991 07:55
Date: Thu, 04 Apr 1991 07:55
51 lines
2309 bytes
2309 bytes
Several points:
EMACS: The easy parts are written in LISP, the hard parts are written in C.
Actually I like the argument about EMACS being written in TECO. EMACS stands
for Editor Macros so I guess it is written in LISP. I.E., LISP is merely a
MACRO language :-)
The "editor engine" part of EMACS is, however, written in C.
(I happen to hate using EMACS although I think the editor engine in it is
pretty amazing)
LISP: Just try to write a terminal screen optimizer in it which is fast enough
to be used in a real editor.
C: This isn't really a high level language, it's portable assembly language.
And it really does have dynamic typing and all that:
/* Graph function user types in... */
top: printf("Type function in terms of variable x: "); gets(buf);
sprintf(buf1,"main(argc,argv)char *argv[];{int x=atof(argv[1]);"
"printf(\"%%f\n\",%s);}",buf);
sprintf(buf2,"echo '%s' >tmp.c;cc tmp.c",buf1);
if(system(buf2))
{ printf("Try again\n");
goto top; }
/* Now graph the function... */
for(x=0.0;x!=1.0;x+=.001)
{
sprintf(buf,"./a.out %f",x);
popen() etc...
}
So what we really need is a "OBJ *compile(char *func)" function in the C
library to compile functions in run-time and then also a
"(*(dynlink(OBJ *)))()" function. Hmm... and maybe an sdb() function...
--
#define h 23 /* Height */ /* jallen@ic.sunysb.edu (129.49.12.74) */
#define w 79 /* Width */
int i,r,b[]={-w,w,1,-1},d,a[w*h];m(p){a[p]=1;while(d=(p>2*w?!a[p-w-w]?1:0:0)|(
p<w*(h-2)?!a[p+w+w]?2:0:0)|(p%w!=w-2?!a[p+2]?4:0:0)|(p%w!=1?!a[p-2]?8:0:0)){do
i=3&(r=(r*57+1))/d;while(!(d&(1<<i)));a[p+b[i]]=1;m(p+2*b[i]);}}main(){r=time(
0L);m(w+1);for(i=0;i%w?0:printf("\n"),i!=w*h;i++)a[i]?printf(" "):printf("#");}
Technical Details
Message-ID:
<1991Apr4.075558.19873@sbcs.sunysb.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!uupsi!cmcl2!sbcs!libserv1.ic.sunysb.edu!jallenShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!uupsi!cmcl2!sbcs!libserv1.ic.sunysb.edu!jallen From: jallen@libserv1.ic.sunysb.edu (Joseph Allen) Newsgroups: comp.lang.misc Subject: Lisp/C Wars Message-ID: <1991Apr4.075558.19873@sbcs.sunysb.edu> Date: 4 Apr 91 07:55:58 GMT Sender: usenet@sbcs.sunysb.edu (Usenet poster) Organization: State University of New York at Stony Brook Lines: 51 Originator: jallen@libserv1.ic.sunysb.edu