unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* add printf.scm to ice-9?
@ 2002-04-06 22:00 Matthew R Wette
  2002-04-07 10:42 ` Marius Vollmer
  2002-04-07 14:38 ` Neil Jerram
  0 siblings, 2 replies; 10+ messages in thread
From: Matthew R Wette @ 2002-04-06 22:00 UTC (permalink / raw)



I have been heavily using guile for an application at here at work.
Guile seems to have everything I need except one item: printf.  Maybe
this is a candidate for a future addition?  [I am currently using the
printf.scm from slib, but the sprintf implementation there is a little
tough to work with as far as I can tell.]

Here is a short description of the application.  I am working on the
development of space-based interferometers.  The long range goal is
the search for earth-like planets orbiting distant stars.  These
interferometers use lots of laser metrology and actively controlled
mirrors.  [My job is to architect the closed-loop control system.]  We
have a program (MACOS) that generates a linear model for a single path
of a single light source.  I have written a program in guile (~3000
lines) that generates a linear optical model for multiple beams
traversing multiple paths through the optics.  I am able to parse
multiple specification files, run the MACOS program multiple times,
perform matrix-vector manipulations and automatically generate the
model in both MATLAB (for analysis) and C (for simulation).  My
prototype program to do all this was completed in less than a month.
People have been pretty impressed.

My thanks to the developers.  Guile is really coming along.
[The debugger has been a life saver.]

Matt

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


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

* Re: add printf.scm to ice-9?
  2002-04-06 22:00 Matthew R Wette
@ 2002-04-07 10:42 ` Marius Vollmer
  2002-04-07 14:38 ` Neil Jerram
  1 sibling, 0 replies; 10+ messages in thread
From: Marius Vollmer @ 2002-04-07 10:42 UTC (permalink / raw)
  Cc: guile-user

Matthew R Wette <mwette@grover.jpl.nasa.gov> writes:

> I have been heavily using guile for an application at here at work.
> Guile seems to have everything I need except one item: printf.

Can't you use 'format' (which is the Lisp version of printf)?

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


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

* Re: add printf.scm to ice-9?
  2002-04-06 22:00 Matthew R Wette
  2002-04-07 10:42 ` Marius Vollmer
@ 2002-04-07 14:38 ` Neil Jerram
  1 sibling, 0 replies; 10+ messages in thread
From: Neil Jerram @ 2002-04-07 14:38 UTC (permalink / raw)
  Cc: guile-user

>>>>> "Matthew" == Matthew R Wette <mwette@grover.jpl.nasa.gov> writes:

    Matthew> I have been heavily using guile for an application at
    Matthew> here at work.  Guile seems to have everything I need
    Matthew> except one item: printf.  Maybe this is a candidate for a
    Matthew> future addition?  [I am currently using the printf.scm
    Matthew> from slib, but the sprintf implementation there is a
    Matthew> little tough to work with as far as I can tell.]

Have you looked at `format' in the (ice-9 format) module?  It is
documented in the reference manual in node `Formatted Output'.

    Matthew> Here is a short description of the application.  I am working on the
    Matthew> development of space-based interferometers.  The long range goal is
    Matthew> the search for earth-like planets orbiting distant stars.  These
    Matthew> interferometers use lots of laser metrology and actively controlled
    Matthew> mirrors.  [My job is to architect the closed-loop control system.]  We
    Matthew> have a program (MACOS) that generates a linear model for a single path
    Matthew> of a single light source.  I have written a program in guile (~3000
    Matthew> lines) that generates a linear optical model for multiple beams
    Matthew> traversing multiple paths through the optics.  I am able to parse
    Matthew> multiple specification files, run the MACOS program multiple times,
    Matthew> perform matrix-vector manipulations and automatically generate the
    Matthew> model in both MATLAB (for analysis) and C (for simulation).  My
    Matthew> prototype program to do all this was completed in less than a month.
    Matthew> People have been pretty impressed.

Fascinating; thanks for this!

    Matthew> My thanks to the developers.  Guile is really coming along.
    Matthew> [The debugger has been a life saver.]

Thanks again; lovely to get such encouraging feedback.

        Neil


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


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

* Re: add printf.scm to ice-9?
@ 2002-04-07 16:09 Matthew R Wette
  2002-04-07 20:30 ` Per Bothner
  2002-04-07 23:53 ` Marius Vollmer
  0 siblings, 2 replies; 10+ messages in thread
From: Matthew R Wette @ 2002-04-07 16:09 UTC (permalink / raw)


Marius Vollmer writes ...
> Matthew R Wette <mwette@grover.jpl.nasa.gov> writes:
> 
> > I have been heavily using guile for an application at here at work.
> > Guile seems to have everything I need except one item: printf.
> 
> Can't you use 'format' (which is the Lisp version of printf)?

I want formats like %12.5e and %-20s.
My understanding is that this is not in format.

Matt

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


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

* Re: add printf.scm to ice-9?
  2002-04-07 16:09 add printf.scm to ice-9? Matthew R Wette
@ 2002-04-07 20:30 ` Per Bothner
  2002-04-09  2:43   ` Steve Tell
  2002-04-07 23:53 ` Marius Vollmer
  1 sibling, 1 reply; 10+ messages in thread
From: Per Bothner @ 2002-04-07 20:30 UTC (permalink / raw)
  Cc: guile-user

Matthew R Wette wrote:
> Marius Vollmer writes ...
> 
>>Matthew R Wette <mwette@grover.jpl.nasa.gov> writes:
>>
>>
>>>I have been heavily using guile for an application at here at work.
>>>Guile seems to have everything I need except one item: printf.
>>
>>Can't you use 'format' (which is the Lisp version of printf)?
> 
> 
> I want formats like %12.5e and %-20s.
> My understanding is that this is not in format.

The Common Lisp specification of format har more parameters
and options and bells and whsitles than printf, by far.  Guile's
implementation of format is based on the slib version, and supports
a large subset of the Common Lisp specification.  I've also implemented
most of Common Lisp format within Kawa:

#|kawa:1|# (format "[~12,5e]" (sqrt 2))
[  1.41421E+0]
--
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/


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


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

* Re: add printf.scm to ice-9?
  2002-04-07 16:09 add printf.scm to ice-9? Matthew R Wette
  2002-04-07 20:30 ` Per Bothner
@ 2002-04-07 23:53 ` Marius Vollmer
  2002-04-14 19:32   ` Rob Browning
  1 sibling, 1 reply; 10+ messages in thread
From: Marius Vollmer @ 2002-04-07 23:53 UTC (permalink / raw)
  Cc: guile-user

Matthew R Wette <mwette@grover.jpl.nasa.gov> writes:

> Marius Vollmer writes ...
> > Matthew R Wette <mwette@grover.jpl.nasa.gov> writes:
> > 
> > > I have been heavily using guile for an application at here at work.
> > > Guile seems to have everything I need except one item: printf.
> > 
> > Can't you use 'format' (which is the Lisp version of printf)?
> 
> I want formats like %12.5e and %-20s.
> My understanding is that this is not in format.

It is, see Per's post.  However, you need to '(use-modules (ice-9
format))'.  There is also a builtin simple-format that doesn't have
these options.

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


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

* Re: add printf.scm to ice-9?
  2002-04-07 20:30 ` Per Bothner
@ 2002-04-09  2:43   ` Steve Tell
  2002-04-09  4:05     ` Per Bothner
  2002-04-28 15:10     ` Marius Vollmer
  0 siblings, 2 replies; 10+ messages in thread
From: Steve Tell @ 2002-04-09  2:43 UTC (permalink / raw)
  Cc: Guile Mailing List

On Sun, 7 Apr 2002, Per Bothner wrote:

> most of Common Lisp format within Kawa:
> 
> #|kawa:1|# (format "[~12,5e]" (sqrt 2))
> [  1.41421E+0]

In guile, that's  (format #f "[~12,5e]" (sqrt 2))

I've wondered how one would translate somthing like 
	(let ((w 12)(d 5)) (printf "%*,*e" w d (sqrt 2)))
though.


But how terrible would it really be to provide both format and printf? 

Seems to me one of the great things about guile is that it brings together
both the lisp tradition and the unix tradition.  If this means a bigger
library of available routines, so be it. A lot of posix and other libc
functions are already provided as guile primitives or library routines.  
But in the unix tradition, formatted I/O means printf, as in C, bash, awk,
perl, etc.  What's one more library module in the name of providing
familar ground for programmers from both traditions?

Yes, of course the lisp-inherited format has bunch of additional features.  
It took a few minutes of study for me to decide that format-strings
probably aren't turing complete, but I'm still not 100% convinced.  
(Loops and conditionals in a format string? the mind boggles).








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


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

* Re: add printf.scm to ice-9?
  2002-04-09  2:43   ` Steve Tell
@ 2002-04-09  4:05     ` Per Bothner
  2002-04-28 15:10     ` Marius Vollmer
  1 sibling, 0 replies; 10+ messages in thread
From: Per Bothner @ 2002-04-09  4:05 UTC (permalink / raw)
  Cc: Guile Mailing List

Steve Tell wrote:
>>#|kawa:1|# (format "[~12,5e]" (sqrt 2))
>>[  1.41421E+0]
> 
> In guile, that's  (format #f "[~12,5e]" (sqrt 2))

Kawa allows the #f (or more generally the "destination"
specification) to be omitted.  I believe this was to
be compatible with some other Scheme  implementations.
It certainly is needed for compatibility with SRFI-28,
which implies "many Scheme implementations" have a format
function that does not require the #f.

> I've wondered how one would translate somthing like 
> 	(let ((w 12)(d 5)) (printf "%*,*e" w d (sqrt 2)))
> though.
> 
> But how terrible would it really be to provide both format and printf? 

Not terrible at all.  In fact slib (and Kawa) provide both.
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/


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


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

* Re: add printf.scm to ice-9?
  2002-04-07 23:53 ` Marius Vollmer
@ 2002-04-14 19:32   ` Rob Browning
  0 siblings, 0 replies; 10+ messages in thread
From: Rob Browning @ 2002-04-14 19:32 UTC (permalink / raw)
  Cc: Matthew R Wette, guile-user

Marius Vollmer <mvo@zagadka.ping.de> writes:

> It is, see Per's post.  However, you need to '(use-modules (ice-9
> format))'.  There is also a builtin simple-format that doesn't have
> these options.

I wish I could remember right now, but I recall needing some %
formatting functionality that sprintf (or was it sscanf) had that
guile didn't seem to provide.  It made me think that it might be nice
to have a more direct interface to the unix function for those that
want it, but I can't recall what the particular missing bit was.

Any reason we wouldn't want to provide a module providing
sprintf/sscanf functionality eventually?

-- 
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG=1C58 8B2C FB5E 3F64 EA5C  64AE 78FE E5FE F0CB A0AD

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


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

* Re: add printf.scm to ice-9?
  2002-04-09  2:43   ` Steve Tell
  2002-04-09  4:05     ` Per Bothner
@ 2002-04-28 15:10     ` Marius Vollmer
  1 sibling, 0 replies; 10+ messages in thread
From: Marius Vollmer @ 2002-04-28 15:10 UTC (permalink / raw)
  Cc: Guile Mailing List

Steve Tell <tell@telltronics.org> writes:

> But how terrible would it really be to provide both format and printf? 

Not really terrible.  Isn't it enough that SLIB provides printf?

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


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

end of thread, other threads:[~2002-04-28 15:10 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-07 16:09 add printf.scm to ice-9? Matthew R Wette
2002-04-07 20:30 ` Per Bothner
2002-04-09  2:43   ` Steve Tell
2002-04-09  4:05     ` Per Bothner
2002-04-28 15:10     ` Marius Vollmer
2002-04-07 23:53 ` Marius Vollmer
2002-04-14 19:32   ` Rob Browning
  -- strict thread matches above, loose matches on Subject: below --
2002-04-06 22:00 Matthew R Wette
2002-04-07 10:42 ` Marius Vollmer
2002-04-07 14:38 ` Neil Jerram

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