* change in call-next-method
@ 2016-01-03 11:38 Stephen Leake
0 siblings, 0 replies; 7+ messages in thread
From: Stephen Leake @ 2016-01-03 11:38 UTC (permalink / raw)
To: emacs-devel
I'm updating JDEE to Emacs 25. It has several functions like this:
(cl-defmethod initialize-instance ((this jdee-jddocset) &rest rest)
(apply 'call-next-method rest)
(unless (oref this description)
(oset this :description
(if (oref this jdkp)
(format "JDK %s Javadoc" (oref this version))
(let ((file (jdee-url-file (oref this url))))
(if (string-match ".*\\/\\(.*?\\)\\/doc\\/api" file)
(match-string 1 file)
(jdee-url-name (oref this url))))))))
This breaks if I just change call-next-method to cl-call-next-method. In
Emacs 24, `call-next-method' is a defun that does the right thing here
(calls the default superclass init). In Emacs 25, cl-call-next-method is
a defun that throws an error; cl-defmethod is supposed to replace plain
calls to cl-call-next-method with an in-line call to the appropriate
method.
As far as I can tell, the only reason for the call to call-next-method
is to process the constructor args in `rest', storing them in the
appropriate slots.
What is the right way to do that in Emacs 25? I don't see anything in
the CL manual about this, and I can't find the relevant code by reading
the implementations of cl-defmethod or cl-generic.
--
-- Stephe
^ permalink raw reply [flat|nested] 7+ messages in thread
* change in call-next-method
@ 2016-01-03 11:37 Stephen Leake
2016-01-03 12:06 ` Andreas Schwab
0 siblings, 1 reply; 7+ messages in thread
From: Stephen Leake @ 2016-01-03 11:37 UTC (permalink / raw)
To: emacs-devel
I'm updating JDEE to Emacs 25. It has several functions like this:
(cl-defmethod initialize-instance ((this jdee-jddocset) &rest rest)
(apply 'call-next-method rest)
(unless (oref this description)
(oset this :description
(if (oref this jdkp)
(format "JDK %s Javadoc" (oref this version))
(let ((file (jdee-url-file (oref this url))))
(if (string-match ".*\\/\\(.*?\\)\\/doc\\/api" file)
(match-string 1 file)
(jdee-url-name (oref this url))))))))
This breaks if I just change call-next-method to cl-call-next-method. In
Emacs 24, `call-next-method' is a defun that does the right thing here
(calls the default superclass init). In Emacs 25, cl-call-next-method is
a defun that throws an error; cl-defmethod is supposed to replace plain
calls to cl-call-next-method with an in-line call to the appropriate
method.
As far as I can tell, the only reason for the call to call-next-method
is to process the constructor args in `rest', storing them in the
appropriate slots.
What is the right way to do that in Emacs 25? I don't see anything in
the CL manual about this, and I can't find the relevant code by reading
the implementations of cl-defmethod or cl-generic.
--
-- Stephe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: change in call-next-method
2016-01-03 11:37 Stephen Leake
@ 2016-01-03 12:06 ` Andreas Schwab
2016-01-03 13:43 ` Stephen Leake
0 siblings, 1 reply; 7+ messages in thread
From: Andreas Schwab @ 2016-01-03 12:06 UTC (permalink / raw)
To: Stephen Leake; +Cc: emacs-devel
Stephen Leake <stephen_leake@stephe-leake.org> writes:
> I'm updating JDEE to Emacs 25. It has several functions like this:
>
> (cl-defmethod initialize-instance ((this jdee-jddocset) &rest rest)
> (apply 'call-next-method rest)
> (unless (oref this description)
> (oset this :description
> (if (oref this jdkp)
> (format "JDK %s Javadoc" (oref this version))
> (let ((file (jdee-url-file (oref this url))))
> (if (string-match ".*\\/\\(.*?\\)\\/doc\\/api" file)
> (match-string 1 file)
> (jdee-url-name (oref this url))))))))
>
> This breaks if I just change call-next-method to cl-call-next-method.
How do you change it? I think you are supposed to call it as
(cl-call-next-method).
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: change in call-next-method
2016-01-03 12:06 ` Andreas Schwab
@ 2016-01-03 13:43 ` Stephen Leake
2016-01-03 14:48 ` Eric Abrahamsen
2016-01-03 21:48 ` Stephen Leake
0 siblings, 2 replies; 7+ messages in thread
From: Stephen Leake @ 2016-01-03 13:43 UTC (permalink / raw)
To: Andreas Schwab; +Cc: emacs-devel
Andreas Schwab <schwab@linux-m68k.org> writes:
> Stephen Leake <stephen_leake@stephe-leake.org> writes:
>
>> I'm updating JDEE to Emacs 25. It has several functions like this:
>>
>> (cl-defmethod initialize-instance ((this jdee-jddocset) &rest rest)
>> (apply 'call-next-method rest)
>> (unless (oref this description)
>> (oset this :description
>> (if (oref this jdkp)
>> (format "JDK %s Javadoc" (oref this version))
>> (let ((file (jdee-url-file (oref this url))))
>> (if (string-match ".*\\/\\(.*?\\)\\/doc\\/api" file)
>> (match-string 1 file)
>> (jdee-url-name (oref this url))))))))
>>
>> This breaks if I just change call-next-method to cl-call-next-method.
>
> How do you change it?
I tried:
(apply 'cl-call-next-method rest)
(cl-call-next-method rest)
They both give the error:
cl-call-next-method: cl-call-next-method only allowed inside primary and around methods
> I think you are supposed to call it as
> (cl-call-next-method).
That gives the same error.
Note that I don't actually need to call the superclass init; I just need
to process the args in `rest', storing them in the slots.
I can write code that does it:
(let ((description (plist-get rest :description))
(url (plist-get rest :url))
(jdkp (plist-get rest :jdkp))
(version (plist-get rest :version)))
(when description
(oset this :description description))
(when url
(oset this :url url))
(when jdkp
(oset this :jdkp jdkp))
(when version
(oset this :version version)))
but that's tedious and error-prone.
--
-- Stephe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: change in call-next-method
2016-01-03 13:43 ` Stephen Leake
@ 2016-01-03 14:48 ` Eric Abrahamsen
2016-01-03 18:05 ` Stephen Leake
2016-01-03 21:48 ` Stephen Leake
1 sibling, 1 reply; 7+ messages in thread
From: Eric Abrahamsen @ 2016-01-03 14:48 UTC (permalink / raw)
To: emacs-devel
Stephen Leake <stephen_leake@stephe-leake.org> writes:
> Andreas Schwab <schwab@linux-m68k.org> writes:
>
>> Stephen Leake <stephen_leake@stephe-leake.org> writes:
>>
>>> I'm updating JDEE to Emacs 25. It has several functions like this:
>>>
>>> (cl-defmethod initialize-instance ((this jdee-jddocset) &rest rest)
>>> (apply 'call-next-method rest)
>>> (unless (oref this description)
>>> (oset this :description
>>> (if (oref this jdkp)
>>> (format "JDK %s Javadoc" (oref this version))
>>> (let ((file (jdee-url-file (oref this url))))
>>> (if (string-match ".*\\/\\(.*?\\)\\/doc\\/api" file)
>>> (match-string 1 file)
>>> (jdee-url-name (oref this url))))))))
>>>
>>> This breaks if I just change call-next-method to cl-call-next-method.
>>
>> How do you change it?
>
> I tried:
>
> (apply 'cl-call-next-method rest)
> (cl-call-next-method rest)
>
> They both give the error:
>
> cl-call-next-method: cl-call-next-method only allowed inside primary and around methods
>
>> I think you are supposed to call it as
>> (cl-call-next-method).
>
> That gives the same error.
>
> Note that I don't actually need to call the superclass init; I just need
> to process the args in `rest', storing them in the slots.
I think if you replace any of the args, you need to replace *all* of the
args. Ie, either:
(cl-call-next-method) ; in which case your changes to REST are ignored
or
(cl-call-next-method this rest)
Otherwise, it's just the wrong number of arguments.
I may be missing something, but...
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: change in call-next-method
2016-01-03 14:48 ` Eric Abrahamsen
@ 2016-01-03 18:05 ` Stephen Leake
0 siblings, 0 replies; 7+ messages in thread
From: Stephen Leake @ 2016-01-03 18:05 UTC (permalink / raw)
To: Eric Abrahamsen; +Cc: emacs-devel
Eric Abrahamsen <eric@ericabrahamsen.net> writes:
> Stephen Leake <stephen_leake@stephe-leake.org> writes:
>
>> Andreas Schwab <schwab@linux-m68k.org> writes:
>>
>>> Stephen Leake <stephen_leake@stephe-leake.org> writes:
>>>
>>>> I'm updating JDEE to Emacs 25. It has several functions like this:
>>>>
>>>> (cl-defmethod initialize-instance ((this jdee-jddocset) &rest rest)
>>>> (apply 'call-next-method rest)
>>>> (unless (oref this description)
>>>> (oset this :description
>>>> (if (oref this jdkp)
>>>> (format "JDK %s Javadoc" (oref this version))
>>>> (let ((file (jdee-url-file (oref this url))))
>>>> (if (string-match ".*\\/\\(.*?\\)\\/doc\\/api" file)
>>>> (match-string 1 file)
>>>> (jdee-url-name (oref this url))))))))
>>>>
>>>> This breaks if I just change call-next-method to cl-call-next-method.
>>>
>>> How do you change it?
>>
>> I tried:
>>
>> (apply 'cl-call-next-method rest)
>> (cl-call-next-method rest)
>>
>> They both give the error:
>>
>> cl-call-next-method: cl-call-next-method only allowed inside primary and around methods
>>
>>> I think you are supposed to call it as
>>> (cl-call-next-method).
>>
>> That gives the same error.
>>
>> Note that I don't actually need to call the superclass init; I just need
>> to process the args in `rest', storing them in the slots.
>
> I think if you replace any of the args, you need to replace *all* of the
> args. Ie, either:
>
> (cl-call-next-method) ; in which case your changes to REST are ignored
>
> or
>
> (cl-call-next-method this rest)
>
> Otherwise, it's just the wrong number of arguments.
Same error.
> I may be missing something, but...
I think this error is due to trying to call the parent method, when
there isn't one:
(defclass jdee-jddocset ()
<slots>...
)
In Emacs 24.5, that calls the default superclass method. Apparently that
call doesn't work properly in Emacs 25.
There is an initialize-instance defined for the default superclass; in
eieio.el:
(cl-defmethod initialize-instance ((this eieio-default-superclass)
&optional slots)
"Construct the new object THIS based on SLOTS.
SLOTS is a tagged list where odd numbered elements are tags, and
even numbered elements are the values to store in the tagged slot.
If you overload the `initialize-instance', there you will need to
call `shared-initialize' yourself, or you can call `call-next-method'
to have this constructor called automatically. If these steps are
not taken, then new objects of your class will not have their values
dynamically set from SLOTS."
;; First, see if any of our defaults are `lambda', and
;; re-evaluate them and apply the value to our slots.
(let* ((this-class (eieio--object-class this))
(slots (eieio--class-slots this-class)))
(dotimes (i (length slots))
;; For each slot, see if we need to evaluate it.
;;
;; Paul Landes said in an email:
;; > CL evaluates it if it can, and otherwise, leaves it as
;; > the quoted thing as you already have. This is by the
;; > Sonya E. Keene book and other things I've look at on the
;; > web.
(let* ((slot (aref slots i))
(initform (cl--slot-descriptor-initform slot))
(dflt (eieio-default-eval-maybe initform)))
(when (not (eq dflt initform))
;; FIXME: We should be able to just do (aset this (+ i <cst>) dflt)!
(eieio-oset this (cl--slot-descriptor-name slot) dflt)))))
;; Shared initialize will parse our slots for us.
(shared-initialize this slots))
That seems to be the code I'm looking for. Maybe with this clue I can
figure out why the call fails.
--
-- Stephe
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: change in call-next-method
2016-01-03 13:43 ` Stephen Leake
2016-01-03 14:48 ` Eric Abrahamsen
@ 2016-01-03 21:48 ` Stephen Leake
1 sibling, 0 replies; 7+ messages in thread
From: Stephen Leake @ 2016-01-03 21:48 UTC (permalink / raw)
To: Andreas Schwab; +Cc: emacs-devel
Stephen Leake <stephen_leake@stephe-leake.org> writes:
> Andreas Schwab <schwab@linux-m68k.org> writes:
>
>> Stephen Leake <stephen_leake@stephe-leake.org> writes:
>>
>>> I'm updating JDEE to Emacs 25. It has several functions like this:
>>>
>>> (cl-defmethod initialize-instance ((this jdee-jddocset) &rest rest)
>>> (apply 'call-next-method rest)
>>> (unless (oref this description)
>>> (oset this :description
>>> (if (oref this jdkp)
>>> (format "JDK %s Javadoc" (oref this version))
>>> (let ((file (jdee-url-file (oref this url))))
>>> (if (string-match ".*\\/\\(.*?\\)\\/doc\\/api" file)
>>> (match-string 1 file)
>>> (jdee-url-name (oref this url))))))))
>>>
>>> This breaks if I just change call-next-method to cl-call-next-method.
>>
>> How do you change it?
>
> I tried:
>
> (apply 'cl-call-next-method rest)
> (cl-call-next-method rest)
>
> They both give the error:
>
> cl-call-next-method: cl-call-next-method only allowed inside primary and around methods
>
>> I think you are supposed to call it as
>> (cl-call-next-method).
>
> That gives the same error.
I take it back. In my simplified test code, I was using "defmethod"
instead of "cl-defmethod". Fixing that, and using your suggestion, fixes
the original problem.
Thanks.
--
-- Stephe
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-01-03 21:48 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-03 11:38 change in call-next-method Stephen Leake
-- strict thread matches above, loose matches on Subject: below --
2016-01-03 11:37 Stephen Leake
2016-01-03 12:06 ` Andreas Schwab
2016-01-03 13:43 ` Stephen Leake
2016-01-03 14:48 ` Eric Abrahamsen
2016-01-03 18:05 ` Stephen Leake
2016-01-03 21:48 ` Stephen Leake
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.