Oh yes, I've considered restructuring things, but the current arcitecture is
the one that best suits all of my needs (the best one that I have been able
to think of, anyway). Specifically, when I define a function element in an
object, that function does nothing more than to call another function (not
defined as part of the object) to do the work. For example:
door-man: make object! [
vocab1: "hello"
vocab2: "world"
speak: func [][say-greeting self]
]
say-greeting: func [idiot][
print [idiot/vocab1 idiot/vocab2]
]
door-man/speak
This simple example is neat and clean. The messy part is when I also have to
pass-through refinements. Then I not only have to keep both functions in
sync with the refinement list, but I also have to keep the 'if statements in
sync. I've been doing that with the assumption that I only specify a single
refinement at a time. To save me just that much more work, it'd be nice to
have some automatic way of passing the refinements.
I have considered passing the refinements as a block, and even the idea of
defining them as an object (within the pass-through function) is appealing.
This involves looping to get the refinement! values from the first block of
the function. But the only way I know how to get the value of a refinement!
type is to cast it as a word!, then use 'get, then bind it to the current
context (ick). It seems like there should be a way to evaluate a refinement!
type directly. That would make me happy.
- Michael Jelinek
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 26, 2000 2:30 AM
To: [EMAIL PROTECTED]
Subject: [REBOL] refinements Re:(3)
[EMAIL PROTECTED] wrote:
> But (unless I don't get it, here) this uses exactly what I am trying to
avoid using: an 'if statement for each possible refinement. I agree it's
easier and more straight forward, but it also creates more work to maintain
(such as when refinements are added to a function). Since I use this
"pass-through of refinements" idea as a common practice in my program, the
added maintenance adds up.
It's only one 'if per refinement that's to be passed through. It avoids
multiple combinations of 'ifs. For each refinement added, it's only one
extra 'if to write. I believe that this approach is only a small price to
pay.
If you're commonly passing refinements through to subfunctions, consider
restructuring your software. It may be better to use a different approach,
perhaps using objects?
YMMV. :-)
Andrew Martin
ICQ: 26227169
http://members.xoom.com/AndrewMartin/
-><-