Newsgroups: comp.lang.misc,gnu.misc.discuss,comp.lang.scheme,comp.lang.tcl,comp.lang.perl
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!udel!darwin.sura.net!news.sesqui.net!uuneo.neosoft.com!nmtigw!peter
From: peter@nmti.com (Peter da Silva)
Subject: Metalanguages in environments where code is data.
	Re: GNU Script isn't fixing something that's broken, so is doomed
Message-ID: <id.QQFE1.XIE@nmti.com>
Sender: peter@nmti.com (peter da silva)
Organization: Network/development platform support, NMTI
References: <394kll$kso@csnews.cs.Colorado.EDU> <PREECE.94Nov3090625@predator.urbana.mcd.mot.com> <id.IWEE1.A3H@nmti.com> <39bo03$d4e@csnews.cs.colorado.edu>
Date: Fri, 4 Nov 1994 15:18:52 GMT
Lines: 83
Xref: glinda.oz.cs.cmu.edu comp.lang.misc:18727 gnu.misc.discuss:19423 comp.lang.scheme:10924 comp.lang.tcl:21342 comp.lang.perl:37970

In article <39bo03$d4e@csnews.cs.colorado.edu>,
Tom Christiansen  <tchrist@mox.perl.com> wrote:
> :-> In gnu.misc.discuss, peter@nmti.com (Peter da Silva) writes:
> :It has the same problem as AREXX and Python, in that it's a procedural
> :and algebraic language, 

> For some things, that's just fine.   I'm suppose that you think their
> opposite must be the soi-disant data-driven or object-oriented programming
> styles.

I'm not talking about coding styles at all. I'm talking about a basic
capability common to all Lisp-derived languages that there's no syntactic
distinction between code and data. This makes it *easy* to define a
metalanguage that's declarative, or embedded, or object-oriented, or
what have you. You bring up the example of makefiles... converting a
Makefile to Tcl (I'll use Tcl instead of Lisp or Scheme because I'm
rusty in Lisp) is a simple mechanical *local* translation:

	CFLAGS=-O -g
	OBJS=main.o frob.o
	LIBS=-lreadline

	frob: $(OBJS)
		$(CC) $(CFLAGS) $(OBJS) -o frob $(LIBS)

Becomes:

	source makefile.tcl

	set CFLAGS "-O -g"
	set OBJS "main.o frob.o"
	set LIBS "-lreadline"

	rule frob "${OBJS}" {
		shell "${CC} ${CFLAGS} ${OBJS} -o frob ${LIBS}"
	}

	make

I doubt that a clean Scheme version would be much, if any, more complex.
As you can see, the resulting Tcl makefile is just as readable and
maintainable as the original. Why look, Tcl is now a declarative language!
Nope... but the metalanguage put together from this subset of Tcl *is*.
What was your other example? Oh, an embedded language. OK... here's how
I'd do that:

	source runoff.tcl
	runoff {
	Here you can have your running text,
	isolated from the rest of the world,
	safely quoted,
	with embedded Tcl commands like [exec date]
	handily sucked into the code,
	with no effort expended whatsoever.
	I know this is little harder in lisp itself
	because I used a similar technique
	in an adventure program back in 1979 or 1980,
	in Lisp 1.5
	on the PDP-11.
	}
	flush

In Perl you'd have to define some new encapsulation method for the procedural
fragments associated with each rule of the makefile. Probably using HERE
documents, I guess. You'd have to write some sort of parser for the running
text. You're no longer using the SAME language in each place, and you're
putting a lot more demands on the new language designer that the designer of
a metalanguage doesn't have.

I'm interested in the Perl way of getting something like the same result,
though, so I'm feeding this back to comp.lang.perl.

PS:
  Tom, if you're going to post something to the net and send me mail, let me
  know so I can ignore your mail instead of having to reply to it twice? Like,
  you're undoubtedly a really hoopy hacker but this is getting annoying. I do
  agree somewhat with your thesis, but I think there's just as viable a niche
  for GEL as any other EL so "doomed" is far too strong a word.
-- 
Peter da Silva                                            `-_-'
Network Management Technology Incorporated                 'U`
1601 Industrial Blvd.     Sugar Land, TX  77478  USA
+1 713 274 5180                       "Hast Du heute schon Deinen Wolf umarmt?"
