Re: Why not a setf-able NIL ?



In article <ymiskre3deu.fsf@xxxxxxxxxxxxxxxx>,
tar@xxxxxxxxxxxxx (Thomas A. Russ) wrote:

Barry Margolin <barmar@xxxxxxxxxxxx> writes:

In article <87k5csnpp1.fsf@xxxxxxxxxxxxxxxxxxxxxxxx>,
pjb@xxxxxxxxxxxxxxxxx (Pascal J. Bourguignon) wrote:

You must be very very sad. I know of no programming language
allowing you to redefined/reassing 42.

Fortran used to allow this. Parameters were passed by reference, and
when you passed a literal it passed a reference to its location in the
literal pool. If the procedure assigned that parameter, it would change
the literal.

This was probably implementation-dependent, but I've heard that it
occurred with many popular implementations.

Hah, I had thought of this as well.

You got really amusing effects when you managed to change the constant
zero (0) to something else.

And just for the record, back in my Lisp Machine days one of my users
managed to set NIL to non-NIL. SETQ had a check to make sure it wasn't
setting NIL or T, but SET didn't (I may be misremembering the exact
detail -- perhaps a locative was involved as well). Needless to say,
the system was not very happy after this, and it quickly crashed the OS.

I had lots of fun using DDT to figure out what had happened and unwedge
it. In the next OS release, Symbolics aliased the value cells of T and
NIL to a read-only memory page so the hardware would prevent this.

--
Barry Margolin, barmar@xxxxxxxxxxxx
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
.



Relevant Pages

  • Re: MD7 Qs
    ... please read the entire chapter at least twice to yourself ... The common reason for assigning nil to an object reference after freeing ... reference before calling the virtual Destroy destructor. ...
    (comp.lang.pascal.delphi.misc)
  • Re: MD7 Qs
    ... Is it really wasted time if I end up seeing the material twice? ... set the objects value to nil. ... Then again, I don't usually re-use a object reference, ... > The FreeAndNil procedure was introduced at the request of the people who ...
    (comp.lang.pascal.delphi.misc)
  • Re: MD7 Qs
    ... >The common reason for assigning nil to an object reference after ... it is safe to call Free on a nil reference. ... Maarten Wiltink ...
    (comp.lang.pascal.delphi.misc)
  • Re: TADOConnection.OpenSchema documentation???
    ... That is sent nil into the constructor. ... If i had sent the form instance ... dynamically, on the heap, so an object reference is like a pointer (but ... Interfaces are different though, they are reference counted and when no ...
    (borland.public.delphi.database.ado)
  • Re: passing parameters by reference
    ... >> construction in C would be passing an argument by reference. ... Attempt to store in the cdr field of NIL which is not a cons. ... the cons cells that make up the argument. ...
    (comp.lang.lisp)