Edward Tate
unread,Aug 6, 2011, 2:48:35 PM8/6/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Lisp Flavoured Erlang
Hey Robert,
Some ideas and thoughts that I've had whilst giving LFE a deeper look.
LFE by default makes me write (: gen_server start_link args) which I
don't think makes it very clear which are the arguments in the list at
first sight.
An alternative I thought for this would be to have something like:
(start_link@gen_server ... 'test '() '())
To denote a module call.
Defun is more verbose and def, and def doesn't have the disadvantage
of causing a spelling mistake (should be deffun).
Everything has to be quoted, strings, symbols etc. Why not make
symbols & lists quoted by default, and have ? and _ be used as the
symbol to denote a variable:
(start_link@gen_server ... test () ())
(def start_link (?arg)
(start_link@gen_server {local ?arg} test () ()))
(def ping ()
(call@gen_server test ping))
I find this makes it clear what is to be matched and what is data.
What about literal syntax for lists, tuples, and patterns?
;; literal syntax
;; using ((), [], {})
;; () -> literal list
;; [] -> literal pattern (explained below)
;; {} -> literal tuple
(def init (_args)
{ok ()})
(def handle_call (_req _from ?state)
{reply pong ?state})
(def handle_cast (_msg ?state)
{noreply ?state})
(def handle_info (_info ?state)
{noreply ?state})
What about having types?
(deftype ok atom)
(deftype string (list number))
And typed protocols?
(defprotocol file
;; open a file
(open (?path:string ?options:list)
?io_device:io_device)
;; close a file
(close (?io_device:io_device)
?response:ok)
;; read a character
(read_char (?io_device)
?result:character))
And high-order patterns, which may later be used to build a pattern
based macro system?
;; high-order patterns
(def run_example ()
(match_pattern [{ok, ?x}])) ;; literal pattern syntax
(def match_pattern (?pat)
(match ?pat {ok 1}
({ok, ?x}
(format@io "got: ~p~n" ?x))
(_error
{error "wrong pattern"})))
Ed