unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: ludovic.courtes@laas.fr (Ludovic Courtès)
Subject: Re: Block comments and `read-hash-extend'
Date: Fri, 19 Aug 2005 10:11:05 +0200	[thread overview]
Message-ID: <87k6iis5wm.fsf@laas.fr> (raw)
In-Reply-To: <87k6kumykq.fsf@laas.fr> (Ludovic Courtès's message of "Thu, 16 Jun 2005 11:37:57 +0200")

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


  parent reply	other threads:[~2005-08-19  8:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2005-09-04 23:02 ` Marius Vollmer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k6iis5wm.fsf@laas.fr \
    --to=ludovic.courtes@laas.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).