[Openmcl-devel] Determining OSX version at runtime

Gary Byers gb at clozure.com
Thu Aug 26 17:42:31 UTC 2010


APROPOS's generally only going to return information about interned symbols.

The #$ and #& reader macros lookup the values (or access information)
of foreign variables in the interface databases.  One side-effect of
this lookup process is to intern the foreign variable's name in some
platform- specific package; the reader macros' implentation generally
involves interning a symbol in the OS package and sometimes expand
into code which reference this lisp symbol in some way.  (I don't even
remember how or in what cases, and I'm too lazy to look ...)  You
generally want to use the reader macros to access foreign
variables/constants and not depend on any possible side-effects on
the lisp symbol

APROPOS's therefore normally only going to report something about a
lisp symbol with the name |NSAppKitVersionNumber| if some reader macro
has interned that symbol as an artifact of its implementation in the current
session.

(A few years ago, the ObjC bridge only worked in a standalone application if
the application was run under the same OS release as it was saved from; we used
#&NSAppKitVersionNumber to try to enforce that.  Some of the IDE startup
code still obtained the value that variable (even if it's no longer used ...);
Cocotron doesn't (or didn't) define the variable.  I don't remember the details
(and am too lazy to click on another buffer and look it up), but it's not too
surprising that #&NSAppKitVersionNumber might be referenced (and ignored) on
some platforms and not others.

On OSX (in the IDE), you can use #&NSAppKitVersionNumber to obtain this info.
If you need to test programmatically to see if a foreign variable is defined
in the interfaces, you can use (e.g.):

#&?NSAppKitVersionNumber

which will return a boolean indication of that.  (AFAIK, that construct will
return T on OSX in the IDE on all platforms.)


On Thu, 26 Aug 2010, Neil Baylis wrote:

> The Apple release notes for Snow Leopard suggest using NSAppKitVersionNumber.On my Snow Leopard system, I see
> 
> CL-USER> (apropos "NSAppKit")
> X86-DARWIN64::|NSAppKitVersionNumber|
> 
> But on my 32 bit ppc Leopard system, apropos doesn't know anything about it.
> 
> (Both systems using ccl 1.5)
> 
> Neil 
> 
> On Thu, Aug 26, 2010 at 9:39 AM, Raffael Cavallaro <raffaelcavallaro at mac.com> wrote:
>
>       On Aug 26, 2010, at 12:17 PM, Gary Palter wrote:
>
>       > Yes, you can use (software-version).  On Mac OS X, the first number is the major release + 4, the second number
>       is the minor release, and the third number is usually zero.
>       >
>       > So, 9.8.0 is OS X 10.5.8 and 10.4.0  is OS X 10.6.4.
> 
> you can also cheat and get the product version directly (though this is not considered the correct method by apple):
> 
> ? (defun mac-os-x-version ()
>   (ccl::with-autorelease-pool
>       (let* ((plist
>               (#/dictionaryWithContentsOfFile: ns:ns-dictionary #@"/System/Library/CoreServices/SystemVersion.plist")))
>         (ccl::lisp-string-from-nsstring (#/valueForKey: plist #@"ProductVersion")))))
> 
> ? (mac-os-x-version)
> "10.6.4"
> 
> warmest regards,
> 
> Ralph
> 
> 
> Raffael Cavallaro
> raffaelcavallaro at me.com
> 
> 
> 
> 
> 
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
> 
> 
> 
> 
> --
> http://www.pixpopuli.com
> 
>


More information about the Openmcl-devel mailing list