unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* why format procedure produce error?
@ 2009-11-11 11:45 Changying Li
  2009-11-11 16:20 ` Linas Vepstas
  2009-11-14 14:18 ` Neil Jerram
  0 siblings, 2 replies; 5+ messages in thread
From: Changying Li @ 2009-11-11 11:45 UTC (permalink / raw)
  To: guile-user

in the guile manual:
 -- Scheme Procedure: format dest fmt [args...]
     Write output specified by the FMT string to DEST.  DEST can be an
     output port, `#t' for `current-output-port' (*note Default
     Ports::), a number for `current-error-port', or `#f' to return the
     output as a string.

what's the meaning of NUMBER?
I want to write things to error port, so I write
(format 1 "hello")

standard input:5:1: In procedure simple-format in expression (format 1 "hello"):
standard input:5:1: Wrong type argument in position 1: 1
ABORT: (wrong-type-arg)


it work when I use (format (current-error-port) "hello")

Is there something wrong in the guile manual ?


-- 

Thanks & Regards

Changying Li





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

* Re: why format procedure produce error?
  2009-11-11 11:45 why format procedure produce error? Changying Li
@ 2009-11-11 16:20 ` Linas Vepstas
  2009-11-12  1:10   ` Changying Li
  2009-11-14 14:18 ` Neil Jerram
  1 sibling, 1 reply; 5+ messages in thread
From: Linas Vepstas @ 2009-11-11 16:20 UTC (permalink / raw)
  To: lchangying; +Cc: guile-user

2009/11/11 Changying Li <lchangying@gmail.com>:
> in the guile manual:
>  -- Scheme Procedure: format dest fmt [args...]
>     Write output specified by the FMT string to DEST.  DEST can be an
>     output port, `#t' for `current-output-port' (*note Default
>     Ports::), a number for `current-error-port', or `#f' to return the
>     output as a string.
>
> what's the meaning of NUMBER?
> I want to write things to error port, so I write
> (format 1 "hello")
>
> standard input:5:1: In procedure simple-format in expression (format 1 "hello"):
> standard input:5:1: Wrong type argument in position 1: 1
> ABORT: (wrong-type-arg)
>
>
> it work when I use (format (current-error-port) "hello")
>
> Is there something wrong in the guile manual ?


That would be my guess.  I assume that once upon a time,
an integer was interpreted as a file or socket number, but
that this code was later disabled, and the documentation
was not changed.  I guess that supporting fileno would have
made an mswindows version difficult -- besides, raw fileno
numbers are kind of a bad idea in this day and age.

--linas




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

* Re: why format procedure produce error?
  2009-11-11 16:20 ` Linas Vepstas
@ 2009-11-12  1:10   ` Changying Li
  2010-08-28 20:45     ` Andy Wingo
  0 siblings, 1 reply; 5+ messages in thread
From: Changying Li @ 2009-11-12  1:10 UTC (permalink / raw)
  To: guile-user


I can't agree you more...

Linas Vepstas <linasvepstas@gmail.com> writes:

> 2009/11/11 Changying Li <lchangying@gmail.com>:
>> in the guile manual:
>>  -- Scheme Procedure: format dest fmt [args...]
>>     Write output specified by the FMT string to DEST.  DEST can be an
>>     output port, `#t' for `current-output-port' (*note Default
>>     Ports::), a number for `current-error-port', or `#f' to return the
>>     output as a string.
>>
>> what's the meaning of NUMBER?
>> I want to write things to error port, so I write
>> (format 1 "hello")
>>
>> standard input:5:1: In procedure simple-format in expression (format 1 "hello"):
>> standard input:5:1: Wrong type argument in position 1: 1
>> ABORT: (wrong-type-arg)
>>
>>
>> it work when I use (format (current-error-port) "hello")
>>
>> Is there something wrong in the guile manual ?
>
>
> That would be my guess.  I assume that once upon a time,
> an integer was interpreted as a file or socket number, but
> that this code was later disabled, and the documentation
> was not changed.  I guess that supporting fileno would have
> made an mswindows version difficult -- besides, raw fileno
> numbers are kind of a bad idea in this day and age.
>
> --linas
>
>
>

-- 

Thanks & Regards

Changying Li





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

* Re: why format procedure produce error?
  2009-11-11 11:45 why format procedure produce error? Changying Li
  2009-11-11 16:20 ` Linas Vepstas
@ 2009-11-14 14:18 ` Neil Jerram
  1 sibling, 0 replies; 5+ messages in thread
From: Neil Jerram @ 2009-11-14 14:18 UTC (permalink / raw)
  To: lchangying; +Cc: guile-user

Changying Li <lchangying@gmail.com> writes:

> in the guile manual:
>  -- Scheme Procedure: format dest fmt [args...]
>      Write output specified by the FMT string to DEST.  DEST can be an
>      output port, `#t' for `current-output-port' (*note Default
>      Ports::), a number for `current-error-port', or `#f' to return the
>      output as a string.
>
> what's the meaning of NUMBER?
> I want to write things to error port, so I write
> (format 1 "hello")
>
> standard input:5:1: In procedure simple-format in expression (format 1 "hello"):
> standard input:5:1: Wrong type argument in position 1: 1
> ABORT: (wrong-type-arg)

You need to add (use-modules (ice-9 format)) to your code, to get the
full implementation of `format'.  Then the "number means
current-error-port" thing should work.

At the moment, you're actually using `simple-format'.

> Is there something wrong in the guile manual ?

I don't think so, because the documentation that you cited comes from a
section that begins by saying that

   "This function is available from

     (use-modules (ice-9 format))"

Regards,
        Neil




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

* Re: why format procedure produce error?
  2009-11-12  1:10   ` Changying Li
@ 2010-08-28 20:45     ` Andy Wingo
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Wingo @ 2010-08-28 20:45 UTC (permalink / raw)
  To: lchangying; +Cc: guile-user

Hi Changying,

>> 2009/11/11 Changying Li <lchangying@gmail.com>:
>>> in the guile manual:
>>>  -- Scheme Procedure: format dest fmt [args...]
>>>     Write output specified by the FMT string to DEST.  DEST can be an
>>>     output port, `#t' for `current-output-port' (*note Default
>>>     Ports::), a number for `current-error-port', or `#f' to return the
>>>     output as a string.
>>>
>>> what's the meaning of NUMBER?
>>> I want to write things to error port, so I write
>>> (format 1 "hello")
>>>
>>> standard input:5:1: In procedure simple-format in expression (format 1 "hello"):
>>> standard input:5:1: Wrong type argument in position 1: 1
>>> ABORT: (wrong-type-arg)
>>>
>>>
>>> it work when I use (format (current-error-port) "hello")
>>>
>>> Is there something wrong in the guile manual ?

No, this would work if you had loaded (ice-9 format). Guile's built-in
format is not as full-featured as the scheme version.

However passing a number to indicate current-error-port is silly, so I
have deprecated that in master, and removed this piece from the
documentation.

Cheers,

Andy
-- 
http://wingolog.org/



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

end of thread, other threads:[~2010-08-28 20:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-11 11:45 why format procedure produce error? Changying Li
2009-11-11 16:20 ` Linas Vepstas
2009-11-12  1:10   ` Changying Li
2010-08-28 20:45     ` Andy Wingo
2009-11-14 14:18 ` 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).