PART 4    Programmer's Guide

 

CHAPTER 17    Elements of the Language

 

In this chapter, we summarize the elements of the Visual Prolog compiler and language. We discuss some fundamental elements of the language: names, program sections, compiler directives, and memory management.

After this we give an introduction to handling modules in Visual Prolog, and how a program can be split up into several modules, which you can then compile separately and link together.

We've written this chapter for programmers who've already worked some with Visual Prolog. To get the most benefit out of this chapter, you should be familiar with the material in the first chapters of the Visual Prolog Language.

Names

In Prolog, names are used to denote symbolic constants, domains, predicates, and variables. A name consists of a letter, or an underscore character, followed by any combination of zero or more letters, digits, and underscores. Two important restrictions are imposed on names:

Names of symbolic constants must start with a lower-case letter.

Names of variables must start with an upper-case letter or an underscore.

Except for these restrictions, you can use upper-case and lower-case letters in your pro­grams as you please. For instance, you could make a name more readable by using mixed upper-case and lower-case, as in the variable

    MyLongestVariableNameSoFar

or by using underscores, as in

    pair_who_might_make_a_happy_couple(henry_viii, ann_boleyn)

The Visual Prolog compiler does not make a distinction between upper and lower case letters, except for the first letter. This means that the two variables:

    SourceCode

and

    SOURCECODE

are the same.

(1) Keywords

The following are reserved words; you must not employ them as user-defined names:

and

clauses

constants

database

domains

elsedef

enddef

global

goal

if

ifdef

ifndef

include

or

predicates

 

(2) Specially-Handled Predicates

The following list of predicates are handled specially by the compiler.

assert

asserta

assertz

bound

chain_inserta

chain_insertafter

chain_insertz

 

chain_terms

consult

db_btrees

db_chains

fail

findall

format

 

free

msgrecv

msgsend

not

readterm

ref_term

retract

 

retractall

save

term_bin

term_replace

term_str

trap

write

writef