Lisp HUG Maillist Archive

objective-c question

Hello list,

is it safe to call an objective-c method defined in lisp from an external objective-c frameworks ?

I did that without problem in the past, but now I experiment some trouble with a more complex situation :

A delegate method is defined in objective-c that is called by a notification of the system. This delegate does a certain job and then calls another method on another class, the two defined in lisp (using performSelector to avoid compilation warning). Finally, the lisp-objc method calls the objective-c frameworks again to finish the job using some data processed in lisp. All of these codes run in the main thread. 

During the lisp part of the process, I got some very strange errors, like structure writers that are suddenly declared undefined… Because of the common objective-c runtime, I thought that I can go from objective-c codes to lisp codes and vice-versa without any problem, but maybe I forget an important thing… 

Thanks for any help

Denis

------------------------------------------------
Denis Pousseur
70 rue de Wansijn
1180 Bruxelles
+ 32 2 219 31 09
http://www.denispousseur.com
------------------------------------------------


_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Re: objective-c question

Denis Pousseur <denis.pousseur@gmail.com> writes:

> Hello list,
>
> is it safe to call an objective-c method defined in lisp from an
> external objective-c frameworks ?

It depends.


> I did that without problem in the past, but now I experiment some
> trouble with a more complex situation :
>
> A delegate method is defined in objective-c that is called by a
> notification of the system. This delegate does a certain job and then
> calls another method on another class, the two defined in lisp (using
> performSelector to avoid compilation warning). Finally, the lisp-objc
> method calls the objective-c frameworks again to finish the job using
> some data processed in lisp. All of these codes run in the main
> thread.

If all is done from the Objective-C main thread, it should be ok (from
the point of view of Objective-C).

> During the lisp part of the process, I got some very strange errors,
> like structure writers that are suddenly declared undefined… Because
> of the common objective-c runtime, I thought that I can go from
> objective-c codes to lisp codes and vice-versa without any problem,
> but maybe I forget an important thing…

There could be problems from the point of view of Lisp, with respect to
the garbage collector, or with interactions between the  lisp condition
system and the Objective-C exception system.  If the implementation
doesn't handle it, then your functions and methods should (use try/catch
and handler-case in all those embedded functions)

-- 
__Pascal Bourguignon__                 http://www.informatimago.com/
“The factory of the future will have only two employees, a man and a
dog. The man will be there to feed the dog. The dog will be there to
keep the man from touching the equipment.” -- Carl Bass CEO Autodesk

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Re: objective-c question

>>>>> On Sat, 9 Aug 2014 11:49:16 +0200, Denis Pousseur said:
> 
> Hello list,
> 
> is it safe to call an objective-c method defined in lisp from an external
> objective-c frameworks ?
> 
> I did that without problem in the past, but now I experiment some trouble
> with a more complex situation :
> 
> A delegate method is defined in objective-c that is called by a notification
> of the system. This delegate does a certain job and then calls another
> method on another class, the two defined in lisp (using performSelector to
> avoid compilation warning). Finally, the lisp-objc method calls the
> objective-c frameworks again to finish the job using some data processed in
> lisp. All of these codes run in the main thread.

Yes, this should all work.


> During the lisp part of the process, I got some very strange errors, like
> structure writers that are suddenly declared undefined… Because of the
> common objective-c runtime, I thought that I can go from objective-c codes
> to lisp codes and vice-versa without any problem, but maybe I forget an
> important thing…

Possibly you are compiling calls to the structure writers before defining the
defstruct?  That would fail with an error like "Undefined function (SETF
FOO-BAR)" because defstruct defines the writers using defsetf rather than as
setf functions.

-- 
Martin Simmons
LispWorks Ltd
http://www.lispworks.com/

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html


Updated at: 2020-12-10 08:33 UTC