Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Using Global Variables

Name: Anonymous 2010-12-26 13:42

... in a Library is worse than murder.

Satan himself will arise from the depths of Oblivion to tear apart your soul for that.

Name: Anonymous 2010-12-26 23:09

>>17
Here's some evil, but non code breaking code:

#.`(cl:defpackage #:inverse-lisp
     (:use #:cl)
     (:shadow #:car #:cdr)
     (:export
      ,@(cl:loop :for sym :being :the :external-symbol :of (find-package :cl)
                 :collect sym)))

(cl:in-package #:inverse-lisp)

(defun car (list) (cl:cdr list))
(defun cdr (list) (cl:car list))

(cl:defpackage #:inverse-lisp-user
  (:use #:inverse-lisp))

(cl:in-package #:inverse-lisp-user)

(car (cons 1 2)) ;=> 2
(cdr (cons 1 2)) ;=> 1


Of course, one could also redefine (this breaks the standard, but would actually work in most implementations) cons/car/cdr such that the positions would be reversed, but you'd just break most of the existing code, not to mention that cons/car/cdr are pretty much always inlined  in any serious implementation (car/cdr being just a simple asm instruction in most cases, while cons just calls a quick allocator and assigns the 2 fields.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List