[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Save `nil' from the mutant void, preserve the truth of falsehood, pr

Subject: Re: Save `nil' from the mutant void, preserve the truth of falsehood, prevent the falsehood of truth
Date: Sun, 12 Sep 2010 20:16:26 -0400

On Sun, Sep 12, 2010 at 10:00 AM, Stefan Monnier
<address@hidden> wrote:
>> Two one-liners not even a Perl devotee could love:
>> (prog1 #1=(fboundp ()) (unintern #1#))
> Let's see how many lines of defenses you broke in the above code:

So what?

These opening two examples were intentionally pathological (and
relatively harmless) There are certainly more prosaic
examples. Likewise, there a others that are far more destructive than
those provided.  Would you prefer I provide those in a public forum as

> - use of #1= in code: very bad.
Which code?

`#1=', and related reader syntax constructs aren't bad.

Indeed, they are quite prevalent in byte-code files and the language
would be hamstrung without them.

That there are any number of ways to (ab)use them is a case for
restricting the uninternment of two critical Lisp constants `t' and
`nil' (and especially nil).

> - unintern takes a symbol as argument, not a boolean, so it should
>   not be called with the return value of (fboundp ...)

No, the argument to `unintern' can be a symbol or string.

  (eval (read
          '(40 100 101 102 97 108 105 97 115 32 39 98 121 101 32
            40 105 110 100 105 114 101 99 116 45 102 117 110 99 116
            105 111 110 32 40 98 121 116 101 45 99 111 109 112 105
            108 101 32 35 39 40 108 97 109 98 100 97 32 40 120 41 32
            40 117 110 105 110 116 101 114 110 32 120 41 41 41 41 41)
  (bye (symbol-name 'bye))
  (fboundp 'bye))

> - calling unintern without an obarray arg is a bad idea.
a) Because there is really only one first class obarray.
b) because restriction aren't placed on certain constants in obarray.

> Maybe we should make the second argument mandatory.

That would be nice.

But, it should also require that the NAME arg _must_ be a string.
Better yet would be to also return the string on success:

This would allow interrogation of the obaray with success on failure:

 (not (intern-soft (unintern "bubba33" '<mandatory-ob>)))
 ;=> t

> The real nil is safely stored in a C variable `Qnil' which you should be
> able to get via something like (not t).

`nil' has to evaluate for both the empty list and a "symbol constant".
`(not t)' just makes it a "symbol constant".

See illustrations from previous example w/re to push.

> But I don't think Elisp lets you re-intern it,

I can't find a way.

> since `intern' only takes a string rather than a symbol.

Yeah, but again there is the weird corner case of interning the 0
length string.  Which, as shown in previous mail causes additional
headaches when attempting to re-intern a symbol.

emacs -Q

(let ((s1 (intern (symbol-name (make-symbol ""))))
      (s2 (intern (symbol-name '#:)))
  (setq cmp `((,#1=s1 ,#1#) (,#2=s2 ,#2#)))
  `(:S1-LEN ,(length (car cmp))
    :S1-LEN ,(length (cadr cmp))
    :S1-IS-S1 ,(eq (caar cmp) (car (cdar cmp)))
    :S2-IS-S2 ,(eq (car (cadr cmp)) (cadr (cadr cmp)))
    :CAR-S1-IS-CAR-S2 ,(eq (caar cmp) (car (cadr cmp)))
    :CADR-S1-IS-CADR-S2 ,(eq (car (cdar cmp)) (cadr (cadr cmp)))
    :S1-IDENTITY ,(identity s1)
    :S1-IDENTITY ,(identity s1)
    :S1-SYM-NAME ,(symbol-name s1)
    :S2-SYM-NAME ,(symbol-name s2)
    :S2-UNINTD   ,(unintern (car (cadr cmp)))
    :S1-UNINTD   ,(unintern (caar cmp))))

(:S1-LEN 2 :S1-LEN 2
 :S1-IS-S1 t :S2-IS-S2 t
 :S1-IDENTITY  :S1-IDENTITY  ;; <- Note, that _is_ an identity
 :S1-SYM-NAME "" :S2-SYM-NAME ""
 :S2-UNINTD t :S1-UNINTD nil)

>        Stefan


reply via email to

[Prev in Thread] Current Thread [Next in Thread]