Re: about dynamic/1 and file format

Jeff Rosenwald <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[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 list
[email protected]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog

 
-------------- next part --------------
HTML attachment scrubbed and removed
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.