PLOGHELP PROLOG_LANGUAGE                   Jonathan Laventhol, June 1983
                                 Revised by Kathryn Seifert, August 1986


Predicates and library package for switching from Prolog to POP-11

    ?- prolog_language(<string>
    ?- prolog_current_language(<prologvar>)

Keywords: Prolog, POP-11, mixed language programming, languages


         CONTENTS - (Use <ENTER> g to access required sections)

 -- INTRODUCTION
 -- THE PREDICATE prolog_language/1
 -- THE PREDICATE prolog_current_language/1
 -- COMMANDS TO CHANGE LANGUAGES EASILY
 -- ERRORS
 -- RELATED DOCUMENTATION


-- INTRODUCTION -------------------------------------------------------

If you just want to do simple things in POP-11 from within Prolog, then
you will be better served by reading PLOGHELP * SIMPLEPOP. Sophisticated
users are referred to PLOGHELP * POPTOPLOG, PLOGHELP * PLOGTOPOP and
PLOGHELP * MIXED_LANGUAGES. This file describes switching between
languages within files and while interacting with the Prolog top level.


-- THE PREDICATE prolog_language/1 ------------------------------------

In POPLOG, you can have files written in several languages.  From
Prolog, you can get to any other language you have loaded in the system
by doing

    ?- prolog_language(Language_name).

When the Prolog system is loaded, you will have three language
subsystems available (see REF * SUBSYSTEM): Prolog top level, Prolog
reconsult, and POP-11. Suppose you wanted a (nominally) Prolog file,
which you wanted to consult or reconsult, but which had parts written in
POP-11.  You could do it like this:

-----------------------------------------------------top of file
    /* here we are in prolog */

        :- prolog_language(pop11).

    /* now we are in pop11 */

        define foo(a, b, c) -> result;
            ...
        enddefine;

        :- prolog_language(prolog).     /* the ":-" works in POP-11 too */

    /* back to prolog */

        foo(A, B, C, Result) :-
            prolog_eval(foo(A,B,C), Result).

-----------------------------------------------------end of file

After you have consulted this file, you will be wherever you started
off.


-- THE PREDICATE prolog_current_language/1 ----------------------------

You can find out what language you are in by doing

        ?- prolog_current_language(X).
        X = top ?


-- COMMANDS TO CHANGE LANGUAGES EASILY --------------------------------

If you want to change language often, it is helpful to have some
commands defined to make the process less long-winded. There is a
library which defines some new Prolog commands and POP-11 macros, which
can be loaded by typing:

        ?- library(languages).

You will then have three commands available:

    POP11
        To take you to POP-11
    TOP
        To take you to Prolog top level
    PROLOG
        To take you to Prolog reconsult

Note that these commands actually are in UPPERCASE LETTERS -- even in
Prolog. All three commands will work from all three language subsystems.


-- RELATED DOCUMENTATION ----------------------------------------------

PLOGHELP * LIBRARIES
 Overview of Prolog library programs

PLOGHELP * MIXED_LANGUAGES
 Methods of interfacing Prolog and other languages

PLOGHELP * PLOGTOPOP
 How to call POP-11 from Prolog

PLOGHELP * POPSTRING
 How to put POP-11 strings in Prolog programs

PLOGHELP * POPTOPLOG
 How to call Prolog from POP-11

PLOGHELP * PROLOG_EVAL
 How to evaluate the Prolog representation of a POP-11 expression

PLOGHELP * SIMPLEPOP
 Library package to do simple things in POP-11 from Prolog


--- C.all/plog/help/prolog_language ------------------------------------
--- Copyright University of Sussex 1990. All rights reserved. ----------
