Galt wrote:
> So, how do I have a sort of almost global variable in the sense that I can
set it and then have all these functions know about it without having to
pass the darn value all around to everyone of them? It gets tedious and one
hopes that an advanced language like Rebol might have some tricks to cure
this ailment.

O, seeker of knowledge! You have found OO and Dialects, and will soon attain
understanding beyond the ken of ordinary mortals.

> I thought already about creating an object which has a layer like this:
>
> r: make object! [
>  parm1: result
>  xx: x parm1
>  yy: y parm1
>  zz: z parm 1
>  aappend: func[ str] [append parm1 str]
> ]
>
> and then going like this
> r
> r/xx
> r/yy
> r/zz
> r/aappend "stuff"
>
> but then I thought that it's only slightly better, and still not ideal.
what would be really cool is a way to bind x, y, and z so that I don't need
any extra clutter, so my code would just be
> x
> y
> z
> append "stuff"
>
> and all these operations would happen on "result"
>
> Does anybody have any idea what the heck I am trying to get at? I hate
seeing oodles of functions where the same stupid parameter is passed over
and over and over and over up and down thru the various levels, never
changing, just getting passed again and again and again, and sometimes not
just one but several.  Ick.  This situation must be very common.

Here's a quick example:

O: make object! [
    f1: func [] []
    f2: func [] []
    set 'Dialect func [Dialect [block!]] [reduce bind Dialect 'f1]
    ]

B: [f1 f2 f1]

Dialect B

I leave the method name changing to the student.

Andrew Martin
Guru on OO mountain...
ICQ: 26227169
http://members.xoom.com/AndrewMartin/
-><-

Reply via email to