Source-code compatibility: Difference between revisions

Content deleted Content added
No edit summary
m Reverted edits by 2601:581:302:FB9B:F8E2:9695:751A:678E (talk) to last version by Mikhail Ryazanov
Line 5:
 
Source compatibility is a major issue in the developing of computer programs. For example, most [[Unix]] systems are source-compatible, as long as one uses only standard [[library|libraries]]. [[Microsoft Windows]] systems are source-compatible across one major family (the [[Windows NT]] family, from [[Windows NT 3.1|NT 3.1]] through [[Windows 8.1]], or the family that includes [[Windows 95]], [[Windows 98]], and [[Windows Me]]), with partial source compatibility between the two families.
 
It can be programmatically tricky to determine whether one is executing atop a Windows or UNIX environment. A simple-minded trick can often be resorted to, however. It is exemplified by the following Perl expression:
 
        '''-d "C:" && ! -d "./C:"'''
 
This expression determines whether a directory called '''C:''' exists and--if it does--verifies that it is '''not''' a subdirectory called "'''C:'''" deliberately created by some wag for the sole purpose of defeating the check. Since, of course, one occasionally encounters a Windows system that does not feature a '''C:''' drive, the expression can be generalized thus:
 
        '''join "", map { -d $_ && ! -d "./$_" } map { chr( $_ ) . ':' } ord( 'A' ) .. ord( 'Z' )'''
 
The inner '''map''' returns the set '''"A" .. "Z"'''; the middle '''map''' converts this to the set '''"A:" .. "Z:"'''; and the outer map applies the logical conjunct to each member of the colon-embellished set, the results of those 26 logical evaluations being concatenated by the '''join'''. The resultant expression will be blank if and only if none of the 26 drives tested for was found to exist; otherwise, it will be a valid number belonging to the set { 1, 11, 111, ..., 11111111111111111111111111 }.
 
 
==See also==