Hi Jon,

> I want to send arbitrary messages to an object MyObj. If I have a word
> "msg", then I want to send the message 'msg> to MyObj. I do it like
> this:
> (setq Word "msg")
> (setq MsgSym (car (str (pack Word ">"))))
> (try MsgSym MyObj)

Yes, you must make an internal symbol, as the message lookup uses
pointer-equality during lookup. But 'str' is a bit too heavy ;)

This should work:

   (dm msg ()
      ... )

   (try (intern Word) MyObj)

The ">" is just a naming convention and not absolutely needed here, but
of course you can do (with a little overhead)

   (dm msg> ()
      ... )

   (try (intern (pack Word ">")) MyObj)

> If MsgSym is not a message that can be located in MyObj, then the
> “try” function will return NIL. However, depending on the message, the
> “try” function may also return NIL for valid messages. What’s the best
> way to find out if MsgSym is/was a valid message symbol for MyObj?

You can test the lookup with

   (method 'msg 'obj)

♪♫ Alex
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to