#

## Issue CONSTANT-MODIFICATION Writeup

    Forum:		Compiler
    Issue:		CONSTANT-MODIFICATION
    References:	CLtL p. 78, 87
    		Issue CONSTANT-COLLAPSING
    Category:	CLARIFICATION
    Edit History:   V1, 07 Nov 1988, Sandra Loosemore
    		V2, 12 Dec 1988, Sandra Loosemore

    Problem Description:

    CLtL states that an implementation is permitted to "collapse"
    constants appearing in code to be compiled if they are EQUAL.  This
    implicit sharing of compiled data structures may result in
    unpredictable behavior if destructive operations are performed.
    However, CLtL does not explicitly allow or disallow destructive
    operations on constants.

    Proposal CONSTANT-MODIFICATION:DISALLOW:

    Clarify that it is an error to destructively modify objects which are
    self-evaluating forms or which appear inside of a QUOTE special form.

    Rationale:

    Disallowing modification of constants consistently in all situations,
    rather than just in compiled code, is proposed because in some
    compiled-only situations it may be difficult to distinguish between
    "compiled" and "interpreted" code.

    Current Practice:

    Many implementations "collapse" compiled constants.

    Many implementations treat compiled constants as read-only.  In
    PSL/PCLS, for example, quoted data structures in compiled code are
    copied into a part of memory that is not scanned by the garbage
    collector.  The TI Explorer's loader also copies constants into a
    write-protected memory area.

    Cost to implementors:

    None.

    Cost to users:

    User programs which perform destructive operations on constants are
    already nonportable.

    Benefits:

    Many novice programmers do not realize that modifying quoted data
    structures is an error in many implementations.  Including an explicit
    statement in the standard that doing so is a bad idea will reduce
    confusion.

    Discussion:

    The issue of whether implementations are permitted to copy constants
    seen by EVAL or COMPILE is discussed separately as issue QUOTE-MAY-COPY.

Copyright 1996-2001, Xanalys Inc. All rights reserved.