functions
[1/1] from: lmecir::mbox::vol::cz at: 6-Mar-2003 19:27
Hi all,
Gabriele's custom datatype application, especially his (and mine) SUBFUNC function inheritance
HOF (will be described separately) needed reliable means to return values from functions.
I multiextrasuperparaprogressivized one of my functions and obtained TFUNC:
tf: tfunc [x] [return x]
; the functions to compare with tf:
f1: func [x] [x]
f2: func [x] [return x]
f3: func [[catch] x] [x]
f4: func [[catch] x] [return x]
f5: func [[throw] x] [x]
f6: func [[throw] x] [return x]
1) TF differs from F1, F3, F4 and F5:
x: does [return make error! "e"]
type? tf :x ; == error!
type? f1 :x
; ** User Error: e
; ** Near: return make error! "e"
2) TF differs from F2, F4 and F6:
x: first [x:]
type? tf :x ; == set-word!
type? f2 :x ; == word!
3) Another example:
tf2: tfunc [x] [
either x [throw make error! "x"] [return make error! "x"]
]
>> type? tf2 false
== error!
>> type? tf2 true
** User Error: x
** Near: tf2 true
4) Anoher
tf3: tfunc [block] [
do block
]
g: does [tf3 [return 1] 2]
g ; == 1
5) And the last one
g: func [[catch]] [tf3 [throw make error! "e"]]
g
** User Error: e
** Near: g
Ciao
-L