How to determine allowable external formats at run time
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. Thanks for your help, Robert Dodier
On Sat, Mar 24, 2018 at 7:14 PM, Robert Dodier <robert.dodier@gmail.com> 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
participants (2)
-
Alan Ruttenberg
-
Robert Dodier