Hi Jean,

that's a funny one.

join uses append. append uses the REBOL functio head to return the series
it appended to at its head.

You redefine head to be

>head: func [block2] [join "<HEAD>" [block2 "</HEAD>"]]

So, what happens is whenever join is called within your functions,
eventually head is called (the intention is to call REBOL's predefined
head!) and instead of REBOL's head function your head function is called,
which in turn does a join, which leads to calling head ... and you have
happily constructed an infinite loop. :-)

If you rename head to something else:

html-head

then you script runs (with problems), producing

>> do %myhtml.r
Script: "Untitled" (none)
<HTML>html-head title Titel body Das ist ein Text !</HTML>
>>

Note that the next problem you encounter is that you get title Titel
instead of your intended <TITLE>....</TITLE> and you get body Das ...
instead of your intended <BODY>...</BODY>.

The reason you get this is that you pass the block [title "Titel"] etc. and
therefore title is not reduced. You need to use rejoin in your functions
and - because the block you are passing to html consists of two embedded
blocks, the html-head block and the body block - you need to use an
additional reduce in addition to rejoin. Now the thing returns:

>> do %myhtml.r
Script: "Untitled" (none)
<HTML><HEAD>title Titel</HEAD> <BODY>Das ist ein Text !</BODY></HTML>

and the complete, slightly modified code is:

REBOL []
;definition part

html: func [block1 ] [rejoin ["<HTML>" reduce block1 "</HTML>"]]
html-head: func [block2] [rejoin ["<HEAD>" block2 "</HEAD>"]]
body: func [block3] [rejoin ["<BODY>" block3 "</BODY>"]]
title: func [block4] [rejoin ["<TITLE>" block4 "</TITLE>"]]

;test part
a: html
[
 html-head
 [
  title "Titel"
 ]
 body
 [
  "Das ist ein Text !"
 ]
]
print a




At 04:46 PM 2/15/00 +0100, you wrote:
>Hi ,
>
>I tried to learn th. about writing dialects. So I did the following code, to
>begin with.
>I exspected it to putput the following:
>
><HTML><HEAD><TITLE>Titel</TITLE></HEAD><BODY>Das ist ein Text
>!</BODY></HTML>
>
>but I got an error msg of type: stack overflow , though I had increased
>stack to 3.000.000 Bytes.
>
>Here's my program:
>
>
>REBOL []
>;definition part
>html: func [block1] [join "<HTML>" [block1 "</HTML>"]]
>head: func [block2] [join "<HEAD>" [block2 "</HEAD>"]]
>body: func [block3] [join "<BODY>" [block3 "</BODY>"]]
>title: func [block4] [join "<TITLE>" [block4 "</TITLE>"]]
>;test part
>a: html
>[
> head
> [
>  title "Titel"
> ]
> body
> [
>  "Das ist ein Text !"
> ]
>]
>print a
>
>
>
> <<myhtml.r>> 
>
>Attachment Converted: "c:\eudora\attach\myhtml.r"
>

;- Elan >> [: - )]

Reply via email to