Swinject / Swinject-CodeGen

Generate code to make the use of Swinject type-safe and reduce duplicate identifiers for Services
MIT License
33 stars 5 forks source link

ADD_DEPENDENCY syntax #30

Closed ddengler closed 8 years ago

ddengler commented 8 years ago

@Lutzifer I would suggest to replace this with a simple comment block allowing any text to be placed as code in the resulting header instead of explicitly defining dependencies. This would be a lot more flexible. What do you think?

yoichitgy commented 8 years ago

@ddengler It's great to have the flexibility. On the other hand, limiting the option to ADD_DEPENDENCY makes the usage easier to understand. It's a trade off between flexibility and ease of use.

Would you give me examples for what you are going to use the flexibility?

(My opinion is still neutral. I want to know what kind of things can be achieved with the flexibility💪)

ddengler commented 8 years ago

@yoichitgy From the top of my head: preprocessor macros or some typedefs or whatever else a user might need in the header I cannot think of right now :)

ddengler commented 8 years ago

And a user does not have to learn the ADD_DEPENDENCY syntax and can just write / copy&paste what he is already used to

yoichitgy commented 8 years ago

@ddengler Thanks for the answers. Let me take time to think. @Lutzifer What do you think?

Lutzifer commented 8 years ago

@ddengler @yoichitgy I would propose a general ADD_HEADER command. Simply using comments for it takes away the possibility to use comments for anything else.

yoichitgy commented 8 years ago

I think Lutzifer's idea ADD_HEADER is good.

@Lutzifer Do you mean we are going to support only ADD_HEADER? Or will you support ADD_DEPENDENCY too?

Lutzifer commented 8 years ago

I would only allow AD_HEADER, so

# ADD_DEPENDENCY Keychain

becomes

# ADD_HEADER import "Keychain"

yoichitgy commented 8 years ago

@Lutzifer I agree, thanks for the clarification.

@ddengler What do you think about @Lutzifer's idea?

Lutzifer commented 8 years ago

the https://github.com/Swinject/Swinject-CodeGen/tree/example_add_header has a prototype implementation of this

ddengler commented 8 years ago

Rails uses in something like the following

# some comment for regular comments

#= import "Keychain" for code to be inserted

Basically the same but a lot shorter

Lutzifer commented 8 years ago

i like that

yoichitgy commented 8 years ago

So do I. Let's use #= to add a header part.

Lutzifer commented 8 years ago

fixed by #55