On Mon, Oct 02, 2017 at 10:39:04AM +0000, Marc Worrell wrote:
> 
> > On 2 Oct 2017, at 02:19, Jake Morrison <j...@cogini.com> wrote:
> > 
> > Marc,
> > 
> > On Fri, Sep 29, 2017 at 09:40:07AM +0000, Marc Worrell wrote:
> >> Can mix build rebar3 based apps?
> > 
> > Mix is more or less a replacement for rebar3, so they are mutually
> > exclusive, though largely compatible.
> > 
> >> If so then we can just provide a mix based project.
> > 
> > For Elixir users, the easiest thing is if Zotonic can be used
> > as a library which can be pulled in by mix/rebar from https://hex.pm/,
> > i.e. it's a well behaved OTP application. It might make sense
> > to have some mix tasks which e.g. create template modules. 
> 
> The master is being split in OTP apps, with the specific goal of
> being reusable.
> 
> Actually, there is not much left in the ‘zotonic.app’, almost everything
> is moved to the other (OTP) apps.
> 
> So I guess having a Mix (/Elixir) project that people can clone could
> be a good starting point for Elixir devs.

The most interesting thing is probably an example combining Zotonic with
Phoenix. 

> >> I am also thinking of using the introspection (we are using that for
> >> notify observers) to discover if a module, filter, action or other
> >> type of Zotonic callback module is an Elixir module.
> >> And if so we could generate or use some glue code to call directly
> >> into the Elixir modules from Zotonic.
> > 
> > Generally speaking, Elixir code is functionally the same as Erlang
> > code, the module atoms just start with 'Elixir.', so that may not be
> > necessary. 
> 
> So if an Elixir source file defines the Elixir equivalent of a function:
> 
>       observe_some_event/2
> 
> Then in the function definitions I can find just that function?
> And the module itself would be loaded as ElixitSomModuleName?
> 
> That would make it quite straightforward to integrate Elixir code
> into the notification system.

It's basically the same, just the Elixir compiler adds "Elixir" to
the front of the module names. So probably nothing needs to be done. 

In Erlang, if you have a module foo, it would look like:

-module(foo).

-export([observe_some_event/2]).

observe_some_event(One, Two) -> ...

And you would call it like foo:observe_some_event(One, Two)

In Elixir, it would look like:

defmodule Foo do
  def observe_some_event(one, two) do
  ...
  end
end

>From Erlang, the module atom would be 'Elixir.Foo', and you can call it
like 'Elixir.Foo':observe_some_event(One, Two) or apply('Elixir.Foo',
observe_some_event, [One, Two])

> - M

Jake

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Zotonic developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to zotonic-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to