object function error??
[1/3] from: raimunddold::web::de at: 23-Jun-2001 9:33
Hi,
whats wrong with this??
REBOL []
book: make object! [
author:
title:
info: none
print: func []
[
print [ author ": " title ]
]
]
my-book: make book[]
my-book/author: "Raimund Dold"
my-book/title: "Is this an error?"
my-book/print
If I evaluate the lines above I get the following:
** Internal Error: Stack overflow
** Near: print [author ": " title]
Whats wrong?
Raimund
[2/3] from: c:brizell:worc:ac at: 23-Jun-2001 8:46
Raimund,
Try the following amended script:
REBOL []
book: make object! [
author:
title:
info: none
printit: func []
[
print [ author ": " title ]
]
]
my-book: make book[]
my-book/author: "Raimund Dold"
my-book/title: "Is this an error?"
my-book/printit
The function print that you declared superceded the system definintion of
the word 'print causing your 'print function to loop recursively
HTH
colinb
[3/3] from: joel:neely:fedex at: 23-Jun-2001 2:16
Hi Raimund,
Raimund Dold wrote:
> REBOL []
> book: make object! [
<<quoted lines omitted: 6>>
> ]
> ]
...
> ** Internal Error: Stack overflow
> ** Near: print [author ": " title]
>
Colin's diagnosis was correct, and in general it's a good
idea IMHO to avoid names already taken. For the sake of
completeness, I'll mention that you *could* do this
book: make oject! [
author: title: info: none
print: func [] [system/words/print [
author ":" title
]
]
because your redefinition of PRINT is only within the
context of BOOK; it won't interfere with the use of
PRINT outside that context (unless you do something
else to cause *that* effect ;-)
-jn-
--
------------------------------------------------------------
Programming languages: compact, powerful, simple ...
Pick any two!
joel'dot'neely'at'fedex'dot'com
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted