From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu From: Robby Message-ID: <5YZCa.5429$iO3.35296367@news-text.cableinet.net> Content-Type: text/plain; charset=us-ascii References: <3EDB4C63.5080902@proweb.co.uk> Subject: Re: [9fans] httpd scripting Date: Tue, 3 Jun 2003 09:42:20 +0000 Topicbox-Message-UUID: c2fba0a4-eacb-11e9-9e20-41e7f4b1d025 In article <20030602163818.316ebbf5.spam@broster.co.uk>, spam@broster.co.uk (Ian Broster) writes: >> the "code fragments in the HTML" model is not very scalable >> >> in fact, content management becomes a total nightmare > > I've come to the conclusion that neither 'code in HTML' nor 'HTML > in code' are very good! Neither are easy to read, quotes mess > everything up and it's hard to debug. > > My thought is to try to raise the abstraction higher. > Here's how I'd like to code a server generated page. > > int some_data[5][5]; /*eg*/ > create_my data(some_data); > ... > { > new_web_page(template); > add(some_data, how_to_add_intgers); > add(sometext, how_to_add_text); > ... > done(); /* composes the page and writes it out*/ > } > > > Note that the ordering is not 'linear'. It doesn't matter which > order the add() calls come. the 'how_to_add_text' things > (whatever they are?) describe how the thing is presented in > the markup language. > > Perhaps this has overtones of a Tk-like interface. > Perhaps it's more object oriented. One > day, I'd like to try to find the time to investigate. > Maybe something already exists? > > ian This kind of reminds me of a posting to comp.compilers, which I love to whip out whenever somebody wants to understand function pointers or variable arguments. I don't know if this "just" works in plan9, though. I haven't had the need to try something like this out yet. Robby > From telnet@wagner.Princeton.EDU.composers Wed Jul 8 06:40:19 1998 > Newsgroups: comp.compilers > Subject: Re: writing an assembler! > Date: 8 Jul 1998 01:40:01 -0400 > Organization: Chemistry Department, Princeton University > Message-ID: <98-07-062@comp.compilers> > Keywords: macros, design > Lines: 70 > In article <98-07-005@comp.compilers>, "Dr Richard A. O'Keefe" writes: > > These days, my language of choice for doing this would be Lisp or Ada > > (sensible macros are about *trees*, not strings!) but you can > > certainly use C as an assembler quite effectively. > > [It's a disgusting hack, but it's a great disgusting hack. -John] > > You can get away with tree-like behavior in C if you use varargs stuff. > I'll risk my reputation (:-)) by admitting to an even more disgusting hack: > --- > void new_section(char *title, char *img_name, int h, int w) { > emit(html_list, > html_p, > html_hr, > html_br, > html_region, "center", > html_region, "h1", > html_text, title, > html_tag, "img", > html_param, "src", html_string, fname, > html_param, "height", html_text, h, > html_param, "width", html_text, w, > 0, > 0); > } > --- > typedef void (*html_func)(va_list *); > > void emit(html_func first, ...) { > va_list ap; > > va_start(ap, first); > (*first)(&ap); > va_end(ap); > } > > void html_list(va_list *ap) { > html_func f; > > while (1) { > f = va_arg(ap, html_func); > if (f == 0) break; > > (*f)(ap); > } > } > > [etc] > --- > > A disgusting hack? Absolutely. > > But it's also an order of magnitude more powerful than any other > dynamic HTML tool I've worked with, and it only took me an hour or so > to implement. > --------------------------------------------------------------------------- > Tim Hollebeek > email: tim@wfn-shop.princeton.edu > URL: http://wfn-shop.princeton.edu/~tim > > [Wow, that's loathsome. I really like it. -John]