Environment inquiry functions provide information about the environment in which a Common Lisp program is being executed. They are described here in two categories: ﬁrst, those dealing with determination and measurement of time, and second, all the others, most of which deal with identiﬁcation of the computer hardware and software.
Справочные функции представляют информацию о среде, в которой исполняется Common Lisp’овая программа. Функции разделены на две категории: первые для работы со временем, и остальные для получения имен, версий, типов программ и оборудования.
Time is represented in three diﬀerent ways in Common Lisp: Decoded Time, Universal Time, and Internal Time. The ﬁrst 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 speciﬁed 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 oﬀset from Greenwich Mean Time by a non-integral number of hours.
There appears to be no user demand for ﬂoating-point time zones. Since such zones would introduce inexact arithmetic, X3J13 did not consider adding them at this time.
This speciﬁcation 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 oﬃcial 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 . 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.
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.
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 speciﬁed 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 speciﬁed; in this case the returned daylight-saving-time-p value will necessarily be nil even if daylight saving time happens to be in eﬀect in that time zone at the speciﬁed time.
[Function]encode-universal-time second minute hour date month year &optional time-zone
The time speciﬁed 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.
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 ﬁxnum will suﬃce as the returned value from these functions. This probability can be tuned to the implementation by trading oﬀ 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.
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 diﬀerence between the values of two calls to this function be the amount of time between the two calls during which computational eﬀort was expended on behalf of the executing program.
The current time is returned as a single integer in Internal Time format. This time is relative to an arbitrary time base, but the diﬀerence 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 deﬁned by internal-time-units-per-second.
(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.
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 ﬁle containing a compiler and then shipping it to another site.
A string is returned that identiﬁes the generic name of the particular Common Lisp implementation. Examples: "Spice LISP", "Zetalisp", "SBCL".
A string is returned that identiﬁes 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".
A string is returned that identiﬁes the generic name of the computer hardware on which Common Lisp is running. Examples: "IMLAC", "DEC PDP-10", "DEC VAX-11/780", "X86-64".
A string is returned that identiﬁes 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+".
A string is returned that identiﬁes 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".
A string is returned that identiﬁes the generic name of any relevant supporting software. Examples: "Spice", "TOPS-20", "ITS", Linux.
A string is returned that identiﬁes the version of any relevant supporting software; this information should be of use to maintainer of the implementation.
A string is returned that identiﬁes the physical location of the computer hardware. Examples of short names: "MIT AI Lab", "CMU-CSD". Examples of long names:
See also user-homedir-pathname.
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-speciﬁc; 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 preﬁx designating some other package appears. The standard feature name ieee-ﬂoating-point is therefore actually the keyword :ieee-ﬂoating-point, though one need not write the colon when using it with #+ or #-; thus #+ieee-ﬂoating-point and #+:ieee-ﬂoating-point mean the same thing.