1

Given the following code:

example1(X) :- X is 1.
example2(X) :- X is 1+1.

when I run it with gprolog, I get:

$ gprolog 
GNU Prolog 1.4.0
By Daniel Diaz
Copyright (C) 1999-2011 Daniel Diaz
| ?- ['example'].
compiling /Users/tomo/projects/7L7W/prolog/day2/example.pl for byte code...
/Users/tomo/projects/7L7W/prolog/day2/example.pl compiled, 1 lines read - 490 bytes written, 7 ms

(1 ms) yes
| ?- example1(X).

X = 1

yes
| ?- example2(X).

Fatal Error: Segmentation Violation

However, if I compile the file:

$ gplc example.pl -o example
$ ./example 
GNU Prolog 1.4.0
By Daniel Diaz
Copyright (C) 1999-2011 Daniel Diaz
| ?- example1(X).

X = 1

yes
| ?- example2(X). 

X = 2

yes

What am I missing? Why it segfaults in the first case and runs OK in the second?

(If it helps: Mac OS 10.7.2)

Tomo
  • 3,431
  • 5
  • 25
  • 28

1 Answers1

1

That's probably a bug in gprolog. Just report it.

Also, you may prefer to use SWI-Prolog that is quite more popular and supported.

salva
  • 9,943
  • 4
  • 29
  • 57
  • Yeah, I guess that's right. Asking it on SO is easier than subscribing to a mailing list to report a bug, so I thought I try here first :-) – Tomo Nov 21 '11 at 18:52