* [EMAIL PROTECTED] <[EMAIL PROTECTED]> [051001 01:03]:
>
> Tim:
> > The reason for the error is clear to me - it remains
> > inconsistant. IMHO, an action value or function
> > should either always return a value
> > OR
> > always not return a va
>
> I completely agree that it would be nice if things behaved in that way.
<grin> But sometimes we just have to deal with things they way they
are - right? (serendipity prayer)
> But I can also see the point that loops or functions can and do (and perhaps
> should) return 'unset in some conditions.
After 5 years of coding rebol, I still don't have an understanding of
'unset - I'm a complete noob in that area.
So let me give an example:
I've been delighted to come across A J Martin's 'collect function.
'collect can very valuable in exploiting iterative loops and relieving
the calling code of having to use multiple 'append calls.
Consider the following code:
=s foreach char str collect/str[ ;; 'str refinement builds a string
either replacement: (select mymap char)
[replacement][char]]
'=s is a little helper function that looks like this:
=s: func[v][any[v ""]]
;:-) my tribute to perl's cryptic sytax
; and is very handy when writing to stdout and we don't want a "none"
; in the output stream.
> It's easy to accidentally or intentionally write a function that has that
> "inconsistent" return behavior:
In the same spirit as '=s, I'm trying the following
=u: func[v][either unset? v[""][v]]
;; with the following results
>> =u v
** Script Error: v has no value
** Near: =u v
;; so how may we intercept an unset value?
I hope I'm being clear here.
thanks
tim
> f: func [p] [either p = 1 [print p][p + 1]]
>
> x: f 2
> == 3
>
> x: f 1
> 1
> ** Script Error: x needs a value
> ** Near: x: f 1
>
> As long as it is part of the specification of 'ff that it returns p+1 or
> 'unset (rather than it being an oversight), I'm happy with that.
>
> Sunanda.
> --
> To unsubscribe from the list, just send an email to
> lists at rebol.com with unsubscribe as the subject.
--
Tim Johnson <[EMAIL PROTECTED]>
http://www.alaska-internet-solutions.com
--
To unsubscribe from the list, just send an email to
lists at rebol.com with unsubscribe as the subject.