diff --git a/C/corout.c b/C/corout.c
index 44906b4d1..553e1d443 100644
--- a/C/corout.c
+++ b/C/corout.c
@@ -894,7 +894,8 @@ can_unify(Term t1, Term t2, Term *Vars)
if (IsVarTerm(t1)) {
/* we know for sure they can't be different */
if (IsVarTerm(t2)) {
- /* we need to suspend on both variables ! */
+ /* we need to suspend on both variables because otherwise
+ Y = susp(_) would not wakeup susp ! */
*Vars = MkPairTerm(t1,MkPairTerm(t2,TermNil));
return(TRUE);
} else {
diff --git a/C/errors.c b/C/errors.c
index d9e3f72a1..1b648f373 100644
--- a/C/errors.c
+++ b/C/errors.c
@@ -1155,6 +1155,27 @@ Error (yap_error_number type, Term where, char *format,...)
serious = TRUE;
}
break;
+ case PERMISSION_ERROR_NEW_ALIAS_FOR_STREAM:
+ {
+ int i;
+ Term ti[3];
+
+#if HAVE_STRNCAT
+ strncat(p, " in ", psize);
+#else
+ strcat(p, " in ");
+#endif
+ i = strlen(p);
+ ti[0] = MkAtomTerm(LookupAtom("new"));
+ ti[1] = MkAtomTerm(LookupAtom("alias"));
+ ti[2] = where;
+ nt[0] = MkApplTerm(MkFunctor(LookupAtom("permission_error"),3), 3, ti);
+ tp = p+i;
+ psize -= i;
+ fun = MkFunctor(LookupAtom("error"),2);
+ serious = TRUE;
+ }
+ break;
case PERMISSION_ERROR_OPEN_SOURCE_SINK:
{
int i;
diff --git a/C/init.c b/C/init.c
index d279ce7b7..9d9852e7d 100644
--- a/C/init.c
+++ b/C/init.c
@@ -690,7 +690,11 @@ InitFlags(void)
{
/* note that heap_regs must be set first */
+#if USE_GMP
+ yap_flags[YAP_INT_BOUNDED_FLAG] = 0;
+#else
yap_flags[YAP_INT_BOUNDED_FLAG] = 1;
+#endif
yap_flags[MAX_ARITY_FLAG] = -1;
yap_flags[INTEGER_ROUNDING_FLAG] = 0;
yap_flags[YAP_MAX_INTEGER_FLAG] = (Int)(~((CELL)1 << (sizeof(Int)*8-1)));
@@ -946,6 +950,8 @@ InitCodes(void)
heap_regs->term_dollar_u = MkAtomTerm(LookupAtom("$u"));
#endif
heap_regs->term_refound_var = MkAtomTerm(LookupAtom("$I_FOUND_THE_VARIABLE_AGAIN"));
+ heap_regs->n_of_file_aliases = 0;
+ heap_regs->file_aliases = NULL;
heap_regs->foreign_code_loaded = NULL;
heap_regs->yap_lib_dir = NULL;
heap_regs->size_of_overflow = 0;
diff --git a/C/iopreds.c b/C/iopreds.c
index d3f5133b8..11920568c 100644
--- a/C/iopreds.c
+++ b/C/iopreds.c
@@ -98,14 +98,6 @@ typedef struct
}
StreamDesc;
-typedef struct AliasDescS
- {
- Atom name;
- int my_stream;
- struct AliasDescS *next;
- }
-* AliasDesc;
-
STATIC_PROTO (void InitStdStream, (int, SMALLUNSGN, YP_File, Atom));
STATIC_PROTO (Int PlIOError, (yap_error_number, Term, char *));
STATIC_PROTO (int FilePutc, (int, int));
@@ -136,7 +128,8 @@ STATIC_PROTO (Term MkStream, (int));
STATIC_PROTO (Int p_stream_flags, (void));
STATIC_PROTO (int find_csult_file, (char *, char *, StreamDesc *, char *));
STATIC_PROTO (Int p_open, (void));
-STATIC_PROTO (void AddAlias, (Atom, int));
+STATIC_PROTO (int AddAlias, (Atom, int));
+STATIC_PROTO (void SetAlias, (Atom, int));
STATIC_PROTO (void PurgeAlias, (int));
STATIC_PROTO (int CheckAlias, (Atom));
STATIC_PROTO (Atom FetchAlias, (int));
@@ -177,6 +170,7 @@ STATIC_PROTO (Int p_show_stream_flags, (void));
STATIC_PROTO (Int p_show_stream_position, (void));
STATIC_PROTO (Int p_set_stream_position, (void));
STATIC_PROTO (Int p_add_alias_to_stream, (void));
+STATIC_PROTO (Int p_change_alias_to_stream, (void));
STATIC_PROTO (Int p_check_if_valid_new_alias, (void));
STATIC_PROTO (Int p_fetch_stream_alias, (void));
STATIC_PROTO (Int GetArgSizeFromThirdArg, (char **, Term *));
@@ -234,13 +228,12 @@ static int parser_error_style = FAIL_ON_PARSER_ERROR;
#define StdOutStream 1
#define StdErrStream 2
+#define ALIASES_BLOCK_SIZE 8
#if USE_SOCKET
extern int YP_sockets_io;
#endif
-static AliasDesc AliasList = NULL;
-
static void
unix_upd_stream_info (StreamDesc * s)
{
@@ -360,8 +353,7 @@ InitStdStream (int sno, SMALLUNSGN flags, YP_File file, Atom name)
s->stream_putc = FilePutc;
s->stream_getc = PlGetc;
}
- s->u.file.name = name;
- s->u.file.user_name = MkAtomTerm (name);
+ s->u.file.user_name = MkAtomTerm (s->u.file.name);
}
if (CharConversionTable != NULL)
s->stream_getc_for_read = ISOGetc;
@@ -391,7 +383,17 @@ InitPlIO (void)
InitStdStream (StdErrStream, Output_Stream_f, YP_stderr, AtomUsrErr);
c_input_stream = StdInStream;
c_output_stream = StdOutStream;
- AliasList = NULL;
+ /* alloca alias array */
+ FileAliases = (AliasDesc)AllocCodeSpace(sizeof(struct AliasDescS)*ALIASES_BLOCK_SIZE);
+ /* init standard aliases */
+ FileAliases[0].name = AtomUsrIn;
+ FileAliases[0].alias_stream = 0;
+ FileAliases[1].name = AtomUsrOut;
+ FileAliases[1].alias_stream = 1;
+ FileAliases[2].name = AtomUsrErr;
+ FileAliases[2].alias_stream = 2;
+ NOfFileAliases = 3;
+ SzOfFileAliases = ALIASES_BLOCK_SIZE;
}
static Int
@@ -673,11 +675,16 @@ ReadlineGetc(int sno)
if (newline) {
char *cptr = Prompt, ch;
- /* don't just output the prompt */
- while ((ch = *cptr++) != '\0') {
- console_count_output_char(ch,Stream+StdErrStream,StdErrStream);
+ if ((Stream[FileAliases[2].alias_stream].status & Tty_Stream_f) &&
+ Stream[FileAliases[2].alias_stream].u.file.name == Stream[sno].u.file.name) {
+ /* don't just output the prompt */
+ while ((ch = *cptr++) != '\0') {
+ console_count_output_char(ch,Stream+StdErrStream,StdErrStream);
+ }
+ _line = readline (Prompt);
+ } else {
+ _line = readline ("");
}
- _line = readline (Prompt);
} else {
_line = readline ("");
}
@@ -1199,8 +1206,11 @@ p_open (void)
}
open_mode = AtomOfTerm (t2);
if (open_mode == AtomRead || open_mode == AtomCsult) {
+ if (open_mode == AtomCsult && AtomOfTerm(file_name) == AtomUsrIn) {
+ return(unify(MkStream(FileAliases[0].alias_stream), ARG3));
+ }
strncpy(io_mode,"rb", 8);
- s = Input_Stream_f;
+ s = Input_Stream_f;
} else if (open_mode == AtomWrite) {
strncpy(io_mode,"w",8);
s = Output_Stream_f;
@@ -1340,7 +1350,33 @@ static Int p_add_alias_to_stream (void)
}
at = AtomOfTerm(tname);
sno = (int)IntOfTerm(ArgOfTerm(1,tstream));
- AddAlias(at, sno);
+ if (AddAlias(at, sno))
+ return(TRUE);
+ /* we could not create the alias, time to close the stream */
+ CloseStream(sno);
+ Error(PERMISSION_ERROR_NEW_ALIAS_FOR_STREAM, tname, "open/3");
+ return (FALSE);
+}
+
+static Int p_change_alias_to_stream (void)
+{
+ Term tname = Deref(ARG1);
+ Term tstream = Deref(ARG2);
+ Atom at;
+ Int sno;
+
+ if (IsVarTerm(tname)) {
+ Error(INSTANTIATION_ERROR, tname, "$change_alias_to_stream/2");
+ return (FALSE);
+ } else if (!IsAtomTerm (tname)) {
+ Error(TYPE_ERROR_ATOM, tname, "$change_alias_to_stream/2");
+ return (FALSE);
+ }
+ at = AtomOfTerm(tname);
+ if ((sno = CheckStream (tstream, Input_Stream_f | Output_Stream_f | Append_Stream_f | Socket_Stream_f, "change_stream_alias/2"))
+ == -1)
+ return(FALSE);
+ SetAlias(at, sno);
return(TRUE);
}
@@ -1380,7 +1416,7 @@ p_fetch_stream_alias (void)
default:
if (IsVarTerm(t2)) {
Atom at = FetchAlias(sno);
- if (at == AtomUsrIn)
+ if (at == AtomFoundVar)
return(FALSE);
else
return(unify_constant(t2, MkAtomTerm(at)));
@@ -1524,83 +1560,134 @@ p_open_mem_write_stream (void) /* $open_mem_write_stream(-Stream) */
return (unify (ARG1, t));
}
-/* create a new alias arg for stream sno */
static void
+ExtendAliasArray(void)
+{
+ AliasDesc new;
+ UInt new_size = SzOfFileAliases+ALIASES_BLOCK_SIZE;
+
+ new = (AliasDesc)AllocCodeSpace(sizeof(AliasDesc *)*new_size);
+ memcpy((void *)new, (void *)FileAliases, sizeof(AliasDesc *)*SzOfFileAliases);
+ FreeCodeSpace((ADDR)FileAliases);
+ FileAliases = new;
+ SzOfFileAliases = new_size;
+}
+
+/* create a new alias arg for stream sno */
+static int
AddAlias (Atom arg, int sno)
{
- AliasDesc aliasp = AliasList;
+ AliasDesc aliasp = FileAliases, aliasp_max = FileAliases+NOfFileAliases;
- while (aliasp != NULL) {
+ while (aliasp < aliasp_max) {
if (aliasp->name == arg) {
- aliasp->my_stream = sno;
+ if (aliasp->alias_stream != sno) {
+ return(FALSE);
+ }
+ return(TRUE);
+ }
+ aliasp++;
+ }
+ /* we have not found an alias neither a hole */
+ if (aliasp == FileAliases+SzOfFileAliases)
+ ExtendAliasArray();
+ NOfFileAliases++;
+ aliasp->name = arg;
+ aliasp->alias_stream = sno;
+ return(TRUE);
+}
+
+/* create a new alias arg for stream sno */
+static void
+SetAlias (Atom arg, int sno)
+{
+
+ AliasDesc aliasp = FileAliases, aliasp_max = FileAliases+NOfFileAliases;
+
+ while (aliasp < aliasp_max) {
+ if (aliasp->name == arg) {
+ aliasp->alias_stream = sno;
return;
}
- else aliasp = aliasp->next;
+ aliasp++;
}
- aliasp = (AliasDesc)AllocAtomSpace(sizeof(struct AliasDescS));
+ /* we have not found an alias, create one */
+ if (aliasp == FileAliases+SzOfFileAliases)
+ ExtendAliasArray();
+ NOfFileAliases++;
aliasp->name = arg;
- aliasp->my_stream = sno;
- aliasp->next = AliasList;
- AliasList = aliasp;
+ aliasp->alias_stream = sno;
}
/* purge all aliases for stream sno */
static void
PurgeAlias (int sno)
{
-
- AliasDesc aliasp = AliasList,
- prev = NULL;
-
- while (aliasp != NULL) {
- if (aliasp->my_stream == sno) {
- if (prev == NULL)
- AliasList = aliasp->next;
- else
- prev->next = aliasp->next;
- FreeAtomSpace((char *)aliasp);
- } else
- prev = aliasp;
- aliasp = aliasp->next;
+ AliasDesc aliasp = FileAliases, aliasp_max = FileAliases+NOfFileAliases, new_aliasp = aliasp;
+
+ while (aliasp < aliasp_max) {
+ if (aliasp->alias_stream == sno) {
+ if (aliasp - FileAliases < 3) {
+ /* get back to std streams, but keep alias around */
+ new_aliasp->alias_stream = aliasp-FileAliases;
+ new_aliasp++;
+ } else {
+ NOfFileAliases--;
+ }
+ } else {
+ /* avoid holes in alias array */
+ if (new_aliasp != aliasp) {
+ new_aliasp->alias_stream = aliasp->alias_stream;
+ new_aliasp->name = aliasp->name;
+ }
+ new_aliasp++;
+ }
+ aliasp++;
}
}
-/* check if arg is an alias */
+/* check if name is an alias */
static int
CheckAlias (Atom arg)
{
- AliasDesc aliasp = AliasList;
- while (aliasp != NULL) {
- if (aliasp->name == arg)
- return(aliasp->my_stream);
- else aliasp = aliasp->next;
+ AliasDesc aliasp = FileAliases, aliasp_max = FileAliases+NOfFileAliases;
+
+ while (aliasp < aliasp_max) {
+ if (aliasp->name == arg) {
+ return(aliasp->alias_stream);
+ }
+ aliasp++;
}
return(-1);
}
-/* check if arg is an alias */
+/* check if stream has an alias */
static Atom
FetchAlias (int sno)
{
- AliasDesc aliasp = AliasList;
- while (aliasp != NULL) {
- if (aliasp->my_stream == sno)
+ AliasDesc aliasp = FileAliases, aliasp_max = FileAliases+NOfFileAliases;
+
+ while (aliasp < aliasp_max) {
+ if (aliasp->alias_stream == sno) {
return(aliasp->name);
- else aliasp = aliasp->next;
+ }
+ aliasp++;
}
- return(AtomUsrIn);
+ return(AtomFoundVar);
}
/* check if arg is an alias */
static int
FindAliasForStream (int sno, Atom al)
{
- AliasDesc aliasp = AliasList;
- while (aliasp != NULL) {
- if (aliasp->my_stream == sno && aliasp->name == al)
+ AliasDesc aliasp = FileAliases, aliasp_max = FileAliases+NOfFileAliases;
+
+ while (aliasp < aliasp_max) {
+ if (aliasp->alias_stream == sno && aliasp->name == al) {
return(TRUE);
- else aliasp = aliasp->next;
+ }
+ aliasp++;
}
return(FALSE);
}
@@ -1614,44 +1701,30 @@ CheckStream (Term arg, int kind, char *msg)
Error(INSTANTIATION_ERROR, arg, msg);
return (-1);
}
- else if (IsAtomTerm (arg))
- {
- Atom sname = AtomOfTerm (arg);
- if (sname == AtomUsrIn)
- sno = StdInStream;
- else if (sname == AtomUsrOut)
- sno = StdOutStream;
- else if (sname == AtomUsrErr)
- sno = StdErrStream;
- else if (sname == AtomUser)
- {
- if (kind & Input_Stream_f)
- sno = StdInStream;
- if (kind & Output_Stream_f) {
- if (sno >= 0)
- {
- Error(PERMISSION_ERROR_INPUT_STREAM, arg,
- "ambiguous use of 'user' as a stream");
- return (-1);
- }
- else {
- sno = StdOutStream;
- }
- }
- }
- else {
- if ((sno = CheckAlias(sname)) == -1) {
- Error(EXISTENCE_ERROR_STREAM, arg, msg);
- return(-1);
+ else if (IsAtomTerm (arg)) {
+ Atom sname = AtomOfTerm (arg);
+
+ if (sname == AtomUser) {
+ if (kind & Input_Stream_f) {
+ if (kind & (Output_Stream_f|Append_Stream_f)) {
+ Error(PERMISSION_ERROR_INPUT_STREAM, arg,
+ "ambiguous use of 'user' as a stream");
+ return (-1);
}
+ sname = AtomUsrIn;
+ } else {
+ sname = AtomUsrOut;
}
}
- else if (IsApplTerm (arg) && FunctorOfTerm (arg) == FunctorStream)
- {
- arg = ArgOfTerm (1, arg);
- if (!IsVarTerm (arg) && IsIntTerm (arg))
- sno = IntOfTerm (arg);
+ if ((sno = CheckAlias(sname)) == -1) {
+ Error(EXISTENCE_ERROR_STREAM, arg, msg);
+ return(-1);
}
+ } else if (IsApplTerm (arg) && FunctorOfTerm (arg) == FunctorStream) {
+ arg = ArgOfTerm (1, arg);
+ if (!IsVarTerm (arg) && IsIntTerm (arg))
+ sno = IntOfTerm (arg);
+ }
if (sno < 0)
{
Error(DOMAIN_ERROR_STREAM_OR_ALIAS, arg, msg);
@@ -1685,7 +1758,7 @@ p_check_stream (void)
static Int
p_check_if_stream (void)
{ /* '$check_stream'(Stream) */
- return (CheckStream (ARG1, Input_Stream_f | Output_Stream_f | Socket_Stream_f, "check_stream/1")
+ return (CheckStream (ARG1, Input_Stream_f | Output_Stream_f | Append_Stream_f | Socket_Stream_f, "check_stream/1")
!= -1);
}
@@ -4159,6 +4232,7 @@ InitIOPreds(void)
InitCPred ("$force_char_conversion", 0, p_force_char_conversion, SyncPredFlag);
InitCPred ("$disable_char_conversion", 0, p_disable_char_conversion, SyncPredFlag);
InitCPred ("$add_alias_to_stream", 2, p_add_alias_to_stream, SafePredFlag|SyncPredFlag);
+ InitCPred ("$change_alias_to_stream", 2, p_change_alias_to_stream, SafePredFlag|SyncPredFlag);
InitCPred ("$check_if_valid_new_alias", 1, p_check_if_valid_new_alias, TestPredFlag|SafePredFlag|SyncPredFlag);
InitCPred ("$fetch_stream_alias", 2, p_fetch_stream_alias, SafePredFlag|SyncPredFlag);
#if HAVE_SELECT
diff --git a/C/save.c b/C/save.c
index 0ce30a79e..9c01d44a0 100644
--- a/C/save.c
+++ b/C/save.c
@@ -1084,6 +1084,10 @@ restore_codes(void)
heap_regs->term_dollar_u = AtomTermAdjust(heap_regs->term_dollar_u);
#endif
heap_regs->term_refound_var = AtomTermAdjust(heap_regs->term_refound_var);
+ heap_regs->file_aliases =
+ (void *)AddrAdjust((ADDR)heap_regs->file_aliases);
+ heap_regs->yap_lib_dir =
+ (char *)AddrAdjust((ADDR)heap_regs->yap_lib_dir);
heap_regs->pred_goal_expansion =
(PredEntry *)AddrAdjust((ADDR)heap_regs->pred_goal_expansion);
heap_regs->pred_meta_call =
diff --git a/H/Heap.h b/H/Heap.h
index b45de974f..9a1cee26c 100644
--- a/H/Heap.h
+++ b/H/Heap.h
@@ -10,7 +10,7 @@
* File: Heap.h *
* mods: *
* comments: Heap Init Structure *
-* version: $Id: Heap.h,v 1.1.1.1 2001-04-09 19:53:39 vsc Exp $ *
+* version: $Id: Heap.h,v 1.2 2001-04-16 16:41:04 vsc Exp $ *
*************************************************************************/
/* information that can be stored in Code Space */
@@ -247,6 +247,9 @@ typedef struct various_codes {
void *last_wtime;
PredEntry *pred_goal_expansion;
PredEntry *pred_meta_call;
+ UInt n_of_file_aliases;
+ UInt sz_of_file_aliases;
+ void * file_aliases;
void *foreign_code_loaded;
char *yap_lib_dir;
#if defined(YAPOR) || defined(TABLING)
@@ -418,6 +421,9 @@ typedef struct various_codes {
#define TermReFoundVar heap_regs->term_refound_var
#define PredGoalExpansion heap_regs->pred_goal_expansion
#define PredMetaCall heap_regs->pred_meta_call
+#define NOfFileAliases heap_regs->n_of_file_aliases
+#define SzOfFileAliases heap_regs->sz_of_file_aliases
+#define FileAliases ((AliasDesc)(heap_regs->file_aliases))
#define ForeignCodeLoaded heap_regs->foreign_code_loaded
#define Yap_LibDir heap_regs->yap_lib_dir
#define DeadClauses heap_regs->dead_clauses
diff --git a/H/yapio.h b/H/yapio.h
index e4da9456b..9f8f2e408 100644
--- a/H/yapio.h
+++ b/H/yapio.h
@@ -211,6 +211,12 @@ typedef enum{ /* we accept two domains for the moment, IPV6 may follow */
af_unix /* or AF_FILE */
} socket_domain;
+/* info on aliases */
+typedef struct AliasDescS {
+ Atom name;
+ int alias_stream;
+} * AliasDesc;
+
Term STD_PROTO(InitSocketStream,(int, socket_info, socket_domain));
int STD_PROTO(CheckSocketStream,(Term, char *));
socket_domain STD_PROTO(GetSocketDomain,(int));
@@ -253,7 +259,7 @@ void STD_PROTO(CloseStream,(int));
int STD_PROTO(PlGetchar,(void));
int STD_PROTO(PlFGetchar,(void));
-extern int c_input_stream, c_output_stream;
+extern int c_input_stream, c_output_stream, c_error_stream;
/* routines in sysbits.c */
char *STD_PROTO(pfgets,(char *,int,YP_File));
diff --git a/Makefile.in b/Makefile.in
index d61cd36c3..46310c85a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -434,45 +434,44 @@ libYap.a: $(LIB_OBJECTS)
install: @INSTALL_COMMAND@
install_unix:
- -mkdir -p $(BINDIR)
- $(INSTALL_PROGRAM) -m 755 yap $(BINDIR)/yap
- -mkdir -p $(YAPLIBDIR)
- $(INSTALL_DATA) -m 644 startup $(YAPLIBDIR)/startup
- $(INSTALL_DATA) -m 644 libYap.a $(LIBDIR)/libYap.a
- (cd $(srcdir) ; tar cf - library) | (cd $(YAPLIBDIR) ; tar xf -)
- $(INSTALL_DATA) $(srcdir)/LGPL/icon_address.pl $(YAPLIBDIR)/library
- $(INSTALL_DATA) $(srcdir)/LGPL/pillow.pl $(YAPLIBDIR)/library
- (cd $(srcdir)/CLPQR ; tar cf - .) | (cd $(YAPLIBDIR)/library ; tar xf -)
- (cd $(srcdir)/CHR ; tar cf - .) | (cd $(YAPLIBDIR)/library ; tar xf -)
+ -mkdir -p $(DESTDIR)$(BINDIR)
+ $(INSTALL_PROGRAM) -m 755 yap $(DESTDIR)$(BINDIR)/yap
+ -mkdir -p $(DESTDIR)$(YAPLIBDIR)
+ $(INSTALL_DATA) -m 644 startup $(DESTDIR)$(YAPLIBDIR)/startup
+ $(INSTALL_DATA) -m 644 libYap.a $(DESTDIR)$(LIBDIR)/libYap.a
+ (cd $(srcdir) ; tar cf - library) | (cd $(DESTDIR)$(YAPLIBDIR) ; tar xf -)
+ $(INSTALL_DATA) $(srcdir)/LGPL/icon_address.pl $(DESTDIR)$(YAPLIBDIR)/library
+ $(INSTALL_DATA) $(srcdir)/LGPL/pillow.pl $(DESTDIR)$(YAPLIBDIR)/library
+ (cd $(srcdir)/CLPQR ; tar cf - .) | (cd $(DESTDIR)$(YAPLIBDIR)/library ; tar xf -)
+ (cd $(srcdir)/CHR ; tar cf - .) | (cd $(DESTDIR)$(YAPLIBDIR)/library ; tar xf -)
@INSTALL_DLLS@ (cd library/regex; make install)
- -mkdir -p $(INCLUDEDIR)
- for h in $(INTERFACE_HEADERS); do $(INSTALL) $$h $(INCLUDEDIR); done
+ -mkdir -p $(DESTDIR)$(INCLUDEDIR)
+ for h in $(INTERFACE_HEADERS); do $(INSTALL) $$h $(DESTDIR)$(INCLUDEDIR); done
install_mingw32:
- -mkdir $(ROOTDIR)
- -mkdir $(BINDIR)
- -mkdir $(ROOTDIR)/lib
- -mkdir $(YAPLIBDIR)
- -mkdir $(ROOTDIR)/include
- -mkdir $(INCLUDEDIR)
- $(INSTALL_PROGRAM) -m 755 yap.exe $(BINDIR)/yap.exe
- $(INSTALL_PROGRAM) -m 755 yap.dll $(BINDIR)/yap.dll
- $(INSTALL_PROGRAM) -m 755 startup $(YAPLIBDIR)/startup
- $(INSTALL) $(srcdir)/include/c_interface.h $(INCLUDEDIR)/c_interface.h
+ -mkdir $(DESTDIR)$(ROOTDIR)
+ -mkdir $(DESTDIR)$(BINDIR)
+ -mkdir $(DESTDIR)$(ROOTDIR)/lib
+ -mkdir $(DESTDIR)$(YAPLIBDIR)
+ -mkdir $(DESTDIR)$(ROOTDIR)/include
+ -mkdir $(DESTDIR)$(INCLUDEDIR)
+ $(INSTALL_PROGRAM) -m 755 yap.exe $(DESTDIR)$(BINDIR)/yap.exe
+ $(INSTALL_PROGRAM) -m 755 yap.dll $(DESTDIR)$(BINDIR)/yap.dll
+ $(INSTALL_PROGRAM) -m 755 startup $(DESTDIR)$(YAPLIBDIR)/startup
+ $(INSTALL) $(HEADERS) $(DESTDIR)$(INCLUDEDIR)
+ $(INSTALL) $(srcdir)/include/c_interface.h $(DESTDIR)$(INCLUDEDIR)/c_interface.h
$(INSTALL) config.h $(INCLUDEDIR)/config.h
- (cd $(srcdir) ; tar cf - library) | (cd $(YAPLIBDIR) ; tar xf -)
- $(INSTALL_DATA) $(srcdir)/LGPL/icon_address.pl $(YAPLIBDIR)/library
- $(INSTALL_DATA) $(srcdir)/LGPL/pillow.pl $(YAPLIBDIR)/library
- (cd $(srcdir)/CLPQR ; tar cf - .) | (cd $(YAPLIBDIR)/library ; tar xf -)
- (cd $(srcdir)/CHR ; tar cf - .) | (cd $(YAPLIBDIR)/library ; tar xf -)
+ (cd $(srcdir) ; tar cf - library) | (cd $(DESTDIR)$(YAPLIBDIR) ; tar xf -)
+ $(INSTALL_DATA) $(srcdir)/LGPL/icon_address.pl $(DESTDIR)$(YAPLIBDIR)/library
+ $(INSTALL_DATA) $(srcdir)/LGPL/pillow.pl $(DESTDIR)$(YAPLIBDIR)/library
+ (cd $(srcdir)/CLPQR ; tar cf - .) | (cd $(DESTDIR)$(YAPLIBDIR)/library ; tar xf -)
+ (cd $(srcdir)/CHR ; tar cf - .) | (cd $(DESTDIR)$(YAPLIBDIR)/library ; tar xf -)
(cd library/regex; make install_mingw32)
- -mkdir $(INCLUDEDIR)
- $(INSTALL) $(HEADERS) $(INCLUDEDIR)
install_library: libYap.a
- $(INSTALL_DATA) -m 644 libYap.a $(LIBDIR)/libYap.a
- -mkdir $(INCLUDEDIR)
- $(INSTALL) $(HEADERS) $(INCLUDEDIR)
+ $(INSTALL_DATA) -m 644 libYap.a $(DESTDIR)$(LIBDIR)/libYap.a
+ -mkdir $(DESTDIR)$(INCLUDEDIR)
+ $(INSTALL) $(HEADERS) $(DESTDIR)$(INCLUDEDIR)
##########
TAGS: $(C_SOURCES) $(PL_SOURCES) $(HEADERS)
@@ -486,10 +485,10 @@ depend: $(HEADERS) $(C_SOURCES)
sed 's|.*/\([^:]*\):|\1:|' > .depend ;\
fi
-clean:
+clean: clean_docs
rm -f *.o *~ $(GHEADERS) *.BAK
-realclean: clean
+realclean: clean realclean_docs
rm -f yap startup config.log config.cache config.h
dist:
@@ -527,28 +526,60 @@ yap.dll: $(HEADERS) $(LIB_OBJECTS) $(DEF_FILE)
$(LD) $(EXP_FILE) --dll -o $(DLLNAME) $(LIB_OBJECTS) $(DLL_LIBS) -e $(ENTRY_FUNCTION)
install_info:
- cd $(srcdir)/docs ; \
make info; \
- $(INSTALL) yap.info* $(INFODIR); \
- if test -e $(INFODIR)/emacs.bz2; then \
- bzip2 --quiet --force $(INFODIR)/yap.info*; \
+ $(INSTALL) yap.info* $(DESTDIR)$(INFODIR); \
+ if test -e $(DESTDIR)$(INFODIR)/emacs.bz2; then \
+ bzip2 --quiet --force $(DESTDIR)$(INFODIR)/yap.info*; \
else \
- if test -e $(INFODIR)/emacs.gz; then \
- gzip --quiet --force $(INFODIR)/yap.info*; \
+ if test -e $(DESTDIR)$(INFODIR)/emacs.gz; then \
+ gzip --quiet --force $(DESTDIR)$(INFODIR)/yap.info*; \
fi \
fi; \
- $(INSTALL_INFO) --quiet --section "Programming Languages" yap.info $(INFODIR)/dir; \
+ $(INSTALL_INFO) --quiet --section "Programming Languages" yap.info $(DESTDIR)$(INFODIR)/dir; \
cd ../LGPL/pillow/doc ; \
- $(INSTALL) pillow_doc.info $(INFODIR); \
- if test -e $(INFODIR)/emacs.bz2; then \
- bzip2 --quiet --force $(INFODIR)/pillow_doc.info; \
+ $(INSTALL) pillow_doc.info $(DESTDIR)$(INFODIR); \
+ if test -e $(DESTDIR)$(INFODIR)/emacs.bz2; then \
+ bzip2 --quiet --force $(DESTDIR)$(INFODIR)/pillow_doc.info; \
else \
- if test -e $(INFODIR)/emacs.gz; then \
- gzip --quiet --force $(INFODIR)/pillow_doc.info; \
+
+ if test -e $(DESTDIR)$(INFODIR)/emacs.gz; then \
+ gzip --quiet --force $(DESTDIR)$(INFODIR)/pillow_doc.info; \
fi \
fi; \
$(INSTALL_INFO) --quiet --section "Programming Languages" --entry="`cat pillow_doc.infoindex`" pillow_doc.info $(INFODIR)/dir
+info: yap.info
+
+yap.info: $(srcdir)/docs/yap.tex
+ $(MAKEINFO) $(srcdir)/docs/yap.tex
+
+html: yap.html
+
+yap.html: $(srcdir)/docs/yap.tex
+ $(TEXI2HTML) $(srcdir)/docs/yap.tex
+
+dvi: yap.dvi
+
+yap.dvi: $(srcdir)/docs/yap.tex
+ $(TEXI2DVI) $(srcdir)/docs/yap.tex
+
+ps: yap.ps
+
+yap.ps: $(srcdir)/docs/yap.dvi
+ dvips -o yap.ps $(srcdir)/docs/yap
+
+pdf: yap.pdf
+
+yap.pdf: $(srcdir)/docs/yap.tex
+ $(TEXI2PDF) $(srcdir)/docs/yap.tex
+
+clean_docs:
+ rm -f *.aux *.ca *.cas *.cn *.cns *.cp *.cps *.cy *.cys *.dvi *.fn *.fns *.ky *.log *.sa *.sas *.sn *.sns *.sy *.sys *~ *.tp *.vr *.toc *.pg
+
+realclean_docs: clean_docs
+ rm -f yap.ps yap.html yap_toc.html yap.pdf yap.info*
+
+
# DO NOT DELETE THIS LINE -- make depend depends on it.
diff --git a/changes4.3.html b/changes4.3.html
index cd779dd87..34e912003 100644
--- a/changes4.3.html
+++ b/changes4.3.html
@@ -4,6 +4,25 @@
Changes in YAP4.3
+Yap-4.3.19:
+
+ - FIXED: call_residue should *unify* back constraints *after*
+ restoring original suspension lists.
+
- FIXED: include Mandrake's $(DESTDIR) patches in Makefiles
+ (by Lenny Cartier).
+
- FIXED: close(user_error) now closes stream currently
+ associated with user_error.
+
- FIXED: open(user_*,X,Y) is not special any longer (SICStus compatibility).
+
- FIXED: prolog_flag({max,min}_integer,X) with GMP.
+
- FIXED: prolog_flag(bounded,false) with GMP.
+
- NEW: prolog_flag(user_{input,output,error},X) (request from
+ Nicos Angelopoulos).
+
- FIXED: allow close(file_alias).
+
- FIXED: user_input, user_output and user_error are now
+ aliases, like all the others.
+
- FIXED: restore YapLibDir.
+
+
Yap-4.3.18:
- FIXED: alignment bug with walltime in sparc/solaris.
diff --git a/docs/yap.tex b/docs/yap.tex
index 1f351f782..f21c63a79 100644
--- a/docs/yap.tex
+++ b/docs/yap.tex
@@ -159,6 +159,10 @@ Built In Predicates
* Misc:: Miscellaneous Predicates
+Subnodes of Running
+* Interactive Mode:: Running Yap Interactively
+* Script Mode:: Running Prolog files as scripts
+
Subnodes of Syntax
* Formal Syntax:: Syntax of Terms
* Tokens:: Syntax of Prolog tokens
@@ -374,12 +378,12 @@ We are happy to include in YAP several excellent packages developed
under separate licenses. Our thanks to the authors for their kind
authorisation to include these packages.
-The packages are, in alphabeticall order:
+The packages are, in alphabetical order:
@itemize @bullet
@item The CHR package developed at TUM by
-Ludwig-Maximilians-Universitaet Muenchen (LMU) by Dr.\ Fruehwirth Thom
-and by Dr.\ Christian Holzbaur. The package is distributed under license
+Ludwig-Maximilians-Universitaet Muenchen (LMU) by Dr. Fruehwirth Thom
+and by Dr. Christian Holzbaur. The package is distributed under license
from LMU (Ludwig-Maximilians-University), Munich, Germany:
Permission is granted to copy and distribute modified versions of this
@@ -506,12 +510,16 @@ application, but results in performance loss.
instructions. This is useful when developing YAP, should not be so
useful for normal users.
+ @item @code{--enable-tabling=@{local,batched@}} allows one of the two
+forms of tabling. This option is still experimental.
+
@item @code{--enable-parallelism=@{env-copy,sba,a-cow@}} allows
or-parallelism supported by one of these three forms. This option is
still highly experimental.
- @item @code{--enable-tabling=@{local,batched@}} allows one of the two
-forms of tabling. This option is still experimental.
+ @item @code{--with-gmp[=DIR]} give a path to where one can find the
+@code{GMP} library if not installed in the default path.
+
@end itemize
Next follow machine dependent details:
@@ -594,8 +602,9 @@ YAP_EXTRAS= ... -m486 -DBP_FREE=1
@item Pentium:
@example
-YAP_EXTRAS= ... -m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2
-@end examplef
+YAP_EXTRAS= ... -m486 -malign-loops=2 -malign-jumps=2 \
+ -malign-functions=2
+@end example
@item PentiumPro and other recent Intel and AMD machines:
PentiumPros are known not to require alignment. Check your version of
@@ -615,16 +624,21 @@ Be careful. At least for some versions of @code{GCC}, compiling with
@code{-g} seems to result in broken code.
@item WIN32: The cygwin environment is our suggested approach. The
-CygWin environment is available from the URL
-@code{http://sourceware.cygnus.com} and mirrors. Yap should compile
-under cygwin 20.1 but we suggest using the newer 1.1.1 (April Release),
-which has a more complete implementation of the WIN32 API and uses
-GCC2.95.2 instead of egcs. The compilation steps under the cygwin shell
-are as follows:
+CygWin environment is available from the URL:
+
+
+@code{http://sourceware.cygnus.com}
+
+@noindent
+and mirrors. Yap should compile under cygwin 20.1 but we suggest using
+the newer 1.1.1 (April Release), which has a more complete
+implementation of the WIN32 API and uses GCC2.95.2 instead of egcs. The
+compilation steps under the cygwin shell are as follows:
@example
mkdir cyg
-$YAPSRC/configure --enable-coroutining --enable-max-performance
+$YAPSRC/configure --enable-coroutining \\
+ --enable-max-performance
make
make install
@end example
@@ -635,8 +649,9 @@ need the cygwin dll. It instead accesses the system's @code{CRTDLL.DLL}
@code{C} run time library supplied with Win32 platforms through the
mingw32 interface.
-You can also check the default installation path which is set to
-"/PROGRA~1/Yap" in the Makefile. This corresponds to "c:\Program Files\Yap".
+You should check the default installation path which is set to
+@code{/PROGRA~1/Yap} in the standard Makefile. This string will usually
+be expanded into @code{c:\Program Files\Yap} by Windows.
@end table
@@ -673,10 +688,11 @@ fetch these files from @var{$YAPSRC\VC\include}.
@item You may want to go to @code{Build.Set Active Configuration} and set @code{Project
Type} to @code{Release}
-@item set @code{Project.Project Settings.C/C++.Preprocessor.Additional
-Include Directories} to include the directories @var{$YAPSRC\H}, @var{$YAPSRC\VC\include},
-@var{$YAPSRC\OPTYap} and @var{$YAPSRC\include}.
-The syntax is:
+@item To use Yap's own include directories you have to set the Project
+option @code{Project.Project Settings.C/C++.Preprocessor.Additional
+Include Directories} to include the directories @var{$YAPSRC\H},
+@var{$YAPSRC\VC\include}, @var{$YAPSRC\OPTYap} and
+@var{$YAPSRC\include}. The syntax is:
@example
$YAPSRC\H, $YAPSRC\VC\include, $YAPSRC\OPTYap, $YAPSRC\include
@@ -754,7 +770,8 @@ YAP should compile under the Silicon Graphic's @code{cc} compiler,
although we advise using the GNUCC compiler, if available.
@table @code
-@item 64 bit support should work by using (under Bourne shell syntax):
+@item 64 bit
+Support for 64 bits should work by using (under Bourne shell syntax):
@example
CC="cc -64" $YAP_SRC_PATH/configure --...
@end example
@@ -762,19 +779,27 @@ CC="cc -64" $YAP_SRC_PATH/configure --...
@node Run, Syntax, Install, Top
@chapter Running YAP
-@cindex booting
-The operating system command for invoking YAP is described
-below.
+@menu
+* Interactive Mode:: Running Yap Interactively
+* Script Mode:: Running Prolog files as scripts
+@end menu
-Assuming that YAP is in the user's search path, it can be
-invoked under Unix with the following command:
+@cindex booting
+We next describe how to invoke Yap in Unix systems.
+
+@section Running Yap Interactively
+@node Interactive Mode, Script Mode, ,Running Yap
+
+Most often you will want to use Yap in interactive mode. Assuming that
+YAP is in the user's search path, the top-level can be invoked under
+Unix with the following command:
@example
yap [-s n] [-h n] [-a n] [-c IP_HOST port ] [filename]
@end example
@noindent
-where all the arguments and flags are optional and have the following meaning:
+All the arguments and flags are optional and have the following meaning:
@table @code
@item -?
print a short error message.
@@ -790,8 +815,8 @@ compile the Prolog file @var{YAP_FILE} before entering the top-level.
compile the Prolog file @var{YAP_FILE} and then halt. This option is
useful for implementing scripts.
@item -b @var{BOOT_FILE}
-boot from Prolog @var{BOOT_FILE}. The filename must define the predicate
-'$live'/0.
+boot code is in Prolog file @var{BOOT_FILE}. The filename must define
+the predicate '$live'/0.
@item -c @t{IP_HOST} @t{port}
connect standard streams to host @t{IP_HOST} at port @t{port}
@item filename
@@ -830,12 +855,15 @@ YAP always tries to find saved states from the current directory
first. If it cannot it will use the environment variable YAPLIBDIR, if
defined, or search the default library directory.
-YAP can now be used to run Prolog files as scripts in Unix systems. A
-simple example is shown next:
+@section Running Yap as a script
+@node Script Mode, ,Interactive Mode, Running Yap
+
+YAP can also be used to run Prolog files as scripts, at least in
+Unix-like environments. A simple example is shown next:
@example
@cartouche
-#!yap -L $0 "$@"
+#!/usr/local/bin/yap -L $0 "$@"
#
# Hello World script file using Yap
#
@@ -845,13 +873,33 @@ simple example is shown next:
@end cartouche
@end example
-You should write the first line as shown in the example. The @code{#!}
-characters specify that the Operating System should call @code{yap}. The
-@code{-L} flag indicates that YAP should consult the file "$0" at
-booting and then halt. The remaining arguments are then passed to
-YAP. Note that YAP will skip the first lines if they start with # (the
-comment sign for Unix's shell). YAP will consult the file and
-execute any commands.
+The @code{#!} characters specify that the script should call the binary
+file Yap. Notice that many systems will require the complete path to the
+Yap binary. The @code{-L} flag indicates that YAP should consult the
+file "$0" at booting and then halt. The remaining arguments are then
+passed to YAP. Note that YAP will skip the first lines if they start
+with @code{#} (the comment sign for Unix's shell). YAP will consult the
+file and execute any commands.
+
+A slightly more sophisticated example is:
+
+@example
+@cartouche
+#!/usr/bin/yap -L $0 "$@"
+#
+# Hello World script file using Yap
+#
+
+:- initialization(main).
+
+main :- write('Hello World'), nl.
+
+@end cartouche
+@end example
+
+The @code{initialization} directive tells Yap to execute the goal main
+after consulting the file. Source code is thus compiled and @code{main}
+executed at the end.
@node Syntax, Loading Programs, Run, Top
@chapter Syntax
@@ -1061,8 +1109,10 @@ Strings are described by the following rules:
string --> '"' string_quoted_characters '"'
string_quoted_characters --> '"' '"' string_quoted_characters
- string_quoted_characters --> '\' escape_sequence string_quoted_characters
- string_quoted_characters --> string_character string_quoted_characters
+ string_quoted_characters --> '\'
+ escape_sequence string_quoted_characters
+ string_quoted_characters -->
+ string_character string_quoted_characters
escape_sequence --> 'a' | 'b' | 'r' | 'f' | 't' | 'n' | 'v'
escape_sequence --> '\' | '"' | ''' | '`'
@@ -2173,7 +2223,7 @@ Prolog standard the default action is @code{error}).
After defining @code{undefined/1} by:
@example
-undefined(A) :- write('Undefined predicate: '), write(A), fail.
+undefined(A) :- format('Undefined predicate: ~w~n'), fail.
@end example
@noindent
and executing the goal:
@@ -2398,14 +2448,6 @@ The predicate holds when at least one of the arguments is ground
be unifiable with a number, and the argument @var{L} must be unifiable
with an atom representing the number.
-The ISO-Prolog standard dictates that @code{number_chars/2} should unify
-the second argument with a list of one-char atoms, and not the character
-codes. For compatibility with previous versions of YAP, and
-with other Prolog implementations, YAP unifies the second
-argument with the character codes, as in @code{number_codes/2}. Use the
-@code{set_prolog_flag(to_chars_mode,iso)} to obtain ISO standard
-compatibility.
-
@item char_code(?@var{A},?@var{I}) [ISO]
@findex char_code/2
@syindex char_code/2
@@ -3109,13 +3151,13 @@ one is returned by @code{stream_property/2}
@findex close/1
@syindex close/1
@cyindex close/1
-Closes the stream @var{S}. If @var{S} does not stand for a stream currently
-opened an error is reported. The streams @code{user_input},
+Closes the stream @var{S}. If @var{S} does not stand for a stream
+currently opened an error is reported. The streams @code{user_input},
@code{user_output}, and @code{user_error} can never be closed.
-By default, @code{code/1} will also try to close a stream for a given
-file name. This feature is not available in ISO or SICStus languages
-mode and is deprecated.
+By default, give a file name, @code{close/1} will also try to close a
+corresponding open stream. This feature is not available in ISO or
+SICStus languages mode and is deprecated.
@item close(+@var{S},+@var{O}) [ISO]
@findex close/2
@@ -3517,7 +3559,8 @@ The next argument must be a floating point number. The float @var{F}, the number
As an example:
@example
-?- format("~8e, ~8E, ~8f, ~8g, ~8G~w",[3.14,3.14,3.14,3.14,3.14,3.14]).
+?- format("~8e, ~8E, ~8f, ~8g, ~8G~w",
+ [3.14,3.14,3.14,3.14,3.14,3.14]).
3.140000e+00, 3.140000E+00, 3.140000, 3.14, 3.143.14
@end example
@@ -3577,7 +3620,8 @@ The next argument must be an integer, and @var{N} is interpreted as a
radix, such that @code{2 <= N <= 3} (the default is 8).
@example
-?- format("~2r, 0x~16r, ~r",[150000, 150000, 150000]).
+?- format("~2r, 0x~16r, ~r",
+ [150000, 150000, 150000]).
100100100111110000, 0x249f0, 444760
@end example
@@ -3589,7 +3633,8 @@ Similar to '~NR'. The next argument must be an integer, and @var{N} is
interpreted as a radix, such that @code{2 <= N <= 3} (the default is 8).
@example
-?- format("~2r, 0x~16r, ~r",[150000, 150000, 150000]).
+?- format("~2r, 0x~16r, ~r",
+ [150000, 150000, 150000]).
100100100111110000, 0x249F0, 444760
@end example
@@ -5159,7 +5204,9 @@ simple clock:
@example
loop :- loop.
-ticker :- write('.'), flush_output, get_value(tick, yes), alarm(1,ticker,_).
+ticker :- write('.'), flush_output,
+ get_value(tick, yes),
+ alarm(1,ticker,_).
:- set_value(tick, yes), alarm(1,ticker,_), loop.
@end example
@@ -5176,7 +5223,8 @@ a certain procedure does not take longer than a certain amount of time:
@example
loop :- loop.
-:- alarm(10, throw(ball), _), catch(loop, ball, format('Quota exhausted.~n',[])).
+:- alarm(10, throw(ball), _),
+ catch(loop, ball, format('Quota exhausted.~n',[])).
@end example
In this case after @code{10} seconds our @code{loop} is interrupted,
@code{ball} is thrown, and the handler writes @code{Quota exhausted}.
@@ -5267,12 +5315,14 @@ list_profile :-
findall(D-P,profile_data(P,calls,D),LP),
% sort them
sort(LP,SLP),
- % and output (note the most often called predicates will come last
+ % output so that the most often called
+ % predicates will come last:
write_profile_data(SLP).
write_profile_data([]).
write_profile_data([D-P|SLP]) :-
- % just swap the two calls to get most often called predicates first.
+ % swap the two calls if you want the most often
+ % called predicates first.
format('~w: ~w~n', [P,D]),
write_profile_data(SLP).
@end example
@@ -5509,7 +5559,8 @@ Stack space : 1523712
90 msec. for 5 heap overflows.
90 msec. for 3 stack overflows.
0 msec. for 0 trail overflows.
-800 msec. for 3 garbage collections which collected 208348 bytes.
+800 msec. for 3 garbage collections which
+ collected 208348 bytes.
Runtime : 23.07 sec.
@end example
@@ -5596,13 +5647,6 @@ Space in kbytes currently being used and still available for the trail.
@*
This gives the clock time in milliseconds since starting Prolog.
-@item write_strings
-@findex write_strings (yap_flag/2 option)
-@* Writable flag telling whether the system should write lists of
-integers that are writable character codes using the list notation. It
-is @code{on} if enables or @code{off} if disabled. The default value for
-this flag is @code{off}.
-
@end table
@item yap_flag(?@var{Param},?@var{Value})
@@ -5616,8 +5660,8 @@ Set or read system properties for @var{Param}:
@item bounded [ISO]
@findex bounded (yap_flag/2 option)
@*
-Read-only flag telling whether integers are bounded. Takes the value
-@code{true} for the current version of YAP.
+Read-only flag telling whether integers are bounded. The value depends
+on whether YAP uses the GMP library or not.
@item char_conversion [ISO]
@findex char_conversion (yap_flag/2 option)
@@ -5718,13 +5762,17 @@ Read-only flag telling the maximum arity of a functor. Takes the value
@findex max_integer (yap_flag/2 option)
@*
Read-only flag telling the maximum integer in the
-implementation. Depends on machine and Operating System architecture.
+implementation. Depends on machine and Operating System
+architecture, and on whether YAP uses the @code{GMP} multiprecision
+library. If @code{bounded} is false, requestes for @code{max_integer}
+will fail.
@item min_integer [ISO]
@findex min_integer (yap_flag/2 option)
-@*
-Read-only flag telling the minimum integer in the
-implementation. Depends on machine and Operating System architecture.
+@* Read-only flag telling the minimum integer in the
+implementation. Depends on machine and Operating System architecture,
+and on whether YAP uses the @code{GMP} multiprecision library. If
+@code{bounded} is false, requestes for @code{min_integer} will fail.
@item n_of_integer_keys_in_bb
@findex n_of_integer_keys_in_bb (yap_flag/2 option)
@@ -5848,6 +5896,64 @@ also an intermediate mode, @code{logical_assert}, where dynamic
procedures follow logical semantics but the internal data base still
follows immediate semantics.
+@item user_error
+@findex user_error (yap_flag/2 option)
+@*
+If the second argument is bound to a stream, set @code{user_error} to
+this stream. If the second argument is unbound, unify the argument with
+the current @code{user_error} stream.
+
+By default, the @code{user_error} stream is set to a stream
+corresponding to the Unix @code{stderr} stream.
+
+The next example shows how to use this flag:
+@example
+ ?- open( '/dev/null', append, Error,
+ [alias(mauri_tripa)] ).
+
+Error = '$stream'(3) ? ;
+
+no
+ ?- set_prolog_flag(user_error, mauri_tripa).
+
+close(mauri_tripa).
+
+yes
+ ?-
+@end example
+We first opened a stream in write mode and gave it an alias. Next, we
+set @code{user_error} to the stream via the alias. Note that after we
+did so prompts from the system were redirected to the stream
+@code{mauri_tripa}. Last, when we closed the stream we automatically
+redirect the @code{user_error} alias to the original @code{stderr}.
+
+@item user_input
+@findex user_input (yap_flag/2 option)
+@*
+If the second argument is bound to a stream, set @code{user_input} to
+this stream. If the second argument is unbound, unify the argument with
+the current @code{user_input} stream.
+
+By default, the @code{user_input} stream is set to a stream
+corresponding to the Unix @code{stdin} stream.
+
+@item user_output
+@findex user_output (yap_flag/2 option)
+@*
+If the second argument is bound to a stream, set @code{user_output} to
+this stream. If the second argument is unbound, unify the argument with
+the current @code{user_output} stream.
+
+By default, the @code{user_output} stream is set to a stream
+corresponding to the Unix @code{stdout} stream.
+
+@item write_strings
+@findex write_strings (yap_flag/2 option)
+@* Writable flag telling whether the system should write lists of
+integers that are writable character codes using the list notation. It
+is @code{on} if enables or @code{off} if disabled. The default value for
+this flag is @code{off}.
+
@end table
@item current_prolog_flag(?@var{Flag},-@var{Value}) [ISO]
@@ -7178,7 +7284,7 @@ s-representation. Note that the vertices without edges will appear in
@var{Vertices} but not in @var{Edges}. Moreover, it is sufficient for a
vertice to appear in @var{Edges}.
@example
- ?- vertices_edges_to_ugraph([],[1-3,2-4,4-5,1-5],L).
+?- vertices_edges_to_ugraph([],[1-3,2-4,4-5,1-5],L).
L = [1-[3,5],2-[4],3-[],4-[5],5-[]] ?
@@ -7186,7 +7292,7 @@ L = [1-[3,5],2-[4],3-[],4-[5],5-[]] ?
In this case all edges are defined implicitly. The next example shows
three unconnected edges:
@example
- ?- vertices_edges_to_ugraph([6,7,8],[1-3,2-4,4-5,1-5],L).
+?- vertices_edges_to_ugraph([6,7,8],[1-3,2-4,4-5,1-5],L).
L = [1-[3,5],2-[4],3-[],4-[5],5-[],6-[],7-[],8-[]] ?
@@ -7199,7 +7305,7 @@ L = [1-[3,5],2-[4],3-[],4-[5],5-[],6-[],7-[],8-[]] ?
Unify @var{Vertices} with all vertices appearing in graph
@var{Graph}. In the next example:
@example
- ?- vertices([1-[3,5],2-[4],3-[],4-[5],5-[]], V).
+?- vertices([1-[3,5],2-[4],3-[],4-[5],5-[]], V).
L = [1,2,3,4,5]
@end example
@@ -7211,7 +7317,7 @@ L = [1,2,3,4,5]
Unify @var{Edges} with all edges appearing in graph
@var{Graph}. In the next example:
@example
- ?- vertices([1-[3,5],2-[4],3-[],4-[5],5-[]], V).
+?- vertices([1-[3,5],2-[4],3-[],4-[5],5-[]], V).
L = [1,2,3,4,5]
@end example
@@ -7223,9 +7329,12 @@ L = [1,2,3,4,5]
Unify @var{NewGraph} with a new graph obtained by adding the list of
vertices @var{Vertices} to the graph @var{Graph}. In the next example:
@example
- ?- add_vertices([0,2,9,10,11],[1-[3,5],2-[4],3-[],4-[5],5-[],6-[],7-[],8-[]],NG).
+?- add_vertices([0,2,9,10,11],
+ [1-[3,5],2-[4],3-[],4-[5],
+ 5-[],6-[],7-[],8-[]], NG).
-NG = [0-[],1-[3,5],2-[4],3-[],4-[5],5-[],6-[],7-[],8-[],9-[],10-[],11-[]]
+NG = [0-[],1-[3,5],2-[4],3-[],4-[5],5-[],
+ 6-[],7-[],8-[],9-[],10-[],11-[]]
@end example
@item del_vertices(+@var{Vertices}, +@var{Graph}, -@var{NewGraph})
@@ -7236,7 +7345,8 @@ Unify @var{NewGraph} with a new graph obtained by deleting the list of
vertices @var{Vertices} and all the edges that start from or go to a
vertex in @var{Vertices} to the graph @var{Graph}. In the next example:
@example
- ?- del_vertices([2,1],[1-[3,5],2-[4],3-[],4-[5],5-[],6-[],7-[2,6],8-[]],NL).
+?- del_vertices([2,1],[1-[3,5],2-[4],3-[],
+ 4-[5],5-[],6-[],7-[2,6],8-[]],NL).
NL = [3-[],4-[5],5-[],6-[],7-[6],8-[]]
@end example
@@ -7248,7 +7358,8 @@ NL = [3-[],4-[5],5-[],6-[],7-[6],8-[]]
Unify @var{NewGraph} with a new graph obtained by adding the list of
edges @var{Edges} to the graph @var{Graph}. In the next example:
@example
- ?- add_edges([1-[3,5],2-[4],3-[],4-[5],5-[],6-[],7-[],8-[]],[1-6,2-3,3-2,5-7,3-2,4-5],NL).
+?- add_edges([1-[3,5],2-[4],3-[],4-[5],5-[],6-[],
+ 7-[],8-[]],[1-6,2-3,3-2,5-7,3-2,4-5],NL).
NL = [1-[3,5,6],2-[3,4],3-[2],4-[5],5-[7],6-[],7-[],8-[]]
@end example
@@ -7261,7 +7372,9 @@ Unify @var{NewGraph} with a new graph obtained by removing the list of
edges @var{Edges} from the graph @var{Graph}. Notice that no vertices
are deleted. In the next example:
@example
- ?- del_edges([1-[3,5],2-[4],3-[],4-[5],5-[],6-[],7-[],8-[]],[1-6,2-3,3-2,5-7,3-2,4-5,1-3],NL).
+?- del_edges([1-[3,5],2-[4],3-[],4-[5],5-[],
+ 6-[],7-[],8-[]],
+ [1-6,2-3,3-2,5-7,3-2,4-5,1-3],NL).
NL = [1-[5],2-[4],3-[],4-[],5-[],6-[],7-[],8-[]]
@end example
@@ -7274,7 +7387,8 @@ Unify @var{NewGraph} with a new graph obtained from @var{Graph} by
replacing all edges of the form @var{V1-V2} by edges of the form
@var{V2-V1}. The cost is @code{O(|V|^2)}. In the next example:
@example
- ?- transpose([1-[3,5],2-[4],3-[],4-[5],5-[],6-[],7-[],8-[]],NL).
+?- transpose([1-[3,5],2-[4],3-[],
+ 4-[5],5-[],6-[],7-[],8-[]], NL).
NL = [1-[],2-[],3-[1],4-[2],5-[1,4],6-[],7-[],8-[]]
@end example
@@ -7288,7 +7402,9 @@ Unify @var{Vertices} with the list of neighbors of vertex @var{Vertex}
in @var{Graph}. If the vertice is not in the graph fail. In the next
example:
@example
- ?- neighbors(4,[1-[3,5],2-[4],3-[],4-[1,2,7,5],5-[],6-[],7-[],8-[]],NL).
+?- neighbors(4,[1-[3,5],2-[4],3-[],
+ 4-[1,2,7,5],5-[],6-[],7-[],8-[]],
+ NL).
NL = [1,2,7,5]
@end example
@@ -7300,7 +7416,8 @@ NL = [1,2,7,5]
Unify @var{Vertices} with the list of neighbours of vertex @var{Vertex}
in @var{Graph}. In the next example:
@example
- ?- neighbours(4,[1-[3,5],2-[4],3-[],4-[1,2,7,5],5-[],6-[],7-[],8-[]],NL).
+?- neighbours(4,[1-[3,5],2-[4],3-[],
+ 4-[1,2,7,5],5-[],6-[],7-[],8-[]], NL).
NL = [1,2,7,5]
@end example
@@ -7312,9 +7429,12 @@ NL = [1,2,7,5]
Unify @var{NewGraph} with the graph complementar to @var{Graph}.
In the next example:
@example
- ?- complement([1-[3,5],2-[4],3-[],4-[1,2,7,5],5-[],6-[],7-[],8-[]],NL).
+?- complement([1-[3,5],2-[4],3-[],
+ 4-[1,2,7,5],5-[],6-[],7-[],8-[]], NL).
-NL = [1-[2,4,6,7,8],2-[1,3,5,6,7,8],3-[1,2,4,5,6,7,8],4-[3,5,6,8],5-[1,2,3,4,6,7,8],6-[1,2,3,4,5,7,8],7-[1,2,3,4,5,6,8],8-[1,2,3,4,5,6,7]]
+NL = [1-[2,4,6,7,8],2-[1,3,5,6,7,8],3-[1,2,4,5,6,7,8],
+ 4-[3,5,6,8],5-[1,2,3,4,6,7,8],6-[1,2,3,4,5,7,8],
+ 7-[1,2,3,4,5,6,8],8-[1,2,3,4,5,6,7]]
@end example
@item compose(+@var{LeftGraph}, +@var{RightGraph}, -@var{NewGraph})
@@ -7324,7 +7444,7 @@ NL = [1-[2,4,6,7,8],2-[1,3,5,6,7,8],3-[1,2,4,5,6,7,8],4-[3,5,6,8],5-[1,2,3,4,6,7
Compose the graphs @var{LeftGraph} and @var{RightGraph} to form @var{NewGraph}.
In the next example:
@example
- ?- compose([1-[2],2-[3]],[2-[4],3-[1,2,4]],L).
+?- compose([1-[2],2-[3]],[2-[4],3-[1,2,4]],L).
L = [1-[4],2-[1,2,4],3-[]]
@end example
@@ -7337,7 +7457,7 @@ Generate the set of nodes @var{Sort} as a topological sorting of graph
@var{Graph}, if one is possible.
In the next example we show how topological sorting works for a linear graph:
@example
- ?- top_sort([_138-[_219],_219-[_139], _139-[]],L).
+?- top_sort([_138-[_219],_219-[_139], _139-[]],L).
L = [_138,_219,_139]
@end example
@@ -7350,7 +7470,7 @@ Generate the graph @var{Closure} as the transitive closure of graph
@var{Graph}.
In the next example:
@example
- ?- transitive_closure([1-[2,3],2-[4,5],4-[6]],L).
+?- transitive_closure([1-[2,3],2-[4,5],4-[6]],L).
L = [1-[2,3,4,5,6],2-[4,5,6],4-[6]]
@end example
@@ -7365,9 +7485,10 @@ default, but that can be used to extend the functionality of the
system. These options can be set at compilation time by enabling the
related compilation flag, as explained in the @code{Makefile}
-Extensions to Traditional Prolog
@menu
+Extensions to Traditional Prolog
+
* Rational Trees:: Working with Rational Trees
* Coroutining:: Changing the Execution of Goals
* Attributed Variables:: Using attributed Variables
@@ -7488,19 +7609,16 @@ where @code{dif/2} suspends twice, once outside @code{call_residue/2},
and the other inside:
@example
- ?- dif(X,Y), call_residue((dif(X,Y),(X = f(Z) ; Y = f(Z))), L).
+?- dif(X,Y),
+ call_residue((dif(X,Y),(X = f(Z) ; Y = f(Z))), L).
-X = f(_24)
-Y = _92
-Z = _24
-L = [[_92]-dif(f(_24),_92)]
-dif(f(_24),_92) ;
+X = f(Z),
+L = [[Y]-dif(f(Z),Y)],
+dif(f(Z),Y) ? ;
-X = _86
-Y = f(_24)
-Z = _24
-L = [[_86]-dif(_86,f(_24))]
-dif(_86,f(_24)) ;
+Y = f(Z),
+L = [[X]-dif(X,f(Z))],
+dif(X,f(Z)) ? ;
no
@end example
@@ -8050,34 +8168,37 @@ checked for satisfiability. If you want to overload @{@}/1 with other
solvers, you can avoid its importation via: @code{use_module(clpq, [])}.
@example
-@var{Constraint} --> @var{C}
- | @var{C} , @var{C} conjunction
+@var{Constraint} --> @var{C}
+ | @var{C} , @var{C} conjunction
-@var{C} --> @var{Expr} =:= @var{Expr} equation
- | @var{Expr} = @var{Expr} equation
- | @var{Expr} < @var{Expr} strict inequation
- | @var{Expr} > @var{Expr} strict inequation
- | @var{Expr} =< @var{Expr} nonstrict inequation
- | @var{Expr} >= @var{Expr} nonstrict inequation
- | @var{Expr} =\= @var{Expr} disequation
+@var{C} --> @var{Expr} =:= @var{Expr} equation
+ | @var{Expr} = @var{Expr} equation
+ | @var{Expr} < @var{Expr} strict inequation
+ | @var{Expr} > @var{Expr} strict inequation
+ | @var{Expr} =< @var{Expr} nonstrict inequation
+ | @var{Expr} >= @var{Expr} nonstrict inequation
+ | @var{Expr} =\= @var{Expr} disequation
-@var{Expr} --> variable Prolog variable
- | number floating point or integer
- | + @var{Expr} unary plus
- | - @var{Expr} unary minus
- | @var{Expr} + @var{Expr} addition
- | @var{Expr} - @var{Expr} subtraction
- | @var{Expr} * @var{Expr} multiplication
- | @var{Expr} / @var{Expr} division
- | abs(@var{Expr}) absolute value
- | sin(@var{Expr}) trigonometric sine
- | cos(@var{Expr}) trigonometric cosine
- | tan(@var{Expr}) trigonometric tangent
- | pow(@var{Expr},@var{Expr}) raise to the power
- | exp(@var{Expr},@var{Expr}) raise to the power
- | min(@var{Expr},@var{Expr}) minimum of the two arguments
- | max(@var{Expr},@var{Expr}) maximum of the two arguments
- | #(Const) symbolic numerical constants
+@var{Expr} --> variable Prolog variable
+ | number floating point or integer
+ | + @var{Expr} unary plus
+ | - @var{Expr} unary minus
+ | @var{Expr} + @var{Expr} addition
+ | @var{Expr} - @var{Expr} subtraction
+ | @var{Expr} * @var{Expr} multiplication
+ | @var{Expr} / @var{Expr} division
+ | abs(@var{Expr}) absolute value
+ | sin(@var{Expr}) trigonometric sine
+ | cos(@var{Expr}) trigonometric cosine
+ | tan(@var{Expr}) trigonometric tangent
+ | pow(@var{Expr},@var{Expr}) raise to the power
+ | exp(@var{Expr},@var{Expr}) raise to the power
+ | min(@var{Expr},@var{Expr}) minimum of the two
+ arguments
+ | max(@var{Expr},@var{Expr}) maximum of the two
+ arguments
+ | #(Const) symbolic numerical
+ constant
@end example
Conjunctive constraints @t{@{-C,C@}} have been made part of the syntax
@@ -9578,7 +9699,8 @@ Id --> a unique variable
Guard --> Ask | Ask & Tell
Ask --> Goal
Tell --> Goal
-Goal --> a callable term, including conjunction and disjunction etc.
+Goal --> a callable term,
+ including conjunction and disjunction etc.
Body --> Goal
@@ -9709,9 +9831,12 @@ constraints in the simplification rule @code{antisymmetry}, thus it is
automatically declared passive and the compiler outputs @code{CHR
eliminated code for head 2 in antisymmetry}.
@example
-antisymmetry @ X leq Y , Y leq X # Id <=> X=Y pragma passive(Id).
-idempotence @ X leq Y # Id \ X leq Y <=> true pragma passive(Id).
-transitivity @ X leq Y # Id , Y leq Z ==> X leq Z pragma passive(Id).
+antisymmetry @ X leq Y, Y leq X # Id <=> X=Y
+ pragma passive(Id).
+idempotence @ X leq Y # Id \ X leq Y <=> true
+ pragma passive(Id).
+transitivity @ X leq Y # Id, Y leq Z ==> X leq Z
+ pragma passive(Id).
@end example
Declaring the first head of rule @code{transitivity} passive changes the
behavior of the handler. It will propagate less depending on the order in
@@ -10279,7 +10404,7 @@ stream. This allows you to trace programs while they are performing
file I/O. The basic format is as follows:
@example
-@var{S} 3 1 try eratosthenes:absorb(10) @@ prime(9)#, prime(10)# ?
+@var{S} 3 1 try eratosthenes:absorb(10) @@ prime(9)#, prime(10)# ?
@end example
@noindent
@@ -10429,7 +10554,7 @@ rule, if it exists.
@dfn{show rule}
prints the current rule instantiated by the matched constraints. Example:
@example
- 8 1 apply era:absorb(8) @@ prime(4)# \ prime(8)# ? .
+ 8 1 apply era:absorb(8) @@ prime(4)# \ prime(8)# ? .
absorb(8) @@
prime(4)# \
@@ -10705,12 +10830,11 @@ and pragmas @ref{CHR Pragmas}
offering better grained control.
@item
-The Eclipse library of CHR provided automatic built-in labeling
-through the @code{label_with} declaration. Since it was not widely used
-and can be easily simulated, built-in labeling was dropped.
-The same effect can be achieved
-by replacing the declaration @code{label_with Constraint
-if Guard} by the simplification rule @code{chr_labeling, Constraint <=>
+The Eclipse library of CHR provided automatic built-in labeling through
+the @code{label_with} declaration. Since it was not widely used and can
+be easily simulated, built-in labeling was dropped. The same effect can
+be achieved by replacing the declaration @code{label_with Constraint if
+Guard} by the simplification rule @code{chr_labeling, Constraint <=>
Guard | Constraint', chr_labeling} and by renaming the head in each
clause @code{Constraint :- Body} into @code{Constraint' :- Body} where
@code{Constraint'} is a new predicate. Efficiency can be improved by
@@ -11525,7 +11649,7 @@ a non-zero value if the unification succeeds and zero otherwise.
The YAP C-interface now includes an utility routine to copy a string
represented as a list of a character codes to a previously allocated buffer
@example
- int StringToBuffer(Term String, char *buf, unsigned int bufsize)
+ int StringToBuffer(Term String, char *buf, unsigned int bufsize)
@end example
@noindent
The routine copies the list of character codes @code{String} to a
@@ -11634,8 +11758,11 @@ static int start_n100()
n100_data->next_solution = MkIntTerm(0);
return(continue_n100());
@}
- if(!IsIntTerm(t) || IntOfTerm(t)<0 || IntOfTerm(t)>100) cut_fail();
- else cut_succeed();
+ if(!IsIntTerm(t) || IntOfTerm(t)<0 || IntOfTerm(t)>100) {
+ cut_fail();
+ } else {
+ cut_succeed();
+ }
@}
@end example
@@ -11888,11 +12015,11 @@ Initialise a copy of YAP from @var{SavedState}. The copy is
monolithic and currently must be loaded at the same address where it was
saved. @code{YapFastInit} is a simpler version of @code{YapInit}.
-@item YapInit(@code{char *} @var{SavedState},@code{int}
-@var{HeapSize},@code{int} @var{StackSize}, @code{int}
-@var{TrailSize},@code{int} @var{NumberofWorkers},@code{int}
-@var{SchedulerLoop}, @code{int} @var{DelayedReleaseLoad},@code{int}
-@var{argc},@code{char **} @var{argv})
+@item YapInit(@code{char *} @var{SavedState}, @code{int}
+@var{HeapSize}, @code{int} @var{StackSize}, @code{int}
+@var{TrailSize}, @code{int} @var{NumberofWorkers}, @code{int}
+@var{SchedulerLoop}, @code{int} @var{DelayedReleaseLoad}, @code{int}
+@var{argc}, @code{char **} @var{argv})
@findex YapInit/9
Initialise YAP. In the future the arguments as a single @code{C}
structure.
@@ -12154,7 +12281,7 @@ not available in YAP.
@item YAP implements escape sequences as in the ISO standard. SICStus
Prolog implements Unix-like escape sequences.
-@item YAP implements initialization/1 as in the ISO
+@item YAP implements @code{initialization/1} as per the ISO
standard. Use @code{prolog_initialization/1} for the SICStus Prolog
compatible built-in.
@@ -12169,10 +12296,8 @@ compatible built-in.
@item The following SICStus Prolog v3 built-ins are not (currently)
implemented in YAP (note that this is only a partial list):
-@code{call_cleanup/1},
-@code{file_search_path/2}, @code{stream_interrupt/3},
-@code{print_message/2},
-@code{portray_message/2}, @code{reinitialize/0}, @code{help/0},
+@code{call_cleanup/1}, @code{file_search_path/2},
+@code{stream_interrupt/3}, @code{reinitialize/0}, @code{help/0},
@code{help/1}, @code{module/3}, @code{trimcore/0}.
The previous list is incomplete. We also cannot guarantee full
@@ -12412,7 +12537,8 @@ The following is the list of the declarations of the predefined operators:
@example
:-op(1200,fx,['?-', ':-']).
:-op(1200,xfx,[':-','-->']).
-:-op(1150,fx,[block,dynamic,mode,public,multifile,meta_predicate,sequential,table,initialization]).
+:-op(1150,fx,[block,dynamic,mode,public,multifile,meta_predicate,
+ sequential,table,initialization]).
:-op(1100,xfy,[';','|']).
:-op(1050,xfy,->).
:-op(1000,xfy,',').
diff --git a/library/regex/Makefile.in b/library/regex/Makefile.in
index d774f70c8..6fbfd5f93 100644
--- a/library/regex/Makefile.in
+++ b/library/regex/Makefile.in
@@ -102,7 +102,7 @@ regexp.dll: $(OBJS)
$(LD) $(EXP_FILE) --dll -o $(DLLNAME) $(OBJS) $(DLL_LIBS) -e $(ENTRY_FUNCTION)
install: all
- $(INSTALL_PROGRAM) $(SOBJS) $(LIBDIR)
+ $(INSTALL_PROGRAM) $(SOBJS) $(DESTDIR)$(LIBDIR)
install_mingw32: dll
$(INSTALL_PROGRAM) -m 755 regexp.dll $(LIBDIR)/regexp.dll
diff --git a/m4/Yap.h.m4 b/m4/Yap.h.m4
index ceb491044..4d5e12ee4 100644
--- a/m4/Yap.h.m4
+++ b/m4/Yap.h.m4
@@ -10,7 +10,7 @@
* File: Yap.h.m4 *
* mods: *
* comments: main header file for YAP *
-* version: $Id: Yap.h.m4,v 1.1.1.1 2001-04-09 19:53:46 vsc Exp $ *
+* version: $Id: Yap.h.m4,v 1.2 2001-04-16 16:41:04 vsc Exp $ *
*************************************************************************/
#include "config.h"
@@ -405,6 +405,7 @@ typedef enum {
EXISTENCE_ERROR_STREAM,
INSTANTIATION_ERROR,
PERMISSION_ERROR_ACCESS_PRIVATE_PROCEDURE,
+ PERMISSION_ERROR_NEW_ALIAS_FOR_STREAM,
PERMISSION_ERROR_CREATE_ARRAY,
PERMISSION_ERROR_CREATE_OPERATOR,
PERMISSION_ERROR_INPUT_BINARY_STREAM,
diff --git a/pl/boot.yap b/pl/boot.yap
index ddd201849..4bc886877 100644
--- a/pl/boot.yap
+++ b/pl/boot.yap
@@ -21,14 +21,6 @@
%
true :- true. % otherwise, $$compile will ignore this clause.
-% proccess an input clause
-'$$c'(G,G0,L) :-
- '$head_and_body'(G,H,_),
- '$inform_of_clause'(H,L),
- '$flags'(H, Fl, Fl),
- ( Fl /\ 16'002008 =\= 0 -> '$assertz_dynamic'(L,G,G0) ;
- '$$compile_stat'(G,G0,L,H) ).
-
'$live' :-
'$init_system',
repeat,
@@ -92,32 +84,11 @@ open(Source,M,T) :- var(M), !,
throw(error(instantiation_error,open(Source,M,T))).
open(Source,M,T) :- nonvar(T), !,
throw(error(type_error(variable,T),open(Source,M,T))).
-open(user,read,'$stream'(0)) :- !.
-open(user,'$csult','$stream'(0)) :- !.
-open(user,_,'$stream'(1)) :- !.
-open(user_input,read,'$stream'(0)) :- !.
-open(user_input,'$csult','$stream'(0)) :- !.
-open(user_input,append,'$stream'(0)) :- !.
-open(user_input,write,V) :- !,
- '$get_value'(fileerrors,1),
- throw(error(permission_error(open,source_sink,user_input),open(user_input,write,V))).
-open(user_output,write,'$stream'(1)) :- !.
-open(user_output,append,'$stream'(1)) :- !.
-open(user_output,read,'$stream'(1)) :-
- '$get_value'(fileerrors,1),
- throw(error(permission_error(open,source_sink,user_input),open(user_input,write,'$stream'(1)))).
open(File,Mode,Stream) :-
'$open'(File,Mode,Stream,0).
close(V) :- var(V), !,
throw(error(instantiation_error,close(V))).
-close(user) :- !.
-close(user_input) :- !.
-close(user_output) :- !.
-close(user_error) :- !.
-close('$stream'(0)) :- !.
-close('$stream'(1)) :- !.
-close('$stream'(2)) :- !.
close(File) :-
atom(File), !,
(
@@ -125,9 +96,9 @@ close(File) :-
current_stream(_,_,Stream),
'$user_file_name'(Stream,File)
->
- close(Stream)
+ '$close'(Stream)
;
- throw(error(domain_error(stream,File),close(File)))
+ '$close'(File)
).
close(Stream) :-
'$close'(Stream).
@@ -984,7 +955,7 @@ break :- '$get_value'('$break',BL), NBL is BL+1,
'$loop'(Stream,Status) :-
'$current_module'(OldModule),
- '$add_alias_to_stream'('$loop_stream',Stream),
+ '$change_alias_to_stream'('$loop_stream',Stream),
repeat,
( current_stream(_,_,Stream) -> true
; '$current_module'(_,OldModule), '$abort_loop'(Stream)
@@ -1035,8 +1006,8 @@ break :- '$get_value'('$break',BL), NBL is BL+1,
'$set_value'(fileerrors,V), fail).
-'$find_in_path'(user,user) :- !.
-'$find_in_path'(user_input,user) :- !.
+'$find_in_path'(user,user_input) :- !.
+'$find_in_path'(user_input,user_input) :- !.
'$find_in_path'(library(File),NewFile) :- !,
'$find_library_in_path'(File, NewFile).
'$find_in_path'(File,File) :- '$exists'(File,'$csult'), !.
diff --git a/pl/corout.yap b/pl/corout.yap
index ad8f5957f..5ca536f0e 100644
--- a/pl/corout.yap
+++ b/pl/corout.yap
@@ -540,8 +540,12 @@ call_residue(Goal,Residue) :-
'$set_svar_list'(CurrentList, CurrentAttsList),
'$execute'(NGoal),
'$call_residue_continuation'(NGoal,NResidue),
- '$copy_term_but_not_constraints'(NGoal+NResidue,Goal+Residue),
- ( '$set_svar_list'(OldList,OldAttsList) ; '$set_svar_list'(CurrentList,CurrentAttsList), fail )
+ ( '$set_svar_list'(OldList,OldAttsList),
+ Goal = NGoal,
+ Residue = NResidue
+ ;
+ '$set_svar_list'(CurrentList,CurrentAttsList), fail
+ )
;
'$set_svar_list'(OldList,OldAttsList), fail
).
diff --git a/pl/directives.yap b/pl/directives.yap
index 52ae6e660..16f8f0d00 100644
--- a/pl/directives.yap
+++ b/pl/directives.yap
@@ -194,6 +194,7 @@ yap_flag(max_arity,X) :-
yap_flag(max_integer,X) :-
var(X), !,
+ '$access_yap_flags'(0, 1),
'$access_yap_flags'(3, X).
yap_flag(max_integer,X) :-
integer(X), X > 0, !,
@@ -203,6 +204,7 @@ yap_flag(max_integer,X) :-
yap_flag(min_integer,X) :-
var(X), !,
+ '$access_yap_flags'(0, 1),
'$access_yap_flags'(4, X).
yap_flag(min_integer,X) :-
integer(X), X < 0, !,
@@ -443,6 +445,26 @@ yap_flag(write_strings,off) :- !,
yap_flag(write_strings,X) :-
throw(error(domain_error(flag_value,write_strings+X),yap_flag(write_strings,X))).
+yap_flag(user_input,OUT) :-
+ var(OUT), !,
+ current_stream(user_input,_,OUT).
+yap_flag(user_input,Stream) :-
+ '$change_alias_to_stream'(user_input,Stream).
+
+
+yap_flag(user_output,OUT) :-
+ var(OUT), !,
+ current_stream(user_output,_,OUT).
+yap_flag(user_output,Stream) :-
+ '$change_alias_to_stream'(user_output,Stream).
+
+
+yap_flag(user_error,OUT) :-
+ var(OUT), !,
+ current_stream(user_error,_,OUT).
+yap_flag(user_error,Stream) :-
+ '$change_alias_to_stream'(user_error,Stream).
+
yap_flag(debugger_print_options,OUT) :-
var(OUT),
'$recorded'('$print_options','$debugger'(OUT),_), !.
@@ -521,7 +543,11 @@ yap_flag(host_type,X) :-
V = toplevel_print_options ;
V = typein_module ;
V = unknown ;
- V = update_semantics
+ V = update_semantics ;
+ V = user_error ;
+ V = user_input ;
+ V = user_output ;
+ V = write_strings
),
yap_flag(V, Out).
diff --git a/pl/errors.yap b/pl/errors.yap
index ed22f2c61..4267302d5 100644
--- a/pl/errors.yap
+++ b/pl/errors.yap
@@ -212,6 +212,9 @@ print_message(help,M) :-
'$output_error_message'(permission_error(access,static_procedure,P), Where) :-
format(user_error,"[ PERMISSION ERROR- ~w: cannot access static procedure ~w ]~n",
[Where,P]).
+'$output_error_message'(permission_error(alias,new,P), Where) :-
+ format(user_error,"[ PERMISSION ERROR- ~w: cannot create alias ~w ]~n",
+ [Where,P]).
'$output_error_message'(permission_error(create,array,P), Where) :-
format(user_error,"[ PERMISSION ERROR- ~w: cannot create array ~w ]~n",
[Where,P]).
diff --git a/pl/yio.yap b/pl/yio.yap
index 9b725abf7..a7135e8e9 100644
--- a/pl/yio.yap
+++ b/pl/yio.yap
@@ -34,12 +34,6 @@ open(F,T,S,Opts) :-
throw(error(instantiation_error,open(Source,M,T,N))).
'$open2'(Source,M,T,N) :- nonvar(T), !,
throw(error(type_error(variable,T),open(Source,M,T,N))).
-'$open2'(user,read,'$stream'(0),_) :- !.
-'$open2'(user,'$csult','$stream'(0),_) :- !.
-'$open2'(user,_,'$stream'(1),_) :- !.
-'$open2'(user_input,read,'$stream'(0),_) :- !.
-'$open2'(user_input,'$csult','$stream'(0),_) :- !.
-'$open2'(user_output,_,'$stream'(1),_) :- !.
'$open2'(File,Mode,Stream,N) :-
'$open'(File,Mode,Stream,N).
@@ -175,7 +169,7 @@ open(F,T,S,Opts) :-
'$check_open_alias_arg'(X, G) :- var(X), !,
throw(error(instantiation_error,G)).
'$check_open_alias_arg'(X,G) :- atom(X), !,
- ( '$check_if_valid_new_alias'(X), X \= user, X\= user_input, X\=user_output, X\= user_error ->
+ ( '$check_if_valid_new_alias'(X), X \= user ->
true ;
throw(error(permission_error(open, source_sink, alias(X)),G))
).
@@ -260,7 +254,7 @@ see(F) :- open(F,read,Stream), set_input(Stream).
seeing(File) :- current_input(Stream),
'$user_file_name'(Stream,NFile),
- ( NFile = user_input -> File = user ; NFile = File).
+ ( '$user_file_name'(user_input,NFile) -> File = user ; NFile = File).
seen :- current_input(Stream), close(Stream), set_input(user).
@@ -277,7 +271,7 @@ tell(F) :- open(F,write,Stream), set_output(Stream).
telling(File) :- current_output(Stream),
'$user_file_name'(Stream,NFile),
- ( NFile = user_output -> File = user ; File = NFile ).
+ ( '$user_file_name'(user_output,NFile) -> File = user ; File = NFile ).
told :- current_output(Stream), close(Stream), set_output(user).
@@ -814,8 +808,6 @@ at_end_of_stream(S) :-
consult_depth(LV) :- '$show_consult_level'(LV).
-absolute_file_name(user,user) :- !.
-absolute_file_name(user_input,user_input) :- !.
absolute_file_name(RelFile,AbsFile) :-
'$find_in_path'(RelFile,PathFile),
'$exists'(PathFile,'$csult', AbsFile).