* [bug #31691] Ellipsis not supported in nested `sxml-match' forms [1.9.13]
@ 2010-11-19 22:56 Ludovic Courtès
0 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2010-11-19 22:56 UTC (permalink / raw)
To: Jim Bender; +Cc: bug-guile
[-- Attachment #1: Type: text/plain, Size: 241 bytes --]
Hi Jim,
I stumbled upon the bug below with sxml-match as included in Guile 1.9.
Do you have ideas on how to fix it? My guess is that is has to do with
‘...’ not being specified as a literal in the macros.
Thanks,
Ludo’.
[-- Attachment #2: Type: message/rfc822, Size: 4924 bytes --]
From: anonymous <INVALID.NOREPLY@gnu.org>
To: bug-guile@gnu.org
Subject: [bug #31691] Ellipsis not supported in nested `sxml-match' forms [1.9.13]
Date: Thu, 18 Nov 2010 09:10:37 +0000
Message-ID: <20101118-091036.sv0.12070@savannah.gnu.org>
URL:
<http://savannah.gnu.org/bugs/?31691>
Summary: Ellipsis not supported in nested `sxml-match' forms
[1.9.13]
Project: Guile
Submitted by: None
Submitted on: Thu 18 Nov 2010 09:10:36 AM UTC
Category: None
Severity: 3 - Normal
Item Group: None
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
This fails:
#v+
scheme@(guile-user)> (sxml-match '(foo (bar 1 2 3)) ((foo ,x ...) (sxml-match
(car x) ((bar ,y ...) y))))
While compiling expression:
ERROR: bad pattern syntax (symbol not allowed in this context)
Exception during displaying of error: misc-error
#v-
... whereas in non-nested position ellipsis obviously works:
#v+
scheme@(guile-user)> (define (match-bar x) (sxml-match x ((bar ,y ...) y)))
scheme@(guile-user)> (sxml-match '(foo (bar 1 2 3)) ((foo ,x ...) (sxml-match
(car x) (,(match-bar -> y) y))))
$1 = (1 2 3)
#v-
Has to do with `...' not specified as a literal in the `sxml-match' macros...
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?31691>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* [bug #31691] Ellipsis not supported in nested `sxml-match' forms [1.9.13]
@ 2010-11-18 9:10 anonymous
2010-11-19 16:28 ` Andy Wingo
0 siblings, 1 reply; 10+ messages in thread
From: anonymous @ 2010-11-18 9:10 UTC (permalink / raw)
To: bug-guile
URL:
<http://savannah.gnu.org/bugs/?31691>
Summary: Ellipsis not supported in nested `sxml-match' forms
[1.9.13]
Project: Guile
Submitted by: None
Submitted on: Thu 18 Nov 2010 09:10:36 AM UTC
Category: None
Severity: 3 - Normal
Item Group: None
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
This fails:
#v+
scheme@(guile-user)> (sxml-match '(foo (bar 1 2 3)) ((foo ,x ...) (sxml-match
(car x) ((bar ,y ...) y))))
While compiling expression:
ERROR: bad pattern syntax (symbol not allowed in this context)
Exception during displaying of error: misc-error
#v-
... whereas in non-nested position ellipsis obviously works:
#v+
scheme@(guile-user)> (define (match-bar x) (sxml-match x ((bar ,y ...) y)))
scheme@(guile-user)> (sxml-match '(foo (bar 1 2 3)) ((foo ,x ...) (sxml-match
(car x) (,(match-bar -> y) y))))
$1 = (1 2 3)
#v-
Has to do with `...' not specified as a literal in the `sxml-match' macros...
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?31691>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* [bug #31691] Ellipsis not supported in nested `sxml-match' forms [1.9.13]
2010-11-18 9:10 anonymous
@ 2010-11-19 16:28 ` Andy Wingo
2010-11-19 16:41 ` Andy Wingo
0 siblings, 1 reply; 10+ messages in thread
From: Andy Wingo @ 2010-11-19 16:28 UTC (permalink / raw)
To: Andy Wingo, bug-guile
Follow-up Comment #1, bug #31691 (project guile):
Yeah, I have no idea. Maybe Jim Bender would be interested in this one; I'll
forward the message.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?31691>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* [bug #31691] Ellipsis not supported in nested `sxml-match' forms [1.9.13]
2010-11-19 16:28 ` Andy Wingo
@ 2010-11-19 16:41 ` Andy Wingo
2011-07-15 11:36 ` Stefan Israelsson Tampe
0 siblings, 1 reply; 10+ messages in thread
From: Andy Wingo @ 2010-11-19 16:41 UTC (permalink / raw)
To: Andy Wingo, bug-guile
Follow-up Comment #2, bug #31691 (project guile):
I can't seem to find Jim's mail; perhaps Ludovic would be willing to take a
look at it :)
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?31691>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* [bug #31691] Ellipsis not supported in nested `sxml-match' forms [1.9.13]
2010-11-19 16:41 ` Andy Wingo
@ 2011-07-15 11:36 ` Stefan Israelsson Tampe
2011-09-02 17:17 ` Andy Wingo
0 siblings, 1 reply; 10+ messages in thread
From: Stefan Israelsson Tampe @ 2011-07-15 11:36 UTC (permalink / raw)
To: Andy Wingo, Stefan Israelsson Tampe, bug-guile
Follow-up Comment #3, bug #31691 (project guile):
First, upstream doc's for sxml-match indicates that ellipsis
in the body is not allowed and then the the Bug would be moot
because the spec does not allow the example below.
On the other hand allowing the code below is a useful feature and
I have a patch that introduce this new feature. On the other hand
this means that guile code using sxml-match would not work on other platforms
with the upstream version.
Best is possible to contact Jim Bender to include this as a feature.
The solution is to allow ellipsis in the body in the following way:
if we encounter (p ... . l) then p is investigated to see if there are any
variables that comes from an ellipsis in the matcher. If we find that there
exists such variables the ellipsis will not be used for expansion paths in the
macro and it will be untouched.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?31691>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* [bug #31691] Ellipsis not supported in nested `sxml-match' forms [1.9.13]
2011-07-15 11:36 ` Stefan Israelsson Tampe
@ 2011-09-02 17:17 ` Andy Wingo
2011-09-05 13:40 ` Stefan Israelsson Tampe
0 siblings, 1 reply; 10+ messages in thread
From: Andy Wingo @ 2011-09-02 17:17 UTC (permalink / raw)
To: Andy Wingo, Stefan Israelsson Tampe, bug-guile
Follow-up Comment #4, bug #31691 (project guile):
It does sound like a useful feature. Stefan, can you post the patch here?
Would you mind mailing it to Jim as well, to see what he thinks?
Thanks,
andy
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?31691>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* [bug #31691] Ellipsis not supported in nested `sxml-match' forms [1.9.13]
2011-09-02 17:17 ` Andy Wingo
@ 2011-09-05 13:40 ` Stefan Israelsson Tampe
2011-09-06 21:27 ` Ludovic Courtès
0 siblings, 1 reply; 10+ messages in thread
From: Stefan Israelsson Tampe @ 2011-09-05 13:40 UTC (permalink / raw)
To: Andy Wingo, Stefan Israelsson Tampe, jim, bug-guile
Follow-up Comment #5, bug #31691 (project guile):
Ok here is a patch if it encounters a form like
x ... in the output part of sxml-match it will check if there exists an
ellipsis variable inside x. If there doesn't exist any it will not try to
expand the ellipsis, but instead keep it verbatrim.
So the subsequent matches must not use previous pattern
variables inside their patterns for this to work.
/Stefan
(file #23945)
_______________________________________________________
Additional Item Attachment:
File name: sxml-match.ss.diff Size:1 KB
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?31691>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* [bug #31691] Ellipsis not supported in nested `sxml-match' forms [1.9.13]
2011-09-05 13:40 ` Stefan Israelsson Tampe
@ 2011-09-06 21:27 ` Ludovic Courtès
2011-09-07 11:13 ` Stefan Israelsson Tampe
2011-09-11 21:54 ` Stefan Israelsson Tampe
0 siblings, 2 replies; 10+ messages in thread
From: Ludovic Courtès @ 2011-09-06 21:27 UTC (permalink / raw)
To: Ludovic Courtès, Andy Wingo, Stefan Israelsson Tampe, jim,
bug-guile
Follow-up Comment #6, bug #31691 (project guile):
Hmm, that seems a bit hackish. :-)
(ice-9 match) has `___' as an alternate syntax for `...' in situations where
the latter cannot be used. Maybe we should just do that?
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?31691>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [bug #31691] Ellipsis not supported in nested `sxml-match' forms [1.9.13]
2011-09-06 21:27 ` Ludovic Courtès
@ 2011-09-07 11:13 ` Stefan Israelsson Tampe
2011-09-11 21:54 ` Stefan Israelsson Tampe
1 sibling, 0 replies; 10+ messages in thread
From: Stefan Israelsson Tampe @ 2011-09-07 11:13 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: jim, Ludovic Courtès, bug-guile
[-- Attachment #1: Type: text/plain, Size: 2329 bytes --]
The code is hackish but it shows the reason behind the error in the report.
The semantic behind the idea should not be hackish. any expression (x ...)
with no ellipsis var in x has earlier been an error so there is no danger in
corrupting
code out there. On the other hand there is still room to improve it further.
On the other hand, we will miss an oppertunity to find code errors by
missplaced a .... so that is what we will loose by doing this.
I noticed that syntax-rules and case-lambda does either not allow for
recursive uses of ... but signals an error if the same kind of code is
tried. I would like
tghe solution here to be the same for both of these kinds of matchers.
the ___ solution seams also hackish and I do not follow exactly how it is
used.
can you submit an example to show how it works.
What I can think of is that we could use a quotation system e.g. be able to
quote ...
this means that we need to introduce '... ''... etc at the right places in
order to exactly
show the intention of how to expand e.g.
(sxml-mathc x ((a ,x ...)
(list (sxml-match x ((b ,y '...)
(list (sxml-match y ((c ,z ''...) z)
'...))
...)
To me this is most satisfying because it will keep on finding missplaced ...
and it will
be more exact in the intention of the code it will not be hard to implement.
The downside is that a very small possibly zero number of matchers will stop
working due to the possibility of using quote as a ellipsis variable.
I can very well imagine that quoting is seen as difficult and in order to
promote correct code we should leave the code as is forcing people to cut up
the logic as done in the working example in the original report.
/Stefan
On Tue, Sep 6, 2011 at 11:27 PM, Ludovic Courtès <INVALID.NOREPLY@gnu.org>wrote:
> Follow-up Comment #6, bug #31691 (project guile):
>
> Hmm, that seems a bit hackish. :-)
>
> (ice-9 match) has `___' as an alternate syntax for `...' in situations
> where
> the latter cannot be used. Maybe we should just do that?
>
> _______________________________________________________
>
> Reply to this item at:
>
> <http://savannah.gnu.org/bugs/?31691>
>
> _______________________________________________
> Message sent via/by Savannah
> http://savannah.gnu.org/
>
>
[-- Attachment #2: Type: text/html, Size: 2872 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* [bug #31691] Ellipsis not supported in nested `sxml-match' forms [1.9.13]
2011-09-06 21:27 ` Ludovic Courtès
2011-09-07 11:13 ` Stefan Israelsson Tampe
@ 2011-09-11 21:54 ` Stefan Israelsson Tampe
1 sibling, 0 replies; 10+ messages in thread
From: Stefan Israelsson Tampe @ 2011-09-11 21:54 UTC (permalink / raw)
To: Ludovic Courtès, Andy Wingo, Stefan Israelsson Tampe, jim,
bug-guile
Follow-up Comment #7, bug #31691 (project guile):
I suspect that this bug is a feature request.
Anyway I coded another solution which sematics is more exact.
The idea is to quote ... and each match will remove one of the quotes around
.... So now this works,
(sxml-match '(a (b (c 1) (c 2 3)) (b (c 4)) (b (c 5)))
((a ,x ...)
(list (sxml-match x
((b ,y '...)
(list (sxml-match y
((c ,z ''...) z)) '...))) ...)))
$1 = (((1) (2 3)) ((4)) ((5)))
attached is a git diff of the code.
the bad thing with this code is that it's not possible to output
the '... symbol.
/Stefan
(file #23968)
_______________________________________________________
Additional Item Attachment:
File name: sxml-match.ss.2.diff Size:2 KB
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?31691>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2011-09-11 21:54 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-19 22:56 [bug #31691] Ellipsis not supported in nested `sxml-match' forms [1.9.13] Ludovic Courtès
-- strict thread matches above, loose matches on Subject: below --
2010-11-18 9:10 anonymous
2010-11-19 16:28 ` Andy Wingo
2010-11-19 16:41 ` Andy Wingo
2011-07-15 11:36 ` Stefan Israelsson Tampe
2011-09-02 17:17 ` Andy Wingo
2011-09-05 13:40 ` Stefan Israelsson Tampe
2011-09-06 21:27 ` Ludovic Courtès
2011-09-07 11:13 ` Stefan Israelsson Tampe
2011-09-11 21:54 ` Stefan Israelsson Tampe
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).