Re: [efene] erlang -behaviour in efene?
- From:
- Роман Пельвецкий
- Date:
- 2010-10-26 @ 19:29
Thanks :)
BTW, is there an Erlang to Efene convertion tool?
It definitely would be an argument for "unsure erlangers".
For example the Boo language for .NET has C# to Boo converter.
Cheers, Roman
2010/10/26 Mariano Guerra <luismarianoguerra@gmail.com>
> I copied an example from here:
>
> http://www.erlang.org/doc/design_principles/sup_princ.html
>
> this is the erlang code:
>
> -module(ch_sup).
> -behaviour(supervisor).
> -export([start_link/0]).
> -export([init/1]).
> start_link() ->
> supervisor:start_link(ch_sup, []).
> init(_Args) ->
> {ok, {{one_for_one, 1, 60},
> [{ch3, {ch3, start_link, []},
> permanent, brutal_kill, worker, [ch3]}]}}.
>
> this is the efene code I wrote:
>
> @@behaviour(supervisor)
>
> @public
> start_link = fn ()
> supervisor.start_link(ch_sup, [])
>
> @public
> init = fn (_Args)
> (ok, ((one_for_one, 1, 60),
> [(ch3, (ch3, start_link, []),
> permanent, brutal_kill, worker, [ch3])]))
>
> this is the output of the transformation from efene to erlang:
>
> mariano@ganesha:~$ fnc -t erl ch_sup.ifn
> -module(ch_sup).
>
> -export([start_link/0, init/1]).
>
> -behaviour(supervisor).
>
> start_link() -> supervisor:start_link(ch_sup, []).
>
> init(_Args) ->
> {ok,
> {{one_for_one, 1, 60},
> [{ch3, {ch3, start_link, []}, permanent, brutal_kill,
> worker, [ch3]}]}}.
>
> so yep, we support behaviours :)
>
> when you want to write an attribute from erlang in efene just replace
> the leading "-" for "@@", it should work (@ attributes are bound to
> the function that follows, much like decorators in python).
>
> hope that helps :)
>
Re: [efene] erlang -behaviour in efene?
- From:
- Mariano Guerra
- Date:
- 2010-10-26 @ 20:10
2010/10/26 Роман Пельвецкий <ffindermeister@gmail.com>:
> Thanks :)
>
> BTW, is there an Erlang to Efene convertion tool?
> It definitely would be an argument for "unsure erlangers".
> For example the Boo language for .NET has C# to Boo converter.
no there isn't, but if I rewrite the efene pretty printer to use the
ast instead of the lexer output then I could transform erlang to efene
:)
the problem is that there are some things in efene that are expanded
to more code in erlang, those are hard to detect in the ast to
generate the original syntax, but it may be possible.