> -----Ursprüngliche Nachricht-----
> Von: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
> Gesendet am: Dienstag, 15. Februar 2000 19:41
> An: [EMAIL PROTECTED]
> Betreff: [REBOL] Dialecting...Stack Overflow ?! Re:
>
> 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
>
> ;- Elan >> [: - )]
Thanks a lot. Now it works :)
So if I use a block within a block I need reduce to tell rebol to evaluate
the embedded block.
But why do I need rejoin in this case ?
join "<HTML>" [reduce block1 "</HTML>"]
also worked as I tried it.
Theoretically,
rejoin ["<HTML>" block1 "</HTML>"]
should work,too. The Rebol doc says:
Rejoin: Reduces and joins a block of values.
ciao,
Jean