* bug#12929: case-lambda*
@ 2012-11-19 10:38 Daniel Llorens
2012-11-28 22:36 ` Ludovic Courtès
2013-03-05 17:54 ` Andy Wingo
0 siblings, 2 replies; 3+ messages in thread
From: Daniel Llorens @ 2012-11-19 10:38 UTC (permalink / raw)
To: 12929
See the thread here
http://lists.gnu.org/archive/html/guile-user/2012-11/msg00032.html
In Guile 2.0.6
(define f (case-lambda*
((x #:optional y) 1)
((x #:key y) 2)
((x y #:key z) 3)))
(f 1 2 #:z 3) -> Odd length of keyword argument list
Also
(define g (case-lambda*
((a #:key x) 1)
((a b c #:key x) 3)))
(g 1 2 3) - > Invalid keyword
This behavior doesn't seem useful and doesn't follow from the doc on case-lambda*, which is rather vague and lacks examples.
The case-lambda* test in tree-il.test also fails on the REPL
(let ((f (case-lambda*
((x #:optional y) 1)
((x #:key y) 2)
((x y #:key z) 3))))
(list (f 1)
(f 1 2)
(f #:y 2)
(f 1 2 #:z 3)))
-> Odd length of keyword argument list
Thanks,
Daniel
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#12929: case-lambda*
2012-11-19 10:38 bug#12929: case-lambda* Daniel Llorens
@ 2012-11-28 22:36 ` Ludovic Courtès
2013-03-05 17:54 ` Andy Wingo
1 sibling, 0 replies; 3+ messages in thread
From: Ludovic Courtès @ 2012-11-28 22:36 UTC (permalink / raw)
To: Daniel Llorens; +Cc: 12929
Hi,
Indeed, there’s something wrong. The “Odd length” error comes from the
‘bind-kwargs’ corresponding to the first case of the ‘case-lambda*’:
--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (case-lambda*
((x #:key y) 2)
((x y #:key z) 3))
$63 = #<procedure 22a0d40 at <current input>:4761:0 (x #:key y) | (x y #:key z)>
scheme@(guile-user)> ($63 1 2 #:z 3)
<unnamed port>:4761:0: In procedure #<procedure 22a0d40 at <current input>:4761:0 (x #:key y) | (x y #:key z)>:
<unnamed port>:4761:0: In procedure #<procedure 22a0d40 at <current input>:4761:0 (x #:key y) | (x y #:key z)>: Odd length of keyword argument list
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,proc
$64 = #<procedure 22a0d40 at <current input>:4761:0 (x #:key y) | (x y #:key z)>
scheme@(guile-user) [1]> ,x $64
Disassembly of #<procedure 22a0d40 at <current input>:4761:0 (x #:key y) | (x y #:key z)>:
0 (br-if-nargs-lt 0 1 :L49541) ;; -> 34
6 (bind-optionals/shuffle 0 1 0 1 0 2)
13 (bind-kwargs 0 1 0 2 0)
19 (reserve-locals 0 2)
22 (local-bound? 1)
24 (br-if :L49542) ;; -> 31
28 (make-false)
29 (local-set 1) ;; `y'
31 (make-int8 2) ;; 2
33 (return)
34 (assert-nargs-ge 0 2)
37 (bind-optionals/shuffle 0 2 0 2 0 3)
44 (bind-kwargs 0 2 0 3 0)
50 (reserve-locals 0 3)
53 (local-bound? 2)
55 (br-if :L49543) ;; -> 62
59 (make-false)
60 (local-set 2) ;; `z'
62 (make-int8 3) ;; 3
64 (return)
scheme@(guile-user) [1]> ,regs
Registers:
$65 = ip = 19
$66 = sp = #x2dacd58
$67 = fp = #x2dacd38
--8<---------------cut here---------------end--------------->8---
Seems to me that for this to work, we’d need a variant of ‘bind-kwargs’,
say ‘br-if-kwargs-match’, that allows a jump to the next case upon
mismatch.
At least, I can’t think of any other way to generate a prelude that
would work (search for <glil-kw-prelude> in compile-assembly.scm.)
Thoughts?
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#12929: case-lambda*
2012-11-19 10:38 bug#12929: case-lambda* Daniel Llorens
2012-11-28 22:36 ` Ludovic Courtès
@ 2013-03-05 17:54 ` Andy Wingo
1 sibling, 0 replies; 3+ messages in thread
From: Andy Wingo @ 2013-03-05 17:54 UTC (permalink / raw)
To: Daniel Llorens; +Cc: 12929-done
On Mon 19 Nov 2012 11:38, Daniel Llorens <dll@jast.ch> writes:
> http://lists.gnu.org/archive/html/guile-user/2012-11/msg00032.html
Fixed, with notes in that thread. Thanks again for the report!
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-03-05 17:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-19 10:38 bug#12929: case-lambda* Daniel Llorens
2012-11-28 22:36 ` Ludovic Courtès
2013-03-05 17:54 ` Andy Wingo
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).