* symbol equality --cl-rest-- help-function-arglist member vs member* and also equal, eql, and eq
@ 2009-12-22 1:16 MON KEY
2009-12-22 2:22 ` Miles Bader
2009-12-22 2:32 ` Stephen J. Turnbull
0 siblings, 2 replies; 5+ messages in thread
From: MON KEY @ 2009-12-22 1:16 UTC (permalink / raw)
To: emacs-devel
Why do symbol equality tests/comparisons with --cl-rest-- and
`help-function-arglist' be so freaky?
The only references I can find to --cl-rest-- in non-byte-compiled code are in:
`cl-do-arglist' -> cl-macs.el'
`cl-macroexpand-all' -> cl-extra.el
Is there a reason for the following behavior that I'm missing or is
this a bug (of some sort)?
;;; ==============================
(defun* test-cl-rest (arg1 arg2 &key arg-key)
arg-key)
(test-cl-rest nil nil :arg-key "bubba")
;=> "bubba"
(help-function-arglist 'test-cl-rest)
;=> (arg1 arg2 &rest --cl-rest--)
(member '&rest
(help-function-arglist 'test-cl-rest))
;=> (&rest --cl-rest--)
(member '--cl-rest--
(help-function-arglist 'test-cl-rest))
;=> nil
(cadr (member '&rest (help-function-arglist 'test-cl-rest)))
;=> --cl-rest--
(cadr (member* '&rest '(bubba &rest --cl-rest--)))
;=> --cl-rest--
;; member & member
(equal
(cadr (member '&rest (help-function-arglist 'test-cl-rest)))
(cadr (member '&rest (help-function-arglist 'test-cl-rest))))
;=> t
;; member* & member*
(equal
(cadr (member* '&rest '(bubba &rest --cl-rest--)))
(cadr (member* '&rest '(bubba &rest --cl-rest--))))
;=> t
;; member & member*
(equal
(cadr (member '&rest (help-function-arglist 'test-cl-rest)))
(cadr (member* '&rest (help-function-arglist 'test-cl-rest))))
;=> t
;; member of arg list
(equal '--cl-rest-- (cadr (member '&rest (help-function-arglist
'test-cl-rest))))
;=> nil
;; member* of arg list
(equal '--cl-rest-- (cadr (member* '&rest (help-function-arglist
'test-cl-rest))))
;=> nil
;; member same symbol new list
(member '--cl-rest-- (member '&rest '(bubba &rest --cl-rest--)))
;=> (--cl-rest--)
;; member* same symbol new list
(member* '--cl-rest-- (member* '&rest '(bubba &rest --cl-rest--)))
;=> (--cl-rest--)
;; member same symbol new list
(equal '--cl-rest-- (car (member '--cl-rest-- (member '&rest '(bubba
&rest --cl-rest--)))))
;=> t
;; member* same symbol new list
(equal '--cl-rest-- (car (member* '--cl-rest-- (member* '&rest '(bubba
&rest --cl-rest--)))))
;=> t
;; member
(let (a)
(setq a (member '&rest (help-function-arglist 'test-cl-rest)))
(equal '--cl-rest-- (cadr a)))
;=> nil
;; member*
(let (a)
(setq a (cadr (member* '&rest (help-function-arglist 'test-cl-rest))))
(equal '--cl-rest-- a))
;=> nil
(let (c)
(mapc #'(lambda (y) (when (or (eq y '--cl-rest)
(eql y '--cl-rest--)
(equal y '--cl-rest--))
(push y c )))
(help-function-arglist 'test-cl-rest))
c)
;=> nil
(equal (car '(--cl-rest--)) (car '(--cl-rest--)))
;=> t
(eql (car '(--cl-rest--)) (car '(--cl-rest--)))
;=> t
(eq (car '(--cl-rest-- 666)) (cadr '(666 --cl-rest--)))
;=> t
;; memq/member
(memq '--cl-rest-- (member '&rest (help-function-arglist 'test-cl-rest)))
;=> nil
;; memql/member
(memql '--cl-rest-- (member '&rest (help-function-arglist 'test-cl-rest)))
;=> nil
;; memq/member*
(memq '--cl-rest-- (member* '&rest (help-function-arglist 'test-cl-rest)))
=> nil
;; memq/member*
(memql '--cl-rest-- (member* '&rest (help-function-arglist 'test-cl-rest)))
=> nil
;; memql/member same-symbol new list
(memql '--cl-rest-- (member '&rest '(bubba &rest --cl-rest--)))
;=> (--cl-rest--)
;; memq same-symbol new list
(memq '--cl-rest-- '(arg1 arg2 &rest --cl-rest-- bubba))
;=> (--cl-rest-- bubba)
;; member*
(memql (cadr (member* '&rest '(bubba &rest --cl-rest--)))
(help-function-arglist 'test-cl-rest))
;=> nil
;;; ==============================
s_P
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: symbol equality --cl-rest-- help-function-arglist member vs member* and also equal, eql, and eq
2009-12-22 1:16 symbol equality --cl-rest-- help-function-arglist member vs member* and also equal, eql, and eq MON KEY
@ 2009-12-22 2:22 ` Miles Bader
2009-12-22 23:57 ` MON KEY
2009-12-22 2:32 ` Stephen J. Turnbull
1 sibling, 1 reply; 5+ messages in thread
From: Miles Bader @ 2009-12-22 2:22 UTC (permalink / raw)
To: MON KEY; +Cc: emacs-devel
MON KEY <monkey@sandpframing.com> writes:
> Is there a reason for the following behavior that I'm missing
It looks like `--cl-rest--' is an uninterned symbol.
This is a good thing.
-Miles
--
Cannon, n. An instrument employed in the rectification of national boundaries.
^ permalink raw reply [flat|nested] 5+ messages in thread
* symbol equality --cl-rest-- help-function-arglist member vs member* and also equal, eql, and eq
2009-12-22 1:16 symbol equality --cl-rest-- help-function-arglist member vs member* and also equal, eql, and eq MON KEY
2009-12-22 2:22 ` Miles Bader
@ 2009-12-22 2:32 ` Stephen J. Turnbull
1 sibling, 0 replies; 5+ messages in thread
From: Stephen J. Turnbull @ 2009-12-22 2:32 UTC (permalink / raw)
To: MON KEY; +Cc: emacs-devel
MON KEY writes:
> Why do symbol equality tests/comparisons with --cl-rest-- and
> `help-function-arglist' be so freaky?
Apparently --cl-rest-- is an uninterned symbol. This is done so that
the symbol cannot shadow an definition in code outside the cl-arglist
processing module.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: symbol equality --cl-rest-- help-function-arglist member vs member* and also equal, eql, and eq
2009-12-22 2:22 ` Miles Bader
@ 2009-12-22 23:57 ` MON KEY
2009-12-23 8:59 ` David Kastrup
0 siblings, 1 reply; 5+ messages in thread
From: MON KEY @ 2009-12-22 23:57 UTC (permalink / raw)
To: emacs-devel; +Cc: stephen, miles
Stephen
> Apparently --cl-rest-- is an uninterned symbol. This is done so that
> the symbol cannot shadow an definition in code outside the cl-arglist
> processing module.
Miles
> It looks like `--cl-rest--' is an uninterned symbol.
> This is a good thing.
Ok, thanks to you both for explaining.
However, I'm not able to make that to jibe... still missing something
I'm sure.
I understand why there needs to be a reserved 'anonymous' symbol for the
--rest-of-cl-- e.g. --cl-rest-- and that this symbol should remain uninterned
but what I am missing on is why --cl-keys-- is converted to `cl-keys' whereas
--cl-rest-- can't/isn't in the `cl-do-arglist' function? For example,
In the following both `body' and `--cl-rest--' show as being interned whereas
the `*-wombats' aren't:
(intern-soft "body") ;=> t
(intern-soft "--cl-rest--") ;=> t
(intern-soft "scary-flying-wombats") ;=> nil
(mapatoms (lambda (x)
(when (string= (symbol-name x)
;; "body") ;=> (found body)
;; "--cl-rest--") ;=> (found --cl-rest--)
"scary-flying-wombats") ;=> nil
(prin1 `(found ,x))))
obarray)
(intern-soft "more-wombats") ;=> nil
(make-symbol "more-wombats") ;=> more-wombats
(mapatoms (lambda (x)
(when (string= (symbol-name x) "more-wombats")
(prin1 `(found ,x))))
obarray)
;=> nil
(member 'cl-keys (help-function-arglist 'reduce)) ;=> (cl-keys)
(member 'body (help-function-arglist 'unless)) ;=> (body)
(BTW Everything above was evaluated on two systems and with `emacs -Q'.
With the same results.)
Is not the the now-maybe arg/keyword acting acting in a manner similar
to &key's --cl-keys--, e.g. it
is let bound not setq'd:
(defun* 3rd-degree (q z w &key now-maybe)
(let ((3d (make-symbol "now-maybe")))
(when now-maybe
3d)))
(help-function-arglist '3rd-degree)
;=> (q z w &rest --cl-rest--)
(member 'now-maybe (help-function-arglist '3rd-degree))
;=> nil
(intern-soft "now-maybe")
;=> now-maybe
(mapatoms (lambda (x)
(when (string= (symbol-name x) "now-maybe")
(prin1 `(found ,x))))
obarray)
;=> (found now-maybe)
IOW `now-maybe' is interned directly via the let form whereas `--cl-rest--'
appears to be indirected through let via restarg in `cl-do-arglist' e.g.
(setq restarg (make-symbol "--cl-rest--")
I'm _not_ advocating a change but it would be good to understand vis a vis
Miles' admonition:
"That is a good thing."
What would be the consequences if user level keys following &rest i.e.
:mon-key0 :mon-key1
:mon-key2 _were_ to be interned directly (maybe on a partitioned
obarray) instead of
passing the buck to --cl-rest--?
Again, asked out of curiosity :)
s_P
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: symbol equality --cl-rest-- help-function-arglist member vs member* and also equal, eql, and eq
2009-12-22 23:57 ` MON KEY
@ 2009-12-23 8:59 ` David Kastrup
0 siblings, 0 replies; 5+ messages in thread
From: David Kastrup @ 2009-12-23 8:59 UTC (permalink / raw)
To: emacs-devel
MON KEY <monkey@sandpframing.com> writes:
> Stephen
>> Apparently --cl-rest-- is an uninterned symbol. This is done so that
>> the symbol cannot shadow an definition in code outside the cl-arglist
>> processing module.
>
> Miles
>> It looks like `--cl-rest--' is an uninterned symbol.
>> This is a good thing.
>
> Ok, thanks to you both for explaining.
>
> However, I'm not able to make that to jibe... still missing something
> I'm sure.
>
> I understand why there needs to be a reserved 'anonymous' symbol for
> the --rest-of-cl-- e.g. --cl-rest-- and that this symbol should remain
> uninterned but what I am missing on is why --cl-keys-- is converted to
> `cl-keys' whereas --cl-rest-- can't/isn't in the `cl-do-arglist'
> function? For example,
>
> In the following both `body' and `--cl-rest--' show as being interned whereas
> the `*-wombats' aren't:
>
> (intern-soft "body") ;=> t
> (intern-soft "--cl-rest--") ;=> t
> (intern-soft "scary-flying-wombats") ;=> nil
For what it's worth, cl-macroexpand-all uses the _symbols_ body and
--cl-rest--. Note that even if you let-bind or lambda-bind a literal
symbol in Elisp, it gets interned permanently by the Lisp reader.
That does not mean that you can't use make-symbol to generate
_different_ symbols with the _same_ symbol-name.
--
David Kastrup
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-12-23 8:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-22 1:16 symbol equality --cl-rest-- help-function-arglist member vs member* and also equal, eql, and eq MON KEY
2009-12-22 2:22 ` Miles Bader
2009-12-22 23:57 ` MON KEY
2009-12-23 8:59 ` David Kastrup
2009-12-22 2:32 ` Stephen J. Turnbull
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.