I want to know what the implementation code would look like for this built in predicate read_term_from_atom/3 so that I can recreate the predicate myself.
Asked
Active
Viewed 191 times
-2
-
1The source code fo SWI Prolog is available online. If you don't know where to find it, try Googling "SWI Prolog source code". – lurker Jan 22 '18 at 12:02
-
I've downloaded the source code from https://github.com/SWI-Prolog/swipl-devel and can't find an implementation for this method in there, lots of explanations of what it does but nothing on how to write it yourself. – Sam Jan 22 '18 at 20:35
-
Actually it looks like they implement it using PERL, I'm wondering how to take an atom surrounded by quotes and put the value inside the quotes to a variable without using this built in. I'll post the my question on another question. – Sam Jan 22 '18 at 20:38
-
1PERL?? No, it's in C. `src/pl-read.c`. You're probably seeing a bunch of `.pl` files, which is Prolog file extension. – lurker Jan 22 '18 at 21:12
1 Answers
0
If you want to redefine SWI-Prolog's standard term input you should redefine read_term/3
via redefine_system_predicate/1
This directive may be used both in module user and in normal modules to redefine any system predicate.
If the system definition is redefined in module user, the new definition is the default definition for all sub-modules.
Otherwise the redefinition is local to the module. The system definition remains in the module system.
http://www.swi-prolog.org/pldoc/man?predicate=redefine_system_predicate/1

Anton Danilov
- 1,246
- 11
- 26