unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* end marker
@ 2004-02-11 19:38 Brian S McQueen
  2004-02-11 19:42 ` Paul Jarc
  2004-02-11 19:53 ` Andreas Rottmann
  0 siblings, 2 replies; 8+ messages in thread
From: Brian S McQueen @ 2004-02-11 19:38 UTC (permalink / raw)


Is there an equivalent to perls "__END__" for scheme scripting? It is very
handy for developing scripts.

Brian


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

* Re: end marker
  2004-02-11 19:38 end marker Brian S McQueen
@ 2004-02-11 19:42 ` Paul Jarc
  2004-02-11 19:53 ` Andreas Rottmann
  1 sibling, 0 replies; 8+ messages in thread
From: Paul Jarc @ 2004-02-11 19:42 UTC (permalink / raw)
  Cc: guile-user

Brian S McQueen <bqueen@nas.nasa.gov> wrote:
> Is there an equivalent to perls "__END__" for scheme scripting?

Not exactly, AFAIK, but you can use a #!-!# comment:
... code ...
#!
... random text ...
!#


paul


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

* Re: end marker
  2004-02-11 19:38 end marker Brian S McQueen
  2004-02-11 19:42 ` Paul Jarc
@ 2004-02-11 19:53 ` Andreas Rottmann
  2004-02-11 21:15   ` rm
  1 sibling, 1 reply; 8+ messages in thread
From: Andreas Rottmann @ 2004-02-11 19:53 UTC (permalink / raw)
  Cc: guile-user

Brian S McQueen <bqueen@nas.nasa.gov> writes:

> Is there an equivalent to perls "__END__" for scheme scripting? It is very
> handy for developing scripts.
>
I assume (quit) will do the job in most cases (I don't really know the
semantics of __END__, just guessing).

Andy
-- 
Andreas Rottmann         | Rotty@ICQ      | 118634484@ICQ | a.rottmann@gmx.at
http://yi.org/rotty      | GnuPG Key: http://yi.org/rotty/gpg.asc
Fingerprint              | DFB4 4EB4 78A4 5EEE 6219  F228 F92F CFC5 01FD 5B62

Packages should build-depend on what they should build-depend.


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

* Re: end marker
  2004-02-11 19:53 ` Andreas Rottmann
@ 2004-02-11 21:15   ` rm
  2004-02-11 21:31     ` Paul Jarc
  0 siblings, 1 reply; 8+ messages in thread
From: rm @ 2004-02-11 21:15 UTC (permalink / raw)
  Cc: guile-user

On Wed, Feb 11, 2004 at 08:53:38PM +0100, Andreas Rottmann wrote:
> Brian S McQueen <bqueen@nas.nasa.gov> writes:
> 
> > Is there an equivalent to perls "__END__" for scheme scripting? It is very
> > handy for developing scripts.
> >
> I assume (quit) will do the job in most cases (I don't really know the
> semantics of __END__, just guessing).

Well, __END__ does have some nice/strange/ugly/perlish semantic ;-)
The parser stops reading at '\n__END__' but leaves the filehandle open.
The script itself can then continue reading from this filehandle.

*--------------------------------------------------------------------- 
| #!/usr/barf/perl
| 
| while (<DATA>)
| {
|   print "Data from myself: $_";
| }
| 
| __END__
| 
| This is
| data for the script
| 
*---------------------------------------------------------------------

This can come handy for selfcontained scripts.

 Ralf Mattes



> Andy
> -- 
> Andreas Rottmann         | Rotty@ICQ      | 118634484@ICQ | a.rottmann@gmx.at
> http://yi.org/rotty      | GnuPG Key: http://yi.org/rotty/gpg.asc
> Fingerprint              | DFB4 4EB4 78A4 5EEE 6219  F228 F92F CFC5 01FD 5B62
> 
> Packages should build-depend on what they should build-depend.
> 
> 
> _______________________________________________
> Guile-user mailing list
> Guile-user@gnu.org
> http://mail.gnu.org/mailman/listinfo/guile-user


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

* Re: end marker
  2004-02-11 21:15   ` rm
@ 2004-02-11 21:31     ` Paul Jarc
  2004-02-11 21:46       ` Paul Jarc
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Jarc @ 2004-02-11 21:31 UTC (permalink / raw)
  Cc: Andreas Rottmann, guile-user

rm@fabula.de wrote:
> On Wed, Feb 11, 2004 at 08:53:38PM +0100, Andreas Rottmann wrote:
>> I assume (quit) will do the job in most cases

It won't work if you read the whole file before running any of it
(e.g. guile -s function script.scm).

> Well, __END__ does have some nice/strange/ugly/perlish semantic ;-)
> The parser stops reading at '\n__END__' but leaves the filehandle open.
> The script itself can then continue reading from this filehandle.

No, that's __DATA__.  __END__ just tells the interpreter to pretend
it's EOF.


paul


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

* Re: end marker
  2004-02-11 21:31     ` Paul Jarc
@ 2004-02-11 21:46       ` Paul Jarc
  2004-02-12  8:09         ` Stephen Compall
  0 siblings, 1 reply; 8+ messages in thread
From: Paul Jarc @ 2004-02-11 21:46 UTC (permalink / raw)
  Cc: Andreas Rottmann, guile-user

I wrote:
> It won't work if you read the whole file before running any of it
> (e.g. guile -s function script.scm).

Eh, make that "guile -e function -s script.scm".  guile would still
read beyond (quit) (which might trigger arbitrary actions from reader
extensions), but Perl stops reading at __END__.


paul


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

* Re: end marker
  2004-02-11 21:46       ` Paul Jarc
@ 2004-02-12  8:09         ` Stephen Compall
  2004-02-12 15:59           ` Paul Jarc
  0 siblings, 1 reply; 8+ messages in thread
From: Stephen Compall @ 2004-02-12  8:09 UTC (permalink / raw)


prj@po.cwru.edu (Paul Jarc) writes:

> Eh, make that "guile -e function -s script.scm".  guile would still
> read beyond (quit) (which might trigger arbitrary actions from
> reader extensions), but Perl stops reading at __END__.

How far does `read' read ahead of the last s-expression it returned?
And does -s read and evaluate one s-expression at a time?

--
Stephen Compall or s11 or sirian

I wish I was on a Cincinnati street corner holding a clean dog!

PGP Verisign USCOI jihad ANC MP5K-SD sweep Exon Shell CIDA nuclear
covert video warfare Rand Corporation bullion InfoSec


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

* Re: end marker
  2004-02-12  8:09         ` Stephen Compall
@ 2004-02-12 15:59           ` Paul Jarc
  0 siblings, 0 replies; 8+ messages in thread
From: Paul Jarc @ 2004-02-12 15:59 UTC (permalink / raw)
  Cc: guile-user

Stephen Compall <s11@member.fsf.org> wrote:
> prj@po.cwru.edu (Paul Jarc) writes:
>> Eh, make that "guile -e function -s script.scm".  guile would still
>> read beyond (quit) (which might trigger arbitrary actions from
>> reader extensions), but Perl stops reading at __END__.
>
> How far does `read' read ahead of the last s-expression it returned?

It may buffer ahead at the stdio level, but it doesn't consume any
extra characters (so everything will be visible to the next (read)),
and it doesn't call any reader-extension procedures for the extra
characters.

> And does -s read and evaluate one s-expression at a time?

Yes, but if it's used together with -e, then that probably means that
the whole script wouldn't really do much of anything just by loading
it - it defines some procedures, and then guile calls the one
specified by -e.  However, if it uses reader extensions, then those
would typically be established at the top level, outside any procedure
definition, so they would take place during the reading of the rest of
the script.

Consider this script:
  (define (x chr port)
    (format #t "~S\n" chr)
    #t)
  (read-hash-extend #\x x)
  #x
If the (read-hash-extend) were not fully evaluated before #x is read,
you'd get an error.


paul


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


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

end of thread, other threads:[~2004-02-12 15:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-11 19:38 end marker Brian S McQueen
2004-02-11 19:42 ` Paul Jarc
2004-02-11 19:53 ` Andreas Rottmann
2004-02-11 21:15   ` rm
2004-02-11 21:31     ` Paul Jarc
2004-02-11 21:46       ` Paul Jarc
2004-02-12  8:09         ` Stephen Compall
2004-02-12 15:59           ` Paul Jarc

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