Erlang/OTP Forums

Author Message

<  User Contributions  ~  LFE - Lisp Flavoured Erlang

rvirding
Posted: Sun Mar 02, 2008 12:26 am Reply with quote
User Joined: 30 Aug 2006 Posts: 452 Location: Stockholm, Sweden
This is LFE, Lisp Flavoured Erlang, which is a lisp syntax front-end to the Erlang compiler. Code produced with it is compatible with "normal" Erlang code. Most things seem to work but some things have not been done yet:

- The interpreter does handle recursive letrecs, binaries, receive or try.
- There is no lisp shell.

Yet. The system will be updated as new features are added.



LFE 0.1.zip
 Description:
First version of LFE.

Download
 Filename:  LFE 0.1.zip
 Filesize:  47.6 KB
 Downloaded:  2745 Time(s)

View user's profile Send private message Visit poster's website MSN Messenger
rvirding
Posted: Thu Mar 06, 2008 9:18 pm Reply with quote
User Joined: 30 Aug 2006 Posts: 452 Location: Stockholm, Sweden
This patch contains a fix to the bug Yariv reported as well as the following changes:

- Macro expansion now occurs in patterns
- _ added as don't care variable to patterns

as well as some internal code changes.

Just unload it on top of the original files and recompile.



LFE 0.1 patch 1.zip
 Description:
Patch 1 to LFE 0.1.zip.

Download
 Filename:  LFE 0.1 patch 1.zip
 Filesize:  33.51 KB
 Downloaded:  2476 Time(s)

View user's profile Send private message Visit poster's website MSN Messenger
rvirding
Posted: Fri Apr 25, 2008 2:56 pm Reply with quote
User Joined: 30 Aug 2006 Posts: 452 Location: Stockholm, Sweden
This is version 0.2 of LFE, Lisp Flavoured Erlang. New features in LFE 0.2 are:

- The really *BIG* change is that LFE is now Lisp-2 like Common Lisp,
i.e. functions and variables reside in different name spaces,
instead being a Lisp-1 like Scheme where they reside in the same
name space. The reason for this change is that the ErlangVM does
keep variables and functions separate and while Core Erlang tries to
hide this fact it does not fully succeed. In fact, it is actually
impossible to do this given Erlang's property of being able to have
many functions of the same name but with different arites.

While this is not as elegant and forces the use of funcall to call
functions bound to variables it works better.

It is not an irrevocable change but I would need really convincing
arguments to change it back.

- Being a Lisp-2 has introduced some new core forms to handle them:
flet, flet*, fletrec and funcall. Letrec has been removed.

- The handling of macros has been cleaned up.

- Schemes, R5RS, handling of ellipsis '...' in syntax-rules has been
added. This really simplifies writing some macros in a elegant way.

- The interpreter, lfe_eval, can now handle the complete language.

- In patterns both tuples and binaries/bitstrings use the general
constructor form, the constant form now only matches a literal tuple
or binary. For example:

(tuple 'ok a b) - is eqivalent to {ok,A,B}
#('ok a b) - is eqivalent to {[quote,ok],a,b}
(binary (f float (size 32)) (rest binary))
- is eqivalent to <<F:32/float,Rest:binary>>

Even though this may be longer and, in some cases, more difficult to
"see" I prefer it as it is consistent.

- Patterns can now have aliases, (= pat-1 pat-2). These are checked in
the linter and non-matching patterns are classed as an error. In
future releases they should become warnings.

- There is now an LFE shell which evaluates expressions and prints the
results. It is still a bit primitive and doesn't use processes as it
should in the same manner as the standard Erlang shell does. But it
does have one very nice feature, you can slurp in a source file and
run evaluate all the functions in the shell. Any macros defined in
the file are also available.

It is not yet possible to define functions/macros in the shell but
that should use soon be possible. You should also then be able to do
regurgítate which would write all the definitions out to a file.

- Running a shell other than the standard erlang one is a bit
difficult so I have included a patched version of user_drv.erl from
the standard kernel app which allows you to start specific shells,
both local and remote. You can either put it into the distribution
or leave it where you run the LFE system and it will be picked
up. As far as I can see it is "safe" to use.

- There are two versions of the interpreter, one written in Erlang,
the standard, and a compatible one written in LFE. Lfe_eval.lfe is
not written in a consistent manner and can be seen as an example of
the various styles of LFE programming, for example using
match-lambda or lambda/case.

- As before there are a number of test files included as example code
in lieu of better documentation. They are also useful to see the
Core code generated by the LFE compiler, just add an option
[dcore]. N.B. Not all the test files compile, but this is on purpose
to test linter.

- There is now a lisp prettyprinter in lfe_io. Unfortunately the io
functions in lfe_io are not always obviously named from a lisp
viewpoint.



LFE 0.2.zip
 Description:
Version 0.2 of LFE.

Download
 Filename:  LFE 0.2.zip
 Filesize:  80.33 KB
 Downloaded:  2557 Time(s)

View user's profile Send private message Visit poster's website MSN Messenger
rvirding
Posted: Mon Jun 02, 2008 3:23 pm Reply with quote
User Joined: 30 Aug 2006 Posts: 452 Location: Stockholm, Sweden
These are the overheads from a presentation of LFE which I gave an Erlang Stockholm Usergroup meeting recently.



Lisp Flavoured Erlang.zip
 Description:
LFE presentation

Download
 Filename:  Lisp Flavoured Erlang.zip
 Filesize:  54.55 KB
 Downloaded:  2858 Time(s)

View user's profile Send private message Visit poster's website MSN Messenger
rvirding
Posted: Wed Jun 18, 2008 8:52 pm Reply with quote
User Joined: 30 Aug 2006 Posts: 452 Location: Stockholm, Sweden
This patch contains two major changes:

- list/binary comprehensions have been added (contains a test and bind variables option)
- extra option for cond to test and bind variables (this is a big win)

plus some internal changes and new example file (test files really).

This should be the last minor version before the next full release which should have the new (and final) syntax.



LFE 0.2.1.zip
 Description:
Version 0.2.1 of LFE.

Download
 Filename:  LFE 0.2.1.zip
 Filesize:  77.84 KB
 Downloaded:  2448 Time(s)

View user's profile Send private message Visit poster's website MSN Messenger
rvirding
Posted: Thu Sep 25, 2008 10:01 pm Reply with quote
User Joined: 30 Aug 2006 Posts: 452 Location: Stockholm, Sweden
This is an updated version of the LFE presentation which better describes the new Common Lisp inspired style.



Lisp Flavoured Erlang.zip
 Description:
Updated LFE presentation

Download
 Filename:  Lisp Flavoured Erlang.zip
 Filesize:  40.69 KB
 Downloaded:  2171 Time(s)

View user's profile Send private message Visit poster's website MSN Messenger
rvirding
Posted: Sun Sep 28, 2008 8:52 pm Reply with quote
User Joined: 30 Aug 2006 Posts: 452 Location: Stockholm, Sweden
This is the first version with the modified internal core forms and macro intefaces for the new CL inspired style and the older Scheme inspired style.

Two new modules have been added:

lfe_boot allows you start Erlang with the LFE shell running and still have ^G enabled and user_drv running. Use it as follows:

erl -noshell -noinput -s lfe_boot start

NOTE order of commands important, must be -noshell -noinput! Add -pa to find modules if necessary.

lfe_gen is a trial interface for using LFE for dynamic code generation. LFE is much easier to generate as an Erkang list than Erlang forms. This module helps defining and compiling a module. Note,
that while it works, this module is very experimental and may change.



lfe_v0.3.zip
 Description:
Version 0.3 of LFE.

Download
 Filename:  lfe_v0.3.zip
 Filesize:  193.39 KB
 Downloaded:  2126 Time(s)

View user's profile Send private message Visit poster's website MSN Messenger
febeling
Posted: Fri Feb 27, 2009 5:05 pm Reply with quote
Joined: 03 Sep 2008 Posts: 1 Location: Berlin
Note: development has moved to Github now, it seems: http://github.com/rvirding/lfe/tree/master
View user's profile Send private message
rvirding
Posted: Sun Mar 15, 2009 6:18 pm Reply with quote
User Joined: 30 Aug 2006 Posts: 452 Location: Stockholm, Sweden
Incremental changes are released on github, but I will continue to upload new full releases here as well. A new full release is long overdue, hopefully I will get one out during April.
View user's profile Send private message Visit poster's website MSN Messenger
rvirding
Posted: Thu May 21, 2009 8:33 pm Reply with quote
User Joined: 30 Aug 2006 Posts: 452 Location: Stockholm, Sweden
This is the long overdue v0.4 of LFE containing some real goodies. Amongst other things:

Parameterized modules.

Added (export all) attribute to module definition.

New records which allow giving default values as in vanilla
Erlang. Records are still compatible with vanilla Erlang but now more pratical to use. NOTE this change is not backwards compatible as syntax for (make- ...) and (match- ...) have changed. Also added general multiple (set- ...) macro.

(eval-when-compile ...) added as a top-level form which allows functions to be defined when compiling the forms. These are useful for more complex macros.

Better and more documention. The documentation is still normal text files as Edoc and I are not in agreement on how things should work.

This will be the last development version for Erlang R12B-5 and older, all future development will for R13B. If there is enough interest I may start a separate branch for R12B.



lfe_v0.4.tgz
 Description:
Version 0.4 of LFE.

Download
 Filename:  lfe_v0.4.tgz
 Filesize:  169.1 KB
 Downloaded:  1888 Time(s)

View user's profile Send private message Visit poster's website MSN Messenger
Dionnah
Posted: Sat Aug 15, 2009 4:45 pm Reply with quote
Joined: 15 Aug 2009 Posts: 1
This is of great information to me. Thanks for sharing. Great job guys. Keep it up.

Pret immobilier
View user's profile Send private message
rvirding
Posted: Mon Oct 19, 2009 9:59 pm Reply with quote
User Joined: 30 Aug 2006 Posts: 452 Location: Stockholm, Sweden
At last v0.5 of LFE, long overdue as usual. Some goodies it contains:

Added macro list*.

Added a new shell command to set variables in the shell.

Cleaned up compiler options and made them more like the vanilla compiler.

Added unicode types to binaries: utf-8, utf-16 and utf-32.

Shell and compiler now print error data in LFE instead of vanilla. Shell error reporting still pretty basic, not as "beautiful" as vanilla.

Cleaned up i/o functions and added formated output function. Still use vanilla command characters.

All i/o goes through then module lfe_io. The functions which return the corresponding printable string end in 1. So lfe_io:format prints formatted output while lfe_io:format1 returns the string.

Improved pretty-printing.

Many internal improvements.



lfe_v0.5.tgz
 Description:
Version 0.5 of LFE.

Download
 Filename:  lfe_v0.5.tgz
 Filesize:  218.14 KB
 Downloaded:  1602 Time(s)

View user's profile Send private message Visit poster's website MSN Messenger
rvirding
Posted: Mon Dec 14, 2009 12:07 am Reply with quote
User Joined: 30 Aug 2006 Posts: 452 Location: Stockholm, Sweden
This version contains a fix which allows it to run under R13B03 which had made incompatible internal changes in the compiler. Thanks to Matt Stancliff <matt@genges.com> for pointing it out and providing a fix.

It all also contains a new example file.



lfe_v0.5.1.tgz
 Description:
Version 0.5.1 of LFE.

Download
 Filename:  lfe_v0.5.1.tgz
 Filesize:  168.05 KB
 Downloaded:  1579 Time(s)

View user's profile Send private message Visit poster's website MSN Messenger
anisplas
Posted: Thu Jan 07, 2010 8:07 pm Reply with quote
Joined: 02 Jan 2010 Posts: 3
Shell and compiler now print error data in LFE instead of vanilla. Shell error reporting still pretty basic, not as "beautiful" as vanilla.

Dental Implants Reading
Dentists Reading
View user's profile Send private message
rvirding
Posted: Wed Aug 10, 2011 2:03 am Reply with quote
User Joined: 30 Aug 2006 Posts: 452 Location: Stockholm, Sweden
I have just committed a new version of LFE, v0.7a, to github:

https://github.com/rvirding/lfe

It has been quite a while so there are a number of changes. This is an 'a' release as there some additions which need user testing before they are finalized, notably Query List Comprehensions. These still need more work but I would like feedback on the interface. Other changes are:

First version of Query List Comprehensions.

Add access to current macro environment through the variable $ENV within macros which allows explicit macro expansion.

First version of match-specification generator.

Add ets/mnesia match patterns to records.

Arithmetic functions + - * / and comparison functions > >= < =< == /= =:= =/= now take multiple arguments. This is experimental and as yet only implemented as macros.

Handle compiler option warnings_as_errors in the same way as the vanilla Erlang compiler.

Improved ++ macro can now be used in patterns.

List/binary comprehensions generate fewer unnecessary compiler warnings.

Added new example file with core macros implemented in LFE.

New patterns with explicit constructors! We now follow the invariant that constructors and patterns should look the same. It is still possible to use old patterns but 'cons' and 'list' now as as "reserved words" like 'tuple' and 'binary'.

Allow guards with generators in list/binary comprehensions. N.B. can cause unexpected behaviour with binary generators.

Robert

_________________
Robert Virding, Erlang Solutions Ltd.
View user's profile Send private message Visit poster's website MSN Messenger

Display posts from previous:  

All times are GMT
Page 1 of 2
Goto page 1, 2  Next
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum