Re: Let me try once more
- Posted by George Henry <ghenryca at LYCOS.COM> Jan 29, 2001
- 526 views
David, That's fine, esp. for those who are interested in implementing their own language. That is not my project of the moment, and please recall that my original complaint was about having to do just that, when the Euphoria interpreter is sitting there anxiously (?) waiting to execute code formulated according to its syntax rules. Also, I am not a Lisp programmer (yet), but I have read a bit about it, and I believe there is quite a bit more to it than your example implies. (Yeah, (it (looks (like (Lisp) but) is) it) really?) Oh, you did say your example was simple. Fair enough. George -- On Mon, 29 Jan 2001 18:30:29 David Cuny wrote: >George Henry wrote: > >> Sounds like I'm pushing Lisp, but all I'm saying >> is, there are perfectly good languages for doing >> what you propose, and unless/until Rob changes his >> mind about executing code-as-data, Euphoria isn't >> one of them. > >Actually, Euphoria is an excellent language to implement a LISP-ish sort of >language in. Here's a simple (untested) example: > > >global constant > LITERAL = 0, > ADD = 1, > PRINT = 2 > >function eval( sequence code ) > > integer op > op = code[1] > > if op = LITERAL then > return code[2] > elsif op = ADD then > return eval( code[2] ) + eval( code[3] ) > elsif op = PRINT then > ? eval( code[2] ) > return 1 > else > printf( 1. "Unknown opcode %d\n", {op} ) > abort(0) > end if > >end function > >And here's a call to the eval function: > > object result > result = eval( { PRINT, { ADD, { LITERAL, 1 }, { LITERAL, 1 } } } > >Looks awfully LISP-ish to me. Replace the if/then/else calls with indexed >calls to call_proc, add a parser on the front of it, and you've got your own >custom programming language. > >That's exactly what I did with Eu and Py. > >-- David Cuny > >____________________________________________________________ >T O P I C A -- Learn More. Surf Less. >Newsletters, Tips and Discussions on Topics You Choose. >http://www.topica.com/partner/tag01 > > Get your small business started at Lycos Small Business at http://www.lycos.com/business/mail.html ____________________________________________________________ T O P I C A -- Learn More. Surf Less. Newsletters, Tips and Discussions on Topics You Choose. http://www.topica.com/partner/tag01