message hierarchy question

Dick Kriesel dick.kriesel at mail.com
Thu Jan 5 19:23:17 EST 2006


On 1/5/06 12:07 PM, "Mark Wieder" <mwieder at ahsoftware.net> wrote:

> What I'm
> looking at for this case is not just polymorphism, but being able to
> overload functions whose default instance is in my mainstack and whose
> overloaded instance is in a separate (not sub-) stack.

If the handlers in your main stack check the target, then they can provide
the default implementations:

function foo p
  put the uStack of me into tStack
  if (tStack is empty) \
      or (the target is "stack" && quote & tStack & quote) then
    -- execute the default implementation, for example:
    put the long time into tResult
  else
    put value(the params,stack tStack) into tResult
  end if
  return tResult
end foo

on bar p
  put the uStack of me into tStack
  if (tStack is empty) \
      or (the target is "stack" && quote & tStack & quote) then
    -- execute the default implementation, for example:
    put the long time into tResult
  else
    send the params to stack tStack
    put the result into tResult
  end if
  put tResult
  return tResult
end bar

With this technique, you can overload any handler without repeatedly
removing and inserting scripts into front or back.  I think.  I see you're
satisfied with your current approach, but do you see a problem with this
technique?

-- Dick





More information about the use-livecode mailing list