Re: How to determine allowable external formats at run time

Alan Ruttenberg <[email protected]>
Newsgroups gmane.editors.j.devel
Message-ID <CAFKQJ8nGn1=CSahBxdcZOgJdh_mXWavf90xXDKF3JdXL=vpssQ@mail.gmail.com>
On Sat, Mar 24, 2018 at 7:14 PM, Robert Dodier <[email protected]>
wrote:

> Hi,
>
> I'm wondering if there is a way to get the list of allowable values of
> the :EXTERNAL-FORMAT keyword for OPEN. Is there a way to determine the
> possible values at run time? I looked into the source code for
> MAKE-FILE-STREAM but I got a little lost ... perhaps someone can point
> me in the right direction.
>
> What I'm trying to do is to verify whether a given format is
> acceptable. I am thinking that I can inspect a list to see if the
> given format is on the list. Another workable solution would be a
> function which can report whether the given format is acceptable, if
> such a function exists.
>

I don't know that there's a way to enumerate them. However you can call
open with an external format and it seems it will throw an exception if it
isn't one.

Undefined encoding: FUDGE
   [Condition of type simple-error]

Restarts:
 0: [retry] Retry SLIME REPL evaluation request.
 1: [*abort] Return to SLIME's top level.
 2: [abort] Abort thread.

Backtrace:
  0: (invoke-debugger #<simple-error {2EDCBCEA}>)
  1: org.armedbear.lisp.Lisp.error(Lisp.java:382)

There's also some documentation in FileStream.java
<https://github.com/armedbear/abcl/blob/master/src/org/armedbear/lisp/FileStream.java#L60>
that
shows that one of the possibilities is a list with a charset as car. You
can get the available charsets with

(loop for k being the hash-keys of (jss::hashmap-to-hashtable
(#"availableCharsets" 'charset.charset)) collect k)

Alan


>
> Thanks for your help,
>
> Robert Dodier
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.