* Block comments and `read-hash-extend'
@ 2005-06-16 9:37 Ludovic Courtès
2005-06-17 0:13 ` Kevin Ryde
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Ludovic Courtès @ 2005-06-16 9:37 UTC (permalink / raw)
Hi,
The patch below (1) fixes `#! ... !#' block comments and (2) allows to
override them with `read-hash-extend'.
(1) This example makes Guile 1.6 and the current Guile 1.7 hang (for
some reason which I did not track down):
guile> #! this is a comment !# (+ 2 2)
[wait forever]
Once the patch is applied:
guile> #! this is a comment !# (+ 2 2)
4
I guess block comments have not been widely used over the past
years. ;-)
(2) It makes it possible to discard the block comment syntax with
`read-hash-extend'. The example below allows to recognize the
DSSSL keyword syntax[*], at the expense of losing the block
comment syntax:
(read-hash-extend #\! (lambda (chr port)
(symbol->keyword (read port))))
I find this particular example useful since, even if DSSSL is
apparently not widely used, other Scheme implementations such as
Bigloo do support this syntax, and allowing such extensions is what
`read-hash-extend' is for.
Comments?
Thanks,
Ludovic.
[*] http://www.ibiblio.org/pub/sun-info/standards/dsssl/dssslo/do960816.htm
2005-06-16 Ludovic Courtès <ludovic.courtes@laas.fr>
* read.c (scm_flush_ws): Do not handle `#! .. !#' block
comments here so that the behavior of `#!' can be extended with
`read-hash-extend'.
(scm_lreadr): Handle the `#!' case here instead of in
`scm_flush_ws ()' after making sure that no hash reader
extension exists for `!'. Jump to `tryagain' after call to
`skip_scsh_block_comment ()', which fixes a bug in block
comments handling (where Guile would hang).
Index: read.c
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/libguile/read.c,v
retrieving revision 1.117
diff -u -B -b -p -r1.117 read.c
--- read.c 23 May 2005 19:57:21 -0000 1.117
+++ read.c 16 Jun 2005 09:13:28 -0000
@@ -227,9 +227,6 @@ scm_flush_ws (SCM port, const char *eofe
case EOF:
eoferr = "read_sharp";
goto goteof;
- case '!':
- skip_scsh_block_comment (port);
- break;
default:
scm_ungetc (c, port);
return '#';
@@ -478,9 +475,10 @@ scm_lreadr (SCM *tok_buf, SCM port, SCM
goto num;
case '!':
- /* should never happen, #!...!# block comments are skipped
- over in scm_flush_ws. */
- abort ();
+ /* Only handle `#! ... !#' block comments if no user extension was
+ defined for `!' using `read-hash-extend'. */
+ skip_scsh_block_comment (port);
+ goto tryagain;
case '*':
j = scm_read_token (c, tok_buf, port, 0);
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Block comments and `read-hash-extend'
2005-06-16 9:37 Block comments and `read-hash-extend' Ludovic Courtès
@ 2005-06-17 0:13 ` Kevin Ryde
2005-06-17 7:31 ` Ludovic Courtès
2005-08-19 8:11 ` Ludovic Courtès
2005-09-04 23:02 ` Marius Vollmer
2 siblings, 1 reply; 9+ messages in thread
From: Kevin Ryde @ 2005-06-17 0:13 UTC (permalink / raw)
Cc: guile-devel
ludovic.courtes@laas.fr (Ludovic Courtès) writes:
>
> (1) This example makes Guile 1.6 and the current Guile 1.7 hang (for
> some reason which I did not track down):
>
> guile> #! this is a comment !# (+ 2 2)
> [wait forever]
You mean it reads more input?
> guile> #! this is a comment !# (+ 2 2)
> 4
The manual says the !# is supposed to appear on a line on its own. Do
you think you need it joined on?
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Block comments and `read-hash-extend'
2005-06-17 0:13 ` Kevin Ryde
@ 2005-06-17 7:31 ` Ludovic Courtès
2005-06-17 22:40 ` Rob Browning
2005-07-04 22:26 ` Neil Jerram
0 siblings, 2 replies; 9+ messages in thread
From: Ludovic Courtès @ 2005-06-17 7:31 UTC (permalink / raw)
Cc: guile-devel
Hi,
Kevin Ryde <user42@zip.com.au> writes:
> The manual says the !# is supposed to appear on a line on its own. Do
> you think you need it joined on?
I think I should have read the manual more carefully. ;-) Indeed, `!#'
needs to be on a line on its own, so the bug I described above is not an
actual bug, it's a feature.
Still, I don't understand the rationale behind this and I consider this
a limitation. In fact, it's misleading compared to block comments in
other languages or in SRFI-30.
Thanks,
Ludovic.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Block comments and `read-hash-extend'
2005-06-17 7:31 ` Ludovic Courtès
@ 2005-06-17 22:40 ` Rob Browning
2005-09-04 22:59 ` Marius Vollmer
2005-07-04 22:26 ` Neil Jerram
1 sibling, 1 reply; 9+ messages in thread
From: Rob Browning @ 2005-06-17 22:40 UTC (permalink / raw)
Cc: guile-devel
ludovic.courtes@laas.fr (Ludovic Courtès) writes:
> Still, I don't understand the rationale behind this and I consider this
> a limitation. In fact, it's misleading compared to block comments in
> other languages or in SRFI-30.
Unless there's a strong counterargument, I'd like to see #| |# work
in-line, in accordance with SRFI-30 and Common Lisp, and perhaps #! !#
should just be a synonym.
--
Rob Browning
rlb @defaultvalue.org and @debian.org; previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Block comments and `read-hash-extend'
2005-06-17 22:40 ` Rob Browning
@ 2005-09-04 22:59 ` Marius Vollmer
2005-09-04 23:57 ` Rob Browning
0 siblings, 1 reply; 9+ messages in thread
From: Marius Vollmer @ 2005-09-04 22:59 UTC (permalink / raw)
Cc: guile-devel
Rob Browning <rlb@defaultvalue.org> writes:
> ludovic.courtes@laas.fr (Ludovic Courtès) writes:
>
>> Still, I don't understand the rationale behind this and I consider this
>> a limitation. In fact, it's misleading compared to block comments in
>> other languages or in SRFI-30.
>
> Unless there's a strong counterargument, I'd like to see #| |# work
> in-line, in accordance with SRFI-30 and Common Lisp, and perhaps #! !#
> should just be a synonym.
Right now, HEAD already copes with in-line #! !# comments. We could
copy it over to 1.6... Do you think this would be OK?
And yes, we should probably support #| |# as the primary block comment
syntax and make #! !# an option so that #! can be used as a read-hash
extension. Patches welcome! :-)
--
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Block comments and `read-hash-extend'
2005-09-04 22:59 ` Marius Vollmer
@ 2005-09-04 23:57 ` Rob Browning
0 siblings, 0 replies; 9+ messages in thread
From: Rob Browning @ 2005-09-04 23:57 UTC (permalink / raw)
Cc: guile-devel
Marius Vollmer <mvo@zagadka.de> writes:
> Right now, HEAD already copes with in-line #! !# comments. We could
> copy it over to 1.6... Do you think this would be OK?
So the only change to 1.6 would be that #! would work in-line (where
now they only work at the start of a line)? If so, then I think that
would probably be OK. I'd be surprised if anyone knew about and
depended on the current in-line behavior.
--
Rob Browning
rlb @defaultvalue.org and @debian.org; previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Block comments and `read-hash-extend'
2005-06-17 7:31 ` Ludovic Courtès
2005-06-17 22:40 ` Rob Browning
@ 2005-07-04 22:26 ` Neil Jerram
1 sibling, 0 replies; 9+ messages in thread
From: Neil Jerram @ 2005-07-04 22:26 UTC (permalink / raw)
Cc: guile-devel
Ludovic Courtès wrote:
> Hi,
>
> Kevin Ryde <user42@zip.com.au> writes:
>
>
>>The manual says the !# is supposed to appear on a line on its own. Do
>>you think you need it joined on?
>
>
> I think I should have read the manual more carefully. ;-) Indeed, `!#'
> needs to be on a line on its own, so the bug I described above is not an
> actual bug, it's a feature.
>
> Still, I don't understand the rationale behind this and I consider this
> a limitation. In fact, it's misleading compared to block comments in
> other languages or in SRFI-30.
I agree with you. I think the rationale for the status quo is actually
just historical accident, reflecting that the support for #! ... !# was
initially designed only for the `#! /usr/local/bin/guile' line at the
beginning of a script file. But it surely much more useful for #! ...
!# comments to work as you suggest, and I can't see any downside from
making them do so.
Neil
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Block comments and `read-hash-extend'
2005-06-16 9:37 Block comments and `read-hash-extend' Ludovic Courtès
2005-06-17 0:13 ` Kevin Ryde
@ 2005-08-19 8:11 ` Ludovic Courtès
2005-09-04 23:02 ` Marius Vollmer
2 siblings, 0 replies; 9+ messages in thread
From: Ludovic Courtès @ 2005-08-19 8:11 UTC (permalink / raw)
The patch below (<87k6kumykq.fsf@laas.fr>) also failed to live through
the summer. ;-)
Is it acceptable?
Thanks,
Ludovic.
ludovic.courtes@laas.fr (Ludovic Courtès) writes:
> Hi,
>
> The patch below (1) fixes `#! ... !#' block comments and (2) allows to
> override them with `read-hash-extend'.
>
>
> (1) This example makes Guile 1.6 and the current Guile 1.7 hang (for
> some reason which I did not track down):
>
> guile> #! this is a comment !# (+ 2 2)
> [wait forever]
>
> Once the patch is applied:
>
> guile> #! this is a comment !# (+ 2 2)
> 4
>
> I guess block comments have not been widely used over the past
> years. ;-)
>
>
> (2) It makes it possible to discard the block comment syntax with
> `read-hash-extend'. The example below allows to recognize the
> DSSSL keyword syntax[*], at the expense of losing the block
> comment syntax:
>
> (read-hash-extend #\! (lambda (chr port)
> (symbol->keyword (read port))))
>
> I find this particular example useful since, even if DSSSL is
> apparently not widely used, other Scheme implementations such as
> Bigloo do support this syntax, and allowing such extensions is what
> `read-hash-extend' is for.
>
>
> Comments?
>
> Thanks,
> Ludovic.
>
> [*] http://www.ibiblio.org/pub/sun-info/standards/dsssl/dssslo/do960816.htm
>
>
> 2005-06-16 Ludovic Courtès <ludovic.courtes@laas.fr>
>
> * read.c (scm_flush_ws): Do not handle `#! .. !#' block
> comments here so that the behavior of `#!' can be extended with
> `read-hash-extend'.
> (scm_lreadr): Handle the `#!' case here instead of in
> `scm_flush_ws ()' after making sure that no hash reader
> extension exists for `!'. Jump to `tryagain' after call to
> `skip_scsh_block_comment ()', which fixes a bug in block
> comments handling (where Guile would hang).
>
>
>
> Index: read.c
> ===================================================================
> RCS file: /cvsroot/guile/guile/guile-core/libguile/read.c,v
> retrieving revision 1.117
> diff -u -B -b -p -r1.117 read.c
> --- read.c 23 May 2005 19:57:21 -0000 1.117
> +++ read.c 16 Jun 2005 09:13:28 -0000
> @@ -227,9 +227,6 @@ scm_flush_ws (SCM port, const char *eofe
> case EOF:
> eoferr = "read_sharp";
> goto goteof;
> - case '!':
> - skip_scsh_block_comment (port);
> - break;
> default:
> scm_ungetc (c, port);
> return '#';
> @@ -478,9 +475,10 @@ scm_lreadr (SCM *tok_buf, SCM port, SCM
> goto num;
>
> case '!':
> - /* should never happen, #!...!# block comments are skipped
> - over in scm_flush_ws. */
> - abort ();
> + /* Only handle `#! ... !#' block comments if no user extension was
> + defined for `!' using `read-hash-extend'. */
> + skip_scsh_block_comment (port);
> + goto tryagain;
>
> case '*':
> j = scm_read_token (c, tok_buf, port, 0);
>
>
>
> _______________________________________________
> Guile-devel mailing list
> Guile-devel@gnu.org
> http://lists.gnu.org/mailman/listinfo/guile-devel
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Block comments and `read-hash-extend'
2005-06-16 9:37 Block comments and `read-hash-extend' Ludovic Courtès
2005-06-17 0:13 ` Kevin Ryde
2005-08-19 8:11 ` Ludovic Courtès
@ 2005-09-04 23:02 ` Marius Vollmer
2 siblings, 0 replies; 9+ messages in thread
From: Marius Vollmer @ 2005-09-04 23:02 UTC (permalink / raw)
Cc: guile-devel
ludovic.courtes@laas.fr (Ludovic Courtès) writes:
> Comments?
Your patch has the problem that it breaks things like
(+ 2 2 #! 2 !#)
We can still support the #! read-hash extension, of course, which I
think is a good idea.
--
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3 331E FAF8 226A D5D4 E405
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2005-09-04 23:57 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-16 9:37 Block comments and `read-hash-extend' Ludovic Courtès
2005-06-17 0:13 ` Kevin Ryde
2005-06-17 7:31 ` Ludovic Courtès
2005-06-17 22:40 ` Rob Browning
2005-09-04 22:59 ` Marius Vollmer
2005-09-04 23:57 ` Rob Browning
2005-07-04 22:26 ` Neil Jerram
2005-08-19 8:11 ` Ludovic Courtès
2005-09-04 23:02 ` Marius Vollmer
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).