# Loading R sourc file in real

**URL:** <https://swi-prolog.discourse.group/t/loading-r-sourc-file-in-real/1511>\
**Category:** Help!\
**Created:** [November 15, 2019, 3:46pm UTC](https://swi-prolog.discourse.group/t/loading-r-sourc-file-in-real/1511 "2019-11-15T15:46:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pjadata](https://avatars.discourse-cdn.com/v4/letter/p/8dc957/32.png) [@pjadata](https://swi-prolog.discourse.group/u/pjadata)\
**Post date:** [November 15, 2019, 3:46pm UTC](https://swi-prolog.discourse.group/t/loading-r-sourc-file-in-real/1511/1 "2019-11-15T15:46:46Z")

</div>

I’m using: SWI-Prolog version 8.1.10

I want the code to: load a R source file containing my R functions

But what I’m getting is:

?- r(source(‘R\_proj1.R’)).  
ERROR: R was unable to digest your statement, either syntax or existance error.  
?- r(source(’…/R\_jab/R\_proj1.R’)).  
ERROR: R was unable to digest your statement, either syntax or existance error.  
?- r(source(’~/R\_jab/R\_proj1.R’)).  
Error: 3, in parsing R expression.  
ERROR: R was unable to digest your statement, either syntax or existance error.

Thank you in advance for your help

Jab

---

<div class="post-metadata">

**Author:** ![mgondan](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@mgondan](https://swi-prolog.discourse.group/u/mgondan)\
**Post date:** [November 17, 2019, 12:52pm UTC](https://swi-prolog.discourse.group/t/loading-r-sourc-file-in-real/1511/2 "2019-11-17T12:52:35Z")

</div>

Unsure if it is related, but I also experience some trouble with “real” (Windows, 32-Bit, swipl 8.1.16). See this little program:

```prolog
:- use_module(library(real)).
:- <- frac = (function(x, y) :- return(x/y)).

example :-
    X <- frac(1, 2),
    writeln(X).

```

If I start swipl-win.exe, then open the program and just compile it from the editor (Ctrl-C Ctrl-B), “example.” fails, and if I type “halt.”, swipl crashes.

If I start swipl-win.exe, manually say “use\_module(library(real))”, then compile the program and run example, everything is fine.

I guess the :- use\_module and :- \<- directives are invoked in parallel threads, so I must somehow make sure they are called one after the other.

Nevertheless, there seems to be some little bug somewhere which causes “example.” to fail silently and swipl to crash in the end.

Best wishes,

Matthias

---

<div class="post-metadata">

**Author:** ![mgondan1](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/mgondan1/32/803_2.png) [@mgondan1](https://swi-prolog.discourse.group/u/mgondan1)\
**Post date:** [November 17, 2019, 1:14pm UTC](https://swi-prolog.discourse.group/t/loading-r-sourc-file-in-real/1511/3 "2019-11-17T13:14:09Z")

</div>

Just checked under linux (also 32-Bit). There, the problem does not appear.
