Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructors #7

Closed
binarytemple opened this issue May 19, 2019 · 5 comments
Closed

Constructors #7

binarytemple opened this issue May 19, 2019 · 5 comments

Comments

@binarytemple
Copy link

binarytemple commented May 19, 2019

Joking aside - I'd like to use this code for an open-source project I want to write. Have you any suggestions as to how I would go about implementing (chained) constructors / init with this library?

@bryanhuntesl
Copy link

oop/lib/oop.ex

Lines 141 to 146 in 1bc0caf

def inherit_method(method, arity, parent) do
args = (0..arity) |> Enum.drop(1) |> Enum.map(fn i -> {:"arg#{i}", [], OOP} end)
{:defdelegate, [context: OOP, import: Kernel],
[{method, [], args}, [to: parent]]}
end

@bryanhuntesl
Copy link

Somehow override new ? Add a new keyword ?

@bryanhuntesl
Copy link

bryanhuntesl commented May 19, 2019

As a first attempt perhaps I could override the implementation of Application and provide my own custom registry ?

defmodule OOP.Application do
  use Application

  def start(_type, _args) do
    OOP.Registry.start_link()
  end
end

@wojtekmach
Copy link
Owner

Hi, sorry for delay. I don't plan to extend the library beyond what it already is. Of course you're welcome to use it but I'd highly recommend against it as it was neither thoroughly tested nor optimised and finally vanilla Elixir and Erlang is fundamentally easier to work with.

Thanks for your interest in it!

@binarytemple
Copy link
Author

Hahaha yeah - pretty warped request - plan was to implement a terraform validator/simulator - it does everything with constructors - thought it might be easier than implementing from scratch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants