User_default functions in the shell.

23 views
Skip to first unread message

Mason Staugler

unread,
Feb 2, 2015, 2:43:04 PM2/2/15
to lisp-flavo...@googlegroups.com
Is there a way to import the functions defined in the user_default module into the shell?

Robert Virding

unread,
Feb 2, 2015, 6:34:16 PM2/2/15
to lisp-flavo...@googlegroups.com
No, currently there is no specific handling of the user_default module. If it written in LFE then you can do (slurp 'user_default) which will load in the source file and make the functions accessible. How ever slurping in a file will overwrite the previous slurp, you can only have one file slurped in at a time so it is not really safe.

I will look into this.

Robert

Mason Staugler

unread,
Feb 3, 2015, 11:52:33 AM2/3/15
to lisp-flavo...@googlegroups.com
Slurp is pretty good for now, since I mainly need it to start a process to compile and reload what I'm working on.

Thanks a lot!

Duncan McGreggor

unread,
Feb 3, 2015, 11:54:51 AM2/3/15
to lisp-flavo...@googlegroups.com
Robert, remember how we talked on the possibility of modules in the REPL at the EUC LFE Summit? (i.e., namespaces in the REPL). This sort of touches on that topic tangentially ... have you had any more thoughts about it?

d

--
You received this message because you are subscribed to the Google Groups "Lisp Flavoured Erlang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lisp-flavoured-e...@googlegroups.com.
To post to this group, send email to lisp-flavo...@googlegroups.com.
Visit this group at http://groups.google.com/group/lisp-flavoured-erlang.
For more options, visit https://groups.google.com/d/optout.

Robert Virding

unread,
Feb 3, 2015, 8:39:20 PM2/3/15
to lisp-flavo...@googlegroups.com
There is actually a better solution already in the shell: you can run an LFE shell script file with (run "file-name"). The script file can contain any LFE shell commands including defining functions and macros. If you do this first, or at least before slurping a file, then any definitions in the shell script file will remain even if you slurp/unslurp. There is just no provision for the shell to automatically do this at start-up time.

Robert

P.S. If you get totally fed-up with your whole state in the shell you can (reset-environment) which just resets everything to the default startup settings.

Mason Staugler

unread,
Feb 4, 2015, 11:55:02 PM2/4/15
to lisp-flavo...@googlegroups.com
Run is better, but is there some way to automatically run it at start up?

I don't have much experience with Erlang. It doesn't seem like the .erlang file is much used based on the blog posts I've come across. I really like it because I'm trying to write literate programs and it makes it easy to do the two stages of compilation and then code reloading.

I tried `lfe_shell:run_script` and exporting `lfe_shell:run/2` but I'm not sure how to hook them in to the running environment. Is it `lfe_shell:run_loop`?

Robert Virding

unread,
Feb 7, 2015, 12:35:29 PM2/7/15
to lisp-flavo...@googlegroups.com
No, currently there is nothing you can do in the .erlang file to help initialise the LFE shell. You can compile and preload modules of course but affect the LFE shell. The reason is that the LFE shell has its own local environment which must be initialised when the shell is started and their is currently no way of telling an LFE shell how to initialise itself. The normal erlang shell can only do limited initialisation, basically it will try to call things in the 'user_default' module.

I see a number of different solutions:

- Fix the LFE shell so when it starts it automatically goes out and finds 'user_default' and adds links to all its exported functions.
- Modify the LFE interpreter in lfe_eval so you can add an undefined local function handler when you try to call an undefined local function. The shell could then add a handler which tries calling user_default.
- Maybe fix some form of global initialisation for LFE shells which they all could plug into.

The first is easy, the second one is how it works with the erlang shell and evaluator. The third I am more sceptical to as you could want multiple shells which are relatively independent.

Robert

P.S. Yes, when I say "shell" I mean what most lispers call a REPL. Pure force of habit from calling the erlang shell a shell while it is in fact a REPL.

Mason Staugler

unread,
Feb 8, 2015, 12:08:48 AM2/8/15
to lisp-flavo...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages