[Openmcl-devel] Init-file in openMCL Cocoa App

Gary Byers gb at clozure.com
Fri Jun 11 00:45:51 UTC 2004



On Thu, 10 Jun 2004, Sebastian Nozzi wrote:

>
> Hi,
>
> I was trying to change the lines in "cocoa-application.lisp" where the
> application image is saved. I want to load an init-file in the graphic
> environment as well so I just added the corresponding parameter:
>
> (save-application "ccl:OpenMCL.app;Contents;MacOS;dppccl"
> :init-file "home:openmcl-init.lisp"
> :prepend-kernel t
> :application-class 'cocoa-application)
>
> This works.

I'm surprised that it does.

The behavior of a saved application is (mostly) determined by methods
that're specialied on a subclass of the class CCL:APPLICATION, of which
there's generally one interesting instance (which is the value of the
variable CCL:*APPLICATION*.)

When a saved application starts up, the generic function
CCL:TOPLEVEL-FUNCTION is called on the value of CCL:*APPLICATION* and
an init-file pathname.

SAVE-APPLICATION's :APPLICATION-CLASS argument can be used to change the
value of CCL:*APPLICATION*: it's set to an instance of the named class
if this argument is provided.

The method CCL:APPLICATION-INIT-FILE (called on the application object)
would ordinarily be used to determine the init-file argument passed
to the application's "toplevel function"; this can be overridden by the
:INIT-FILE argument to SAVE-APPLICATION.

The TOPLEVEL-FUNCTION method for the COCOA-APPLICATION class (defined in
"ccl:examples;cocoa-application.lisp") igores its INIT-FILE argument,
which is why I'm surprised that you say that the file was loaded.

(The standard TOPLEVEL-FUNCTION method creates a listener thread and
arranges for that thread to load the init-file.  In a Cocoa application,
the initial listener thread is made when the initial listener is made;
one could change the TOPLEVEL-FUNCTION method to save the init-file
argument in a special variable and change the code that creates listeners
to use (and reset) that special variable.)

> But I also tried other possibilities (since I don't want to
> see the file in the Finder in my home directory) and they didn't work.
> And as a MacOS X novice I don't exactly know in which log to look for
> standard error messages in the Console application.
>
> In the first case, I renamed the file with a dot in front to make it
> invisible to Finder. In the other cases I tried with other locations.
> All failed:
>
> :init-file "home:.openmcl-init.lisp"

The two unquoted dots in this namestring confuse the parsing code; the
part after the second dot is treated as an unusual version number ("lisp")
and the part after the first dot is treated as a pathname type/extension
("openmcl-init").  One can cause the first dot to be treated as part of
the name (and the second as separating the name and type) by escaping
the first dot, as in:

"home:\\.openmcl-init.lisp".


> :init-file "home:Library/openmcl-init.lisp"
> :init-file "home:Library;openmcl-init.lisp"
> :init-file "/Users/sebnozzi/Library/openmcl-init.lisp"
> :init-file "ccl:openmcl-init.lisp"

I'm pretty sure that all of these cases would have been passed to the
saved application's TOPLEVEL-FUNCTION method, which would have then
completely ignored it ...

>
> My init-file defined a global variable and in the cases of failure the
> variable was of course unbound.
>
> Moreover, I would like to know how the directory translation works in
> openMCL. Where can I get more info on that? (what predefined directories
> are there, like home:, ccl:, etc. when to use ; and when to use :? can I
> mix slashes and ; and : ? etc.)
>
> Thanks in advance,
>
> Sebastian
>
> P.S. openMCL version 0.14.2-p1, OSX version 10.3.4
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>



More information about the Openmcl-devel mailing list