unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* edebug specs for cl-loop
@ 2012-08-04  9:58 Thierry Volpiatto
  2012-08-06 21:57 ` Stefan Monnier
  0 siblings, 1 reply; 15+ messages in thread
From: Thierry Volpiatto @ 2012-08-04  9:58 UTC (permalink / raw)
  To: emacs-devel

Hi,
the edebug specs for cl-loop that are commented in cl-macs.el
are helpfuls, even if they do not work everywhere.
(They work actually in many loops, not all though)
Maybe they can be enabled?
They would be better than nothing even if they are not fully working.
WDYT?

-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




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

* Re: edebug specs for cl-loop
  2012-08-04  9:58 edebug specs for cl-loop Thierry Volpiatto
@ 2012-08-06 21:57 ` Stefan Monnier
  2012-08-07  5:08   ` Thierry Volpiatto
  0 siblings, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2012-08-06 21:57 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: emacs-devel

> the edebug specs for cl-loop that are commented in cl-macs.el
> are helpfuls, even if they do not work everywhere.
> (They work actually in many loops, not all though)
> Maybe they can be enabled?

I don't have any experience with them, and only little experience with
`loop' in general, so it is hard for me to judge.

If you could describe the cases where the current spec doesn't work, and
the cases where the complex spec works better as well as where it fails
(and whether the current spec also fails for those), that would be
very helpful.

> They would be better than nothing even if they are not fully working.

AFAIK the default is to use (&rest &or symbolp form) as debug spec,
which should already be a good bit better than nothing.


        Stefan



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

* Re: edebug specs for cl-loop
  2012-08-06 21:57 ` Stefan Monnier
@ 2012-08-07  5:08   ` Thierry Volpiatto
  2012-08-07  6:55     ` Thierry Volpiatto
  0 siblings, 1 reply; 15+ messages in thread
From: Thierry Volpiatto @ 2012-08-07  5:08 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> the edebug specs for cl-loop that are commented in cl-macs.el
>> are helpfuls, even if they do not work everywhere.
>> (They work actually in many loops, not all though)
>> Maybe they can be enabled?
>
> I don't have any experience with them, and only little experience with
> `loop' in general, so it is hard for me to judge.
I use loop everywhere now, but I never used `def-edebug-spec'.

> If you could describe the cases where the current spec doesn't work, and
> the cases where the complex spec works better as well as where it fails
> (and whether the current spec also fails for those), that would be
> very helpful.
Ok I will try to collect some examples where it work and not (most work
actually). 

>> They would be better than nothing even if they are not fully working.
>
> AFAIK the default is to use (&rest &or symbolp form) as debug spec,
I don't know this, I tried to look at documentation, but it seem very
limited (`def-edebug-spec').

> which should already be a good bit better than nothing.
Yes, I am using them actually and they are really helpful.

-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 



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

* Re: edebug specs for cl-loop
  2012-08-07  5:08   ` Thierry Volpiatto
@ 2012-08-07  6:55     ` Thierry Volpiatto
  2012-08-07  7:17       ` Thierry Volpiatto
                         ` (2 more replies)
  0 siblings, 3 replies; 15+ messages in thread
From: Thierry Volpiatto @ 2012-08-07  6:55 UTC (permalink / raw)
  To: emacs-devel

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

>> If you could describe the cases where the current spec doesn't work, and
>> the cases where the complex spec works better as well as where it fails
>> (and whether the current spec also fails for those), that would be
>> very helpful.
> Ok I will try to collect some examples where it work and not (most work
> actually).
This is with your edebug-specs that are commented in cl-macs loaded.
 
Here an example that loop understand but not edebug:

loop and edebug understand this:

        for alphaindex = (random* (length alph))
        for rand2 = (aref alph alphaindex)
        collect rand1 into ls
        collect rand2 into ls

loop understand this but not edebug: (Note where the for rand2 line is now)

        for alphaindex = (random* (length alph))
        collect rand1 into ls
        for rand2 = (aref alph alphaindex)
        collect rand2 into ls

The both do the same.

Another one:

loop and edebug understand this:

          with len = (length (window-list))
          for count from 1
          for w1 = (iter-next wlist)
          for b1 = (window-buffer w1)
          for s1 = (window-start w1)
          for w2 = (iter-next wlist)
          for b2 = (window-buffer w2)
          for s2 = (window-start w2)
          while (< count len)

loop understand this but not edebug: (note where the while line is now)

          with len = (length (window-list))
          for count from 1
          while (< count len)
          for w1 = (iter-next wlist)
          for b1 = (window-buffer w1)
          for s1 = (window-start w1)
          for w2 = (iter-next wlist)
          for b2 = (window-buffer w2)
          for s2 = (window-start w2)
          
Both give same result.


-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




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

* Re: edebug specs for cl-loop
  2012-08-07  6:55     ` Thierry Volpiatto
@ 2012-08-07  7:17       ` Thierry Volpiatto
  2012-08-07 15:12         ` Stefan Monnier
  2012-08-07 15:11       ` Stefan Monnier
  2012-08-08 12:00       ` Lars Brinkhoff
  2 siblings, 1 reply; 15+ messages in thread
From: Thierry Volpiatto @ 2012-08-07  7:17 UTC (permalink / raw)
  To: emacs-devel

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:

> Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
>
>>> If you could describe the cases where the current spec doesn't work, and
>>> the cases where the complex spec works better as well as where it fails
>>> (and whether the current spec also fails for those), that would be
>>> very helpful.
>> Ok I will try to collect some examples where it work and not (most work
>> actually).
> This is with your edebug-specs that are commented in cl-macs loaded.
And also:

print-circle ==> nil
print-gensym ==> nil

(loop for x on '(1 2 3 4) collect x)
=>
Edebug: edebug-anon15

Result: (1 2 3 4)
Result: (2 3 4)
Result: (3 4)
Result: (4)
Result: ((1 . #1=(2 . #2=(3 . #3=(4)))) #1# #2# #3#)

I would expect
Result: ((1 2 3 4) (2 3 4) (3 4) (4))


-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 




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

* Re: edebug specs for cl-loop
  2012-08-07  6:55     ` Thierry Volpiatto
  2012-08-07  7:17       ` Thierry Volpiatto
@ 2012-08-07 15:11       ` Stefan Monnier
  2012-08-08  8:39         ` Thierry Volpiatto
  2012-08-08 12:00       ` Lars Brinkhoff
  2 siblings, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2012-08-07 15:11 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: emacs-devel

> loop understand this but not edebug: (Note where the for rand2 line is now)

>         for alphaindex = (random* (length alph))
>         collect rand1 into ls
>         for rand2 = (aref alph alphaindex)
>         collect rand2 into ls

By "edebug" which edebug-spec do you mean: the simple default (&rest &or
symbolp form) or the complex one?  AFAICT, the simple default should
handle the above just fine, right?

> loop understand this but not edebug: (note where the while line is now)

>           with len = (length (window-list))
>           for count from 1
>           while (< count len)
>           for w1 = (iter-next wlist)
>           for b1 = (window-buffer w1)
>           for s1 = (window-start w1)
>           for w2 = (iter-next wlist)
>           for b2 = (window-buffer w2)
>           for s2 = (window-start w2)
          
> Both give same result.

Here as well, the simple default spec should handle this just fine.


        Stefan



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

* Re: edebug specs for cl-loop
  2012-08-07  7:17       ` Thierry Volpiatto
@ 2012-08-07 15:12         ` Stefan Monnier
  2012-08-08  8:40           ` Thierry Volpiatto
  0 siblings, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2012-08-07 15:12 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: emacs-devel

> print-circle ==> nil
> print-gensym ==> nil
[...]
> Result: ((1 . #1=(2 . #2=(3 . #3=(4)))) #1# #2# #3#)

See edebug-print-circle.


        Stefan



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

* Re: edebug specs for cl-loop
  2012-08-07 15:11       ` Stefan Monnier
@ 2012-08-08  8:39         ` Thierry Volpiatto
  2012-08-08 13:42           ` Stefan Monnier
  0 siblings, 1 reply; 15+ messages in thread
From: Thierry Volpiatto @ 2012-08-08  8:39 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> loop understand this but not edebug: (Note where the for rand2 line is now)
>
>>         for alphaindex = (random* (length alph))
>>         collect rand1 into ls
>>         for rand2 = (aref alph alphaindex)
>>         collect rand2 into ls
>
> By "edebug" which edebug-spec do you mean: the simple default (&rest &or
> symbolp form) or the complex one?  AFAICT, the simple default should
> handle the above just fine, right?
I don't understand what you call simple default and complex one.

Assume the edebug specs in cl-macs (the ones commented) are loaded,
otherwise all this is irrelevant because edebug doesn't work at all in
loop.

I mean that on the above form, if I do C-M-x on it the function is
evaluated with no errors, and if I do C-u C-M-x I have an error:

--8<---------------cut here---------------start------------->8---
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])
--8<---------------cut here---------------end--------------->8---

>> loop understand this but not edebug: (note where the while line is now)
>
>>           with len = (length (window-list))
>>           for count from 1
>>           while (< count len)
>>           for w1 = (iter-next wlist)
>>           for b1 = (window-buffer w1)
>>           for s1 = (window-start w1)
>>           for w2 = (iter-next wlist)
>>           for b2 = (window-buffer w2)
>>           for s2 = (window-start w2)
>           
>> Both give same result.
>
> Here as well, the simple default spec should handle this just fine.
Here both C-M-x and C-u C-M-x works.


-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 



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

* Re: edebug specs for cl-loop
  2012-08-07 15:12         ` Stefan Monnier
@ 2012-08-08  8:40           ` Thierry Volpiatto
  0 siblings, 0 replies; 15+ messages in thread
From: Thierry Volpiatto @ 2012-08-08  8:40 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> print-circle ==> nil
>> print-gensym ==> nil
> [...]
>> Result: ((1 . #1=(2 . #2=(3 . #3=(4)))) #1# #2# #3#)
>
> See edebug-print-circle.
Ok, thanks, works as expected with that.

-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 



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

* Re: edebug specs for cl-loop
  2012-08-07  6:55     ` Thierry Volpiatto
  2012-08-07  7:17       ` Thierry Volpiatto
  2012-08-07 15:11       ` Stefan Monnier
@ 2012-08-08 12:00       ` Lars Brinkhoff
  2 siblings, 0 replies; 15+ messages in thread
From: Lars Brinkhoff @ 2012-08-08 12:00 UTC (permalink / raw)
  To: emacs-devel

Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
> loop understand this but not edebug: (Note where the for rand2 line is now)
>
>         for alphaindex = (random* (length alph))
>         collect rand1 into ls
>         for rand2 = (aref alph alphaindex)
>         collect rand2 into ls
>
> loop understand this but not edebug: (note where the while line is now)
>
>           with len = (length (window-list))
>           for count from 1
>           while (< count len)
>           for w1 = (iter-next wlist)
>           for b1 = (window-buffer w1)
>           for s1 = (window-start w1)
>           for w2 = (iter-next wlist)
>           for b2 = (window-buffer w2)
>           for s2 = (window-start w2)


Note that mixing different kinds of loop clauses like this is actually
not permitted by the Common Lisp specification.  Some implementations
signal errors for this (I checked three, they all complained).

(Just FYI, since we're not discussing a scrict CL implementation.)




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

* Re: edebug specs for cl-loop
  2012-08-08  8:39         ` Thierry Volpiatto
@ 2012-08-08 13:42           ` Stefan Monnier
  2012-08-08 16:12             ` Thierry Volpiatto
  0 siblings, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2012-08-08 13:42 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: emacs-devel

> I don't understand what you call simple default and complex one.

`loop' comes with an edebug spec already:

   (defmacro cl-loop (&rest loop-args)
     "..."
     (declare (debug (&rest &or symbolp form)))
     ...)

This is a simplistic spec, but AFAIK it works (tho sometimes
suboptimally) in most (all?) cases.

At least if I do

   % trunk/src/emacs -Q
   and then C-u C-M-x on a `loop' form

Edebug handles it OK (it steps into the subexpressions of the `loop'
form).


        Stefan



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

* Re: edebug specs for cl-loop
  2012-08-08 13:42           ` Stefan Monnier
@ 2012-08-08 16:12             ` Thierry Volpiatto
  2012-08-08 18:10               ` Stefan Monnier
  0 siblings, 1 reply; 15+ messages in thread
From: Thierry Volpiatto @ 2012-08-08 16:12 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> I don't understand what you call simple default and complex one.
>
> `loop' comes with an edebug spec already:
>
>    (defmacro cl-loop (&rest loop-args)
>      "..."
>      (declare (debug (&rest &or symbolp form)))
>      ...)
>
> This is a simplistic spec, but AFAIK it works (tho sometimes
> suboptimally) in most (all?) cases.
>
> At least if I do
>
>    % trunk/src/emacs -Q
>    and then C-u C-M-x on a `loop' form
>
> Edebug handles it OK (it steps into the subexpressions of the `loop'
> form).
Indeed, yes it is working in both cases WITHOUT your commented edebug
specs too.
So I am a little bit lost because it was not working some days ago
without them.

Thanks for explanations.

-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 



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

* Re: edebug specs for cl-loop
  2012-08-08 16:12             ` Thierry Volpiatto
@ 2012-08-08 18:10               ` Stefan Monnier
  2012-08-10  9:22                 ` Thierry Volpiatto
  0 siblings, 1 reply; 15+ messages in thread
From: Stefan Monnier @ 2012-08-08 18:10 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: emacs-devel

> Indeed, yes it is working in both cases WITHOUT your commented edebug
> specs too.  So I am a little bit lost because it was not working some
> days ago without them.

At some point, there was a bug where the debug spec set on `cl-loop' did
not apply to the `loop' alias.  Maybe that's what you bumped into.


        Stefan



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

* Re: edebug specs for cl-loop
  2012-08-08 18:10               ` Stefan Monnier
@ 2012-08-10  9:22                 ` Thierry Volpiatto
  2012-08-10 16:20                   ` Stefan Monnier
  0 siblings, 1 reply; 15+ messages in thread
From: Thierry Volpiatto @ 2012-08-10  9:22 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@IRO.UMontreal.CA> writes:

>> Indeed, yes it is working in both cases WITHOUT your commented edebug
>> specs too.  So I am a little bit lost because it was not working some
>> days ago without them.
>
> At some point, there was a bug where the debug spec set on `cl-loop' did
> not apply to the `loop' alias.  Maybe that's what you bumped into.
This one is not working without the commented stuff of cl-macs:

(loop for (k . v) in '((a . 1) (b . 2) (c . 3))
      collect (cons k (1+ v)))

==> edebug-syntax-error: Invalid read syntax: "Dotted spec required."

>
>         Stefan

-- 
  Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 



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

* Re: edebug specs for cl-loop
  2012-08-10  9:22                 ` Thierry Volpiatto
@ 2012-08-10 16:20                   ` Stefan Monnier
  0 siblings, 0 replies; 15+ messages in thread
From: Stefan Monnier @ 2012-08-10 16:20 UTC (permalink / raw)
  To: Thierry Volpiatto; +Cc: emacs-devel

>>> Indeed, yes it is working in both cases WITHOUT your commented edebug
>>> specs too.  So I am a little bit lost because it was not working some
>>> days ago without them.
>> At some point, there was a bug where the debug spec set on `cl-loop' did
>> not apply to the `loop' alias.  Maybe that's what you bumped into.
> This one is not working without the commented stuff of cl-macs:

> (loop for (k . v) in '((a . 1) (b . 2) (c . 3))
>       collect (cons k (1+ v)))

> ==> edebug-syntax-error: Invalid read syntax: "Dotted spec required."

Good point.  The patch below should address this issue,


        Stefan


=== modified file 'lisp/emacs-lisp/cl-macs.el'
--- lisp/emacs-lisp/cl-macs.el	2012-08-06 19:53:45 +0000
+++ lisp/emacs-lisp/cl-macs.el	2012-08-10 15:49:23 +0000
@@ -731,7 +731,12 @@
   finally return EXPR, named NAME.
 
 \(fn CLAUSE...)"
-  (declare (debug (&rest &or symbolp form)))
+  (declare (debug (&rest &or
+                         ;; These are usually followed by a symbol, but it can
+                         ;; actually be any destructuring-bind pattern.
+                         [[&or "for" "as" "with" "and"] sexp]
+                         ;; Simple default, which covers 99% of the cases.
+                         symbolp form)))
   (if (not (memq t (mapcar 'symbolp (delq nil (delq t (cl-copy-list loop-args))))))
       `(cl-block nil (while t ,@loop-args))
     (let ((cl--loop-args loop-args) (cl--loop-name nil) (cl--loop-bindings nil)




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

end of thread, other threads:[~2012-08-10 16:20 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-04  9:58 edebug specs for cl-loop Thierry Volpiatto
2012-08-06 21:57 ` Stefan Monnier
2012-08-07  5:08   ` Thierry Volpiatto
2012-08-07  6:55     ` Thierry Volpiatto
2012-08-07  7:17       ` Thierry Volpiatto
2012-08-07 15:12         ` Stefan Monnier
2012-08-08  8:40           ` Thierry Volpiatto
2012-08-07 15:11       ` Stefan Monnier
2012-08-08  8:39         ` Thierry Volpiatto
2012-08-08 13:42           ` Stefan Monnier
2012-08-08 16:12             ` Thierry Volpiatto
2012-08-08 18:10               ` Stefan Monnier
2012-08-10  9:22                 ` Thierry Volpiatto
2012-08-10 16:20                   ` Stefan Monnier
2012-08-08 12:00       ` Lars Brinkhoff

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).