24.3 Environment Inquiries

Environment inquiry functions provide information about the environment in which a Common Lisp program is being executed. They are described here in two categories: first, those dealing with determination and measurement of time, and second, all the others, most of which deal with identification of the computer hardware and software.

Справочные функции представляют информацию о среде, в которой исполняется Common Lisp’овая программа. Функции разделены на две категории: первые для работы со временем, и остальные для получения имен, версий, типов программ и оборудования.

24.3.1 Time Functions

Time is represented in three different ways in Common Lisp: Decoded Time, Universal Time, and Internal Time. The first two representations are used primarily to represent calendar time and are precise only to one second. Internal Time is used primarily to represent measurements of computer time (such as run time) and is precise to some implementation-dependent fraction of a second, as specified by internal-time-units-per-second. Decoded Time format is used only for absolute time indications. Universal Time and Internal Time formats are used for both absolute and relative times.

Decoded Time format represents calendar time as a number of components:

Time zone part of Decoded Time need not be an integer, but may be any rational number (either an integer or a ratio) in the range -24 to 24 (inclusive on both ends) that is an integral multiple of 1/3600. _________________________

Обоснование: For all possible time designations to be accommodated, it is necessary to allow the time zone to be non-integral, for some places in the world have time standards offset from Greenwich Mean Time by a non-integral number of hours.

There appears to be no user demand for floating-point time zones. Since such zones would introduce inexact arithmetic, X3J13 did not consider adding them at this time.

This specification does require time zones to be represented as integral multiples of 1 second (rather than 1 hour). This prevents problems that could otherwise occur in converting Decoded Time to Universal Time.

__________________________________________________________________________

Universal Time represents time as a single non-negative integer. For relative time purposes, this is a number of seconds. For absolute time, this is the number of seconds since midnight, January 1, 1900 GMT. Thus the time 1 is 00:00:01 (that is, 12:00:01 A.M.) on January 1, 1900 GMT. Similarly, the time 2398291201 corresponds to time 00:00:01 on January 1, 1976 GMT. Recall that the year 1900 was not a leap year; for the purposes of Common Lisp, a year is a leap year if and only if its number is divisible by 4, except that years divisible by 100 are not leap years, except that years divisible by 400 are leap years. Therefore the year 2000 will be a leap year. (Note that the “leap seconds” that are sporadically inserted by the world’s official timekeepers as an additional correction are ignored; Common Lisp assumes that every day is exactly 86400 seconds long.) Universal Time format is used as a standard time representation within the ARPANET; see reference [22]. Because the Common Lisp Universal Time representation uses only non-negative integers, times before the base time of midnight, January 1, 1900 GMT cannot be processed by Common Lisp.

Internal Time also represents time as a single integer, but in terms of an implementation-dependent unit. Relative time is measured as a number of these units. Absolute time is relative to an arbitrary time base, typically the time at which the system began running.

[Function] get-decoded-time

The current time is returned in Decoded Time format. Nine values are returned: second, minute, hour, date, month, year, day-of-week, daylight-saving-time-p, and time-zone.


[Function] get-universal-time

The current time of day is returned as a single integer in Universal Time format.

Функция возвращает текущее время всемирное время в


[Function] decode-universal-time universal-time &optional time-zone

The time specified by universal-time in Universal Time format is converted to Decoded Time format. Nine values are returned: second, minute, hour, date, month, year, day-of-week, daylight-saving-time-p, and time-zone.

The time-zone argument defaults to the current time zone.

decode-universal-time, like encode-universal-time, ignores daylight saving time information if a time-zone is explicitly specified; in this case the returned daylight-saving-time-p value will necessarily be nil even if daylight saving time happens to be in effect in that time zone at the specified time.


[Function] encode-universal-time second minute hour date month year &optional time-zone

The time specified by the given components of Decoded Time format is encoded into Universal Time format and returned. If you do not specify time-zone, it defaults to the current time zone adjusted for daylight saving time. If you provide time-zone explicitly, no adjustment for daylight saving time is performed.


[Constant] internal-time-units-per-second

This value is an integer, the implementation-dependent number of internal time units in a second. (The internal time unit must be chosen so that one second is an integral multiple of it.) ______________________________________________

Обоснование: The reason for allowing the internal time units to be implementation-dependent is so that get-internal-run-time and get-internal-real-time can execute with minimum overhead. The idea is that it should be very likely that a fixnum will suffice as the returned value from these functions. This probability can be tuned to the implementation by trading off the speed of the machine against the word size. Any particular unit will be inappropriate for some implementations: a microsecond is too long for a very fast machine, while a much smaller unit would force many implementations to return bignums for most calls to get-internal-time, rendering that function less useful for accurate timing measurements.

___________________________________________________________________________________________________________

[Function] get-internal-run-time

The current run time is returned as a single integer in Internal Time format. The precise meaning of this quantity is implementation-dependent; it may measure real time, run time, CPU cycles, or some other quantity. The intent is that the difference between the values of two calls to this function be the amount of time between the two calls during which computational effort was expended on behalf of the executing program.


[Function] get-internal-real-time

The current time is returned as a single integer in Internal Time format. This time is relative to an arbitrary time base, but the difference between the values of two calls to this function will be the amount of elapsed real time between the two calls, measured in the units defined by internal-time-units-per-second.


[Function] sleep seconds

(sleep n) causes execution to cease and become dormant for approximately n seconds of real time, whereupon execution is resumed. The argument may be any non-negative non-complex number. sleep returns nil.


24.3.2 Other Environment Inquiries

24.3.3 Справочные функции о среде

For any of the following functions, if no appropriate and relevant result can be produced, nil is returned instead of a string. _______________________________

Обоснование: These inquiry facilities are functions rather than variables against the possibility that a Common Lisp process might migrate from machine to machine. This need not happen in a distributed environment; consider, for example, dumping a core image file containing a compiler and then shipping it to another site.

___________________________________________________________________________________________________________

[Function] lisp-implementation-type

A string is returned that identifies the generic name of the particular Common Lisp implementation. Examples: "Spice LISP", "Zetalisp", "SBCL".


[Function] lisp-implementation-version

A string is returned that identifies the version of the particular Common Lisp implementation; this information should be of use to maintainers of the implementation. Examples: "1192", "53.7 with complex numbers", "1746.9A, NEWIO 53, ETHER 5.3".


[Function] machine-type

A string is returned that identifies the generic name of the computer hardware on which Common Lisp is running. Examples: "IMLAC", "DEC PDP-10", "DEC VAX-11/780", "X86-64".


[Function] machine-version

A string is returned that identifies the version of the computer hardware on which Common Lisp is running. Example: "KL10, microcode 9", "AMD Athlon(tm) 64 X2 Dual Core Processor 3600+".


[Function] machine-instance

A string is returned that identifies the particular instance of the computer hardware on which Common Lisp is running; this might be a local nickname, for example, or a serial number. Examples: "MIT-MC", "CMU GP-VAX".


[Function] software-type

A string is returned that identifies the generic name of any relevant supporting software. Examples: "Spice", "TOPS-20", "ITS", Linux.


[Function] software-version

A string is returned that identifies the version of any relevant supporting software; this information should be of use to maintainer of the implementation.


[Function] short-site-name
[Function] long-site-name

A string is returned that identifies the physical location of the computer hardware. Examples of short names: "MIT AI Lab", "CMU-CSD". Examples of long names:

"MIT Artificial Intelligence Laboratory"
"Massachusetts Institute of Technology
Artificial Intelligence Laboratory"
"Carnegie-Mellon University Computer Science Department"


See also user-homedir-pathname.

[Variable] *features*

The value of the variable *features* should be a list of symbols that name “features” provided by the implementation. Most such names will be implementation-specific; typically a name for the implementation will be included.

The value of this variable is used by the #+ and #- reader syntax.

Feature names used with #+ and #- are read in the keyword package unless an explicit prefix designating some other package appears. The standard feature name ieee-floating-point is therefore actually the keyword :ieee-floating-point, though one need not write the colon when using it with #+ or #-; thus #+ieee-floating-point and #+:ieee-floating-point mean the same thing.