[comp.lang.lisp] Preserving case for LISP symbol names

skp@stl.stc.co.uk (Steve Perryman ) (07/05/90)

I have a problem which my lack of LISP knowledge prevents me from solving.

I have implemented a CLOS architecture which allows CLOS users to access
Objective-C objects in a distributed environment. I have special CLOS objects
which when called fail but since these objects override "no-applicable-method"
as defined in the CLOS system, they request the objective-C service via the
Internet. For example:


Calling (objective_C_Op obj 1)    in CLOS 
calls   [obj objective_C_Op: 1]   in Objective-C


The problem is that the Objective-C method naming convention is case
sensitive, and that the print value in LISP for the symbol objective_C_Op is
OBJECTIVE_C_OP. My comms protocol will encode this as the string
"OBJECTIVE_C_OP" (as it uses princ-to-string) and the objective-C environment
decodes it as OBJECTIVE_C_OP.

So [obj OBJECTIVE_C_OP: 1] is called, which may not exist.


What I need in LISP is a way to make sure that my special "no-applicable-method"
method gets passed the symbol whose print value is objective_C_Op and not
OBJECTIVE_C_OP. If I can do this I can encode the method name correctly and
everything works. Going from Objective-C to CLOS is not a problem.


It is very urgent that I get this one sorted out quickly as it is preventing
me from integration testing, so I'd be extremely grateful to hear from all you
gurus who know the answer.



Thanks in advance,

Steven Perryman
(skp@stl.stc.co.uk)

miller@GEM.cam.nist.gov (Bruce R. Miller) (07/06/90)

In article <3186@stl.stc.co.uk>, Steve Perryman writes: 
> 
> 
> I have a problem which my lack of LISP knowledge prevents me from solving.
> 
> I have implemented a CLOS architecture which allows CLOS users to access
> Objective-C objects in a distributed environment. I have special CLOS objects
> which when called fail but since these objects override "no-applicable-method"
> as defined in the CLOS system, they request the objective-C service via the
> Internet. For example:
> 
> 
> Calling (objective_C_Op obj 1)    in CLOS 
> calls   [obj objective_C_Op: 1]   in Objective-C
> 
> 
> The problem is that the Objective-C method naming convention is case
> sensitive, and that the print value in LISP for the symbol objective_C_Op is

Wow! that's an interesting (and ambitious) idea!

But, how about a different approach to the problem?
Instead of defining a handler for no-applicable-method, which IMHO 
is a dangerous habit to get too comfortable with, why dont you define
methods for each of the functions which are `cross mounted'?

Or better yet, a macro such as

  (define-pseudo-method objective-c-op (args ..) "objective_C_Op")

which would expand to something like

  (defmethod objective-c-op (args)
     (network-magic args.. "objective_C_Op"))
[whatever Syntax; ok,ok i admit, i'm still a flavors programmer...]

This gives you the benefit of a documented, checked, etc, interface
and avoids making any assumptions about how lisp treats the case of
symbols, or whether any automatic re-casing mismatches the objective-c
code.

>  ...
> Thanks in advance,
> 
> Steven Perryman
> (skp@stl.stc.co.uk)

no problem;
bruce

klapper@oravax.UUCP (Carl Klapper) (07/06/90)

In article <2856214136@ARTEMIS.cam.nist.gov>, miller@GEM.cam.nist.gov (Bruce R. Miller) writes:
> 
>   [good idea deleted]
> 
> Or better yet, a macro such as
> 
>   (define-pseudo-method objective-c-op (args ..) "objective_C_Op")
> 
> which would expand to something like
> 
>   (defmethod objective-c-op (args)
>      (network-magic args.. "objective_C_Op"))

While it is easier to construct the Objective C call with strings,
there may still be a need to keep information about object_C_Op in Lisp,
to have a token for it in, say, an Objective C -> Lisp parser, etc.
For these reasons, one may still want a Lisp object of the correct name,
i.e. |object_C_Op|. Or one may want for aesthetic reasons to have:

   (define-pseudo-method |objective_C_Op| (args ..) "objective_C_Op")

+-----------------------------+--------------------------------------------+
|  Real urbanites don't buy   | Carl Klapper				   |
|  things. They buy service.  | Odyssey Research Associates, Inc.	   |
|                             | 301A Harris B. Dates Drive		   |
|  A kitchen's place is       | Ithaca, NY  14850			   |
|  in the restaurant.         | (607) 277-2020				   |
|                             | klapper%oravax.uucp@cu-arpa.cs.cornell.edu |
+-----------------------------+--------------------------------------------+