Re: about dynamic/1 and file format
Jiun-Shiung Wu <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <CALvsX_JOw_XMVRVtm3Vj6v8yJ7SMDN1qvLpLoKKGgOVSNt=mEQ@mail.gmail.com> |
Hi, Jeff, Thank you very much for your response. As for dynamic, I am talking about the second one in your response. Because I am trying to establish a knowledge base in which new facts can be added, I declare :- dynamic(father/2) at the beginning of my file. When I write all of the father/2 facts into a new file, I get :- dynamic father/2 at the beginning of my new file. When I try my program again, :- dynamic father/2 does not work. So, is there a way to put the parentheses back? As for file format, I used open/4 and I did specify the file format to be UTF-8. But, I opened the file with Notepad++, it showed that the file was the format of UTF-8 without the BOM header. So.... Best, Hunter ------------------------------------------------------ Wu, Jiun-Shiung, Ph.D. Professor Institute of Linguistics National Chung Cheng University 168, University Road, Minhsiung, Chiayi County, Taiwan 621 ------------------------------------------------------- 2014/1/6 Jeff Rosenwald <[email protected]> > Hi Hunter: > > On the business of dynamic predicates, it is not entirely clear what you > are trying to accomplish. > > There are two syntaxes for "dynamic" predicates: 1) as a directive (usage > in the body of a headless predicate), and 2) as an ordinary predicate used > in the body of a named predicate. The first provides for compile-time > declaration of dynamic predicates and in that case, the grammar allows you > to specify one or more name/arity combinations separated by commas. There > are no parentheses. The second syntax provides for run-time declaration of > dynamic predicates. It is structured as an ordinary predicate and allows > exactly one name/arity compound as an argument. I believe that the > postcondition is the same regardless of the form used. > > When writing a text file using Prolog streams, you can specify the > encoding of the file using the type(text) and encoding/1 options of open/3. > I believe that you can also use set_set_stream_property/2 as well. When > writing files (using external editors and such) that you wish to eventually > consult with SWIPL, you may supply an encoding/1 directive as the first > line of the file. > > Regards, > Jeff R. > > > > -----Original Message----- > From: Jiun-Shiung Wu <[email protected]> > To: swi-prolog <[email protected]> > Sent: Mon, Jan 6, 2014 7:22 am > Subject: [SWIPL] about dynamic/1 and file format > > Hi, SWI-Prolog users, > > I have two questions concerning dynamic/1 and saved file format. I am > wondering if someone can help me. > > I used dynamic to declare that a predicate is dynamic. For example, I put > :- dynamic(father/2) at the beginning of my file. I used listing(father/2) > to list all instances of father/2. I found that the parentheses in dynamic > is gone. That is, when I did listing(father/2), I got: dynamic father/2. > When I used with_input_to to save all instances of father/2, I got :- > dynamic father/2 at the beginning of the new file. The parentheses are > missing. Is there a way not to remove the parentheses in this case? > > Secondly, how can I save a file using the UTF-8 with the header BOM? I have > a knowledge base containing facts written in traditional Chinese (UTF-8). > When I used with_input_to to save those facts into a new file, the BOM head > seems to be gone and my Prolog program cannot read it. Though it is easy to > restore the BOM head using Notepadd++, I am still wondering whether > SWI-Prolog can save a file using UTF-8 with the BOM head. > > Thank you! > > Hunter Wu > -------------- next part -------------- > HTML attachment scrubbed and removed > _______________________________________________ > SWI-Prolog mailing [email protected]://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog > > -------------- next part -------------- HTML attachment scrubbed and removed