unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* need help debugging edebug (Common lisp problem?)
@ 2010-12-14  6:00 rusi
  2010-12-14 14:59 ` Pascal J. Bourguignon
       [not found] ` <87vd2w43zf.fsf@fh-trier.de>
  0 siblings, 2 replies; 4+ messages in thread
From: rusi @ 2010-12-14  6:00 UTC (permalink / raw)
  To: help-gnu-emacs

The following function (from http://delysid.org/emacs/midi.el )
crashes edebug.
It gives

edebug-syntax-error: Invalid read syntax: "Failed matching",
([&optional ["named" symbolp]] [&rest &or ["repeat" form] loop-for-as
loop-with loop-initial-final] [&rest loop-clause])

Note: It loads correctly (or rather silently) if edebug is turned off

I have a feeling its in the loop (cl) macro. Can someone who knows CL
better have a look?

(defun smf-read-mtrk (length)
  "Read one MTrk chunk.
NoteOn/NoteOff and NoteOn/NoteOn(vel=0) event
pairs are unified into a Note event with a certain duration."
  (let ((end (+ (point) length))
	(notes (make-vector 16 nil))
	(ticks 0) (running-status 0))
    (dotimes (i 16) (aset notes i (make-vector 128 nil)))
    (loop while (< (point) end)
	  do (incf ticks (smf-read-varlen))
	  for event =
	  (let ((status (following-char)))
	    (if (/= (logand status #B10000000 ) #B10000000 )
		(if (= running-status 0)
		    (error "Seen data byte without running status")
		  (setq status running-status))
	      (forward-char 1))
	    (unless (= status #XFF ) (setq running-status status))
	    (let ((lower (logand status #X0F )))
	      (case (ash status -4)
		(8  (let* ((note (smf-read-byte)) (vel (smf-read-byte))
			   (old-note (aref (aref notes lower) note)))
		      (if (not old-note)
			  (list 'NoteOff lower note vel)
			(setcar (cdr old-note) 'Note)
			(setcdr (nthcdr 4 old-note)
				(list (- ticks (car old-note)) vel))
			(aset (aref notes lower) note nil))))
		(9  (let* ((note (smf-read-byte)) (vel (smf-read-byte))
			   (data (cons ticks (list 'NoteOn lower note vel))))
		      (if (= vel 0)
			  (let ((old-note (aref (aref notes lower) note)))
			    (if (not old-note)
				(cdr data)
			      (setcar (cdr old-note) 'Note)
			      (setcdr (nthcdr 4 old-note)
				      (list (- ticks (car old-note))))
			      (aset (aref notes lower) note nil)))
			(cdr (aset (aref notes lower) note data)))))
		(10 (list 'At lower (smf-read-byte) (smf-read-byte)))
		(11 (list 'CC lower (smf-read-byte) (smf-read-byte)))
		(12 (list 'PC lower (smf-read-byte)))
		(13 (list 'CP lower (smf-read-byte)))
		(14 (list 'PW lower (logior (smf-read-byte)
					    (lsh (smf-read-byte) 7))))
		(15 (case lower
		      (0  (append (list 'SysEx)
				  (loop repeat (smf-read-varlen) collect
					(smf-read-byte))))
		      (2  (let ((value (logior (smf-read-byte)
					       (lsh (smf-read-byte) 7))))
			    (list 'SongPosition value)))
		      (3  (list 'SongSelect (smf-read-byte)))
		      (6  (list 'TuneRequest))
		      (8  (list 'Clock))
		      (9  (list 'Tick))
		      (10 (list 'Start))
		      (11 (list 'Continue))
		      (12 (list 'Stop))
		      (14 (list 'ActiveSense))
		      (15 (smf-read-meta-event))
		      (t (error "Unknown stuff")))))))
	  until (eq event t) when event collect (cons ticks event))))


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: need help debugging edebug (Common lisp problem?)
  2010-12-14  6:00 need help debugging edebug (Common lisp problem?) rusi
@ 2010-12-14 14:59 ` Pascal J. Bourguignon
  2010-12-14 20:47   ` bolega
       [not found] ` <87vd2w43zf.fsf@fh-trier.de>
  1 sibling, 1 reply; 4+ messages in thread
From: Pascal J. Bourguignon @ 2010-12-14 14:59 UTC (permalink / raw)
  To: help-gnu-emacs

rusi <rustompmody@gmail.com> writes:

> The following function (from http://delysid.org/emacs/midi.el )
> crashes edebug.
> It gives
>
> edebug-syntax-error: Invalid read syntax: "Failed matching",
> ([&optional ["named" symbolp]] [&rest &or ["repeat" form] loop-for-as
> loop-with loop-initial-final] [&rest loop-clause])
>
> Note: It loads correctly (or rather silently) if edebug is turned off
>
> I have a feeling its in the loop (cl) macro. Can someone who knows CL
> better have a look?

And I have the feeling that this function is too big.  It definitely
goes over my multi-mega-pixel display.  Perhaps you should refactor it.


Otherwise, if you have a problem with a macro, you can always
macroexpand it to see what it does.  Of course, if you start with a
multi-page form, it won't get better.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: need help debugging edebug (Common lisp problem?)
  2010-12-14 14:59 ` Pascal J. Bourguignon
@ 2010-12-14 20:47   ` bolega
  0 siblings, 0 replies; 4+ messages in thread
From: bolega @ 2010-12-14 20:47 UTC (permalink / raw)
  To: help-gnu-emacs

On Dec 14, 6:59 am, "Pascal J. Bourguignon" <p...@informatimago.com>
wrote:
> rusi <rustompm...@gmail.com> writes:
> > The following function (fromhttp://delysid.org/emacs/midi.el)
> > crashes edebug.
> > It gives
>
> > edebug-syntax-error: Invalid read syntax: "Failed matching",
> > ([&optional ["named" symbolp]] [&rest &or ["repeat" form] loop-for-as
> > loop-with loop-initial-final] [&rest loop-clause])
>
> > Note: It loads correctly (or rather silently) if edebug is turned off
>
> > I have a feeling its in the loop (cl) macro. Can someone who knows CL
> > better have a look?
>
> And I have the feeling that this function is too big.  It definitely
> goes over my multi-mega-pixel display.  Perhaps you should refactor it.

show him how to refactor it and iff possible to me how to read it.

once you wrote that one who knows CL can read it without the need of
comments just like english prose.

> Otherwise, if you have a problem with a macro, you can always
> macroexpand it to see what it does.  Of course, if you start with a
> multi-page form, it won't get better.
>
> --
> __Pascal Bourguignon__                    http://www.informatimago.com/
> A bad day in () is better than a good day in {}.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: need help debugging edebug (Common lisp problem?)
       [not found] ` <87vd2w43zf.fsf@fh-trier.de>
@ 2010-12-15  3:50   ` Rustom Mody
  0 siblings, 0 replies; 4+ messages in thread
From: Rustom Mody @ 2010-12-15  3:50 UTC (permalink / raw)
  To: Andreas Politz; +Cc: help-gnu-emacs

On Tue, Dec 14, 2010 at 11:43 PM, Andreas Politz <politza@fh-trier.de> wrote:
> rusi <rustompmody@gmail.com> writes:
>
>> The following function (from http://delysid.org/emacs/midi.el )
>> crashes edebug.
>> It gives
>>
>> edebug-syntax-error: Invalid read syntax: "Failed matching",
>> ([&optional ["named" symbolp]] [&rest &or ["repeat" form] loop-for-as
>> loop-with loop-initial-final] [&rest loop-clause])
>>
>> Note: It loads correctly (or rather silently) if edebug is turned off
>>
>> I have a feeling its in the loop (cl) macro. Can someone who knows CL
>> better have a look?
>>
>>     (loop while (< (point) end)
>>         do (incf ticks (smf-read-varlen))
>>         for event =
>>         (let ((status (following-char)))
> [...]
>>                     (t (error "Unknown stuff")))))))
>>         until (eq event t) when event collect (cons ticks event))))
>
> Is the loop syntax correct ? If so the edebug-spec of the loop macro is
> wrong.

I dont know (intricacies of) common lisp.
But (AFAIK) this is working code in emacs before version 23 -- I got
this file from the linux audio list
http://lists.linuxaudio.org/pipermail/linux-audio-user/2010-December/074658.html
so I guess a number of people have used/are using it.
So I thought I'd file this bug
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7639

To reiterate: the el file loads quietly without edebug but edebug
barfs (in emacs 23) so there is some mismatch somewhere.
Since the code does not work it could be a (default) elisp problem and
edebug may be correct -- dunno.

Thanks Andreas anyhow for looking.

Rusi



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-12-15  3:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-14  6:00 need help debugging edebug (Common lisp problem?) rusi
2010-12-14 14:59 ` Pascal J. Bourguignon
2010-12-14 20:47   ` bolega
     [not found] ` <87vd2w43zf.fsf@fh-trier.de>
2010-12-15  3:50   ` Rustom Mody

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).